From 5bf6fe0cd7ab45e703ff1f679326ddedf67f8f5c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 26 Jan 2022 21:20:08 -0800 Subject: [PATCH] Fix handling of premiered videos in ycdldb.refresh_all. --- ycdl/ycdldb.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ycdl/ycdldb.py b/ycdl/ycdldb.py index 170f6a6..07498fa 100644 --- a/ycdl/ycdldb.py +++ b/ycdl/ycdldb.py @@ -3,6 +3,7 @@ import sqlite3 from voussoirkit import cacheclass from voussoirkit import configlayers +from voussoirkit import lazychain from voussoirkit import pathclass from voussoirkit import vlogging from voussoirkit import worms @@ -136,8 +137,20 @@ class YCDLDBChannelMixin: ) traditional(channel) - new_ids = (id for channel in channels for id in assisted(channel)) - for video in self.youtube.get_videos(new_ids): + video_ids = lazychain.LazyChain() + + for channel in channels: + video_ids.extend(assisted(channel)) + + # Premieres or live events which may now be over but were not + # included in the requested batch of IDs because they are not the + # most recent. + query = 'SELECT id FROM videos WHERE live_broadcast IS NOT NULL' + premiere_ids = set(self.select_column(query)) + log.debug('Refreshing %d ids separately.', len(premiere_ids)) + video_ids.extend(premiere_ids) + + for video in self.youtube.get_videos(video_ids): self.ingest_video(video) return excs