From ecf96d531a7504e40c12c19bef7bb2d241b09398 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 19 Dec 2021 19:07:13 -0800 Subject: [PATCH] Improve use of SQL selecting livestream video ids. --- ycdl/objects.py | 11 ++++++----- ycdl/ytapi.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ycdl/objects.py b/ycdl/objects.py index 8f49abc..7ce0164 100644 --- a/ycdl/objects.py +++ b/ycdl/objects.py @@ -221,16 +221,17 @@ class Channel(ObjectBase): # 2. 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 * FROM videos WHERE author_id == ? AND live_broadcast IS NOT NULL' - videos = self.ycdldb.get_videos_by_sql(query, [self.id]) - refresh_ids.update(v.id for v in videos) + query = 'SELECT id FROM videos WHERE author_id == ? AND live_broadcast IS NOT NULL' + bindings = [self.id] + premiere_ids = self.ycdldb.select_column(query, bindings) + refresh_ids.update(premiere_ids) if refresh_ids: log.debug('Refreshing %d ids separately.', len(refresh_ids)) # We call ingest_video instead of insert_video so that # premieres / livestreams which have finished can be automarked. - for video_id in self.ycdldb.youtube.get_videos(refresh_ids): - self.ycdldb.ingest_video(video_id) + for video in self.ycdldb.youtube.get_videos(refresh_ids): + self.ycdldb.ingest_video(video) def reset_uploads_playlist_id(self): ''' diff --git a/ycdl/ytapi.py b/ycdl/ytapi.py index b473142..29f082e 100644 --- a/ycdl/ytapi.py +++ b/ycdl/ytapi.py @@ -139,7 +139,7 @@ class Youtube: id=chunk, ).execute() snippets = data['items'] - self.log.debug('Got %d snippets.', len(snippets)) + self.log.debug('Got batch of %d snippets.', len(snippets)) total_snippets += len(snippets) self.log.loud(snippets) for snippet in snippets: