forked from MarseyWorld/MarseyWorld
make offsite_mentions_task take 3 seconds instead of 14 seconds
parent
b029ae2c38
commit
112841cf9e
|
@ -32,13 +32,11 @@ def offsite_mentions_task(cache):
|
|||
def get_mentions(cache, queries, reddit_notifs_users=False):
|
||||
mentions = []
|
||||
for kind in ('submission', 'comment'):
|
||||
data = []
|
||||
|
||||
for query in queries:
|
||||
url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}'
|
||||
try: req = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies)
|
||||
except: return []
|
||||
data += req.json()['data']
|
||||
q = " or ".join(queries)
|
||||
url = f'https://api.pullpush.io/reddit/search/{kind}?q={q}'
|
||||
try: req = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies)
|
||||
except: return []
|
||||
data = req.json()['data']
|
||||
|
||||
for thing in data:
|
||||
if not thing.get('permalink'):
|
||||
|
|
Loading…
Reference in New Issue