dfs
This commit is contained in:
parent
35a9cd1bfe
commit
b6db34b505
1 changed files with 33 additions and 35 deletions
|
@ -702,48 +702,46 @@ def thumbnail_thread(pid):
|
||||||
|
|
||||||
if SITE == 'rdrama.net':
|
if SITE == 'rdrama.net':
|
||||||
for t in ("submission","comment"):
|
for t in ("submission","comment"):
|
||||||
for term in ('rdrama'):
|
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q=rdrama&size=10').json()["data"]:
|
||||||
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={term}&size=10').json()["data"]:
|
|
||||||
|
|
||||||
body_html = sanitize(f'New rdrama mention: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
|
body_html = sanitize(f'New rdrama mention: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
|
||||||
|
|
||||||
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html, level=1, sentto=0).first()
|
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html, level=1, sentto=0).first()
|
||||||
|
|
||||||
if existing_comment: break
|
if existing_comment: break
|
||||||
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
distinguish_level=6,
|
distinguish_level=6,
|
||||||
body_html=body_html,
|
body_html=body_html,
|
||||||
level=1,
|
level=1,
|
||||||
sentto=0,
|
sentto=0,
|
||||||
)
|
)
|
||||||
db.add(new_comment)
|
db.add(new_comment)
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
admins = db.query(User).filter(User.admin_level > 0).all()
|
admins = db.query(User).filter(User.admin_level > 0).all()
|
||||||
for admin in admins:
|
for admin in admins:
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
|
||||||
db.add(notif)
|
|
||||||
|
|
||||||
for k,v in REDDIT_NOTIFS.items():
|
|
||||||
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q={k}&size=10').json()["data"]:
|
|
||||||
try: body_html = sanitize(f'New mention of you: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
|
|
||||||
except: continue
|
|
||||||
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html).first()
|
|
||||||
if existing_comment: break
|
|
||||||
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
|
||||||
parent_submission=None,
|
|
||||||
distinguish_level=6,
|
|
||||||
body_html=body_html
|
|
||||||
)
|
|
||||||
|
|
||||||
db.add(new_comment)
|
|
||||||
db.flush()
|
|
||||||
|
|
||||||
notif = Notification(comment_id=new_comment.id, user_id=v)
|
|
||||||
db.add(notif)
|
db.add(notif)
|
||||||
|
|
||||||
|
for i in requests.get(f'https://api.pushshift.io/reddit/{t}/search?html_decode=true&q=aevann&size=10').json()["data"]:
|
||||||
|
try: body_html = sanitize(f'New mention of you: https://old.reddit.com{i["permalink"]}?context=89', noimages=True)
|
||||||
|
except: continue
|
||||||
|
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html).first()
|
||||||
|
if existing_comment: break
|
||||||
|
new_comment = Comment(author_id=NOTIFICATIONS_ID,
|
||||||
|
parent_submission=None,
|
||||||
|
distinguish_level=6,
|
||||||
|
body_html=body_html
|
||||||
|
)
|
||||||
|
|
||||||
|
db.add(new_comment)
|
||||||
|
db.flush()
|
||||||
|
|
||||||
|
notif = Notification(comment_id=new_comment.id, user_id=v)
|
||||||
|
db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue