Shuffle invidious instances

This commit is contained in:
blank X 2021-04-17 22:16:26 +07:00
parent a6e3f7dda3
commit de500788ca
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import time import time
import json import json
import random
import logging import logging
import feedparser import feedparser
from io import BytesIO from io import BytesIO
@ -31,7 +32,9 @@ async def update_seen_videos():
await client.edit_message(config['config']['storage_chat_id'], config['config']['storage_message_id'], file=file) await client.edit_message(config['config']['storage_chat_id'], config['config']['storage_message_id'], file=file)
async def get_video_list(session, channel_id): async def get_video_list(session, channel_id):
for i in config['config'].get('invidious_instances', []): invidious_instances = config['config'].get('invidious_instances', [])
random.shuffle(invidious_instances)
for i in invidious_instances:
try: try:
async with session.get(f'{i}/api/v1/channels/{channel_id}/latest?fields=videoId&a={time.time()}', headers={'Cache-Control': 'no-store, max-age=0'}) as resp: async with session.get(f'{i}/api/v1/channels/{channel_id}/latest?fields=videoId&a={time.time()}', headers={'Cache-Control': 'no-store, max-age=0'}) as resp:
if resp.status != 200: if resp.status != 200: