Cap video list to 15

This commit is contained in:
blank X 2021-05-29 17:12:07 +07:00
parent de500788ca
commit b34f14a431
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 2 additions and 2 deletions

View File

@ -40,9 +40,9 @@ async def get_video_list(session, channel_id):
if resp.status != 200: if resp.status != 200:
logging.error('Invidious instance %s returned %s', i, str(resp.status)) logging.error('Invidious instance %s returned %s', i, str(resp.status))
continue continue
return list(map(lambda i: i['videoId'], await resp.json())) return list(map(lambda i: i['videoId'], await resp.json()))[:15]
except BaseException: except BaseException:
logging.exception('Invidious instance %s raised exception', i) logging.exception('Invidious instance %s raised exception', i)
async with session.get(f'https://www.youtube.com/feeds/videos.xml?channel_id={channel_id}&a={time.time()}', headers={'Cache-Control': 'no-store, max-age=0'}) as resp: async with session.get(f'https://www.youtube.com/feeds/videos.xml?channel_id={channel_id}&a={time.time()}', headers={'Cache-Control': 'no-store, max-age=0'}) as resp:
d = feedparser.parse(await resp.text()) d = feedparser.parse(await resp.text())
return list(map(lambda i: i['yt_videoid'], d['entries'])) return list(map(lambda i: i['yt_videoid'], d['entries']))[:15]