From 3553aaf427ca96825e98e974ee029283191aeacd Mon Sep 17 00:00:00 2001 From: blank X Date: Mon, 7 Jun 2021 06:02:13 +0700 Subject: [PATCH] Use random.randint for wait_time --- autoytarchive/workers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autoytarchive/workers.py b/autoytarchive/workers.py index 2f82937..66b7b1b 100644 --- a/autoytarchive/workers.py +++ b/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'):