Browse Source

Use random.randint for wait_time

master
blank X 1 year ago
parent
commit
3553aaf427
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
  1. 8
      autoytarchive/workers.py

8
autoytarchive/workers.py

@ -77,7 +77,7 @@ async def _check_video(video_id):
try:
video_json = await client.loop.run_in_executor(None, ytdl.extract_info, f'https://youtube.com/watch?v={video_id}')
except BaseException as e:
wait_time = 30
wait_time = random.randint(30, 10 * 30)
message = str(e)
if '429' in message or 'too many' in message.lower():
wait_time = too_many_requests_count * 60 * 60
@ -123,7 +123,7 @@ async def _video_worker():
tempdir = tempdir_obj.name
if late_to_queue:
for i in range(5):
wait_time = 30
wait_time = random.randint(30, 10 * 60)
try:
tmp = await client.loop.run_in_executor(None, ytdl.extract_info, video_json['id'])
except BaseException as e:
@ -148,7 +148,7 @@ async def _video_worker():
command.extend(('-i', video_json['url']))
if is_manifest:
await asyncio.sleep(video_json['duration'] + 30)
wait_time = 30
wait_time = random.randint(30, 10 * 30)
for i in range(5):
try:
tmp = await client.loop.run_in_executor(None, ytdl.extract_info, video_json['id'])
@ -207,7 +207,7 @@ async def _video_worker():
pass
if not proc.returncode:
break
wait_time = 30
wait_time = random.randint(30, 10 * 60)
if video_json.get('duration'):
is_manifest = False
if video_json.get('url'):

Loading…
Cancel
Save