mirror of
https://github.com/Watchful1/PushshiftDumps.git
synced 2025-07-24 15:15:24 -04:00
Shorter and don't throw
This commit is contained in:
parent
2cc3e3f68e
commit
31e656673f
1 changed files with 2 additions and 2 deletions
|
@ -129,7 +129,7 @@ def query_reddit(ids, reddit, object_type):
|
||||||
id_prefix = 't1_' if object_type == ObjectType.COMMENT else 't3_'
|
id_prefix = 't1_' if object_type == ObjectType.COMMENT else 't3_'
|
||||||
id_string = f"{id_prefix}{(f',{id_prefix}'.join(ids))}"
|
id_string = f"{id_prefix}{(f',{id_prefix}'.join(ids))}"
|
||||||
response = None
|
response = None
|
||||||
for i in range(100):
|
for i in range(20):
|
||||||
try:
|
try:
|
||||||
response = reddit.request(method="GET", path=endpoints.API_PATH["info"], params={"id": id_string})
|
response = reddit.request(method="GET", path=endpoints.API_PATH["info"], params={"id": id_string})
|
||||||
break
|
break
|
||||||
|
@ -138,7 +138,7 @@ def query_reddit(ids, reddit, object_type):
|
||||||
time.sleep(i * 5)
|
time.sleep(i * 5)
|
||||||
if response is None:
|
if response is None:
|
||||||
log.warning(f"Reddit api failed, aborting")
|
log.warning(f"Reddit api failed, aborting")
|
||||||
raise IOError
|
return []
|
||||||
return response['data']['children']
|
return response['data']['children']
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue