Improve use of SQL selecting livestream video ids.

master
voussoir 2021-12-19 19:07:13 -08:00
parent 03b88ec5f8
commit ecf96d531a
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
2 changed files with 7 additions and 6 deletions

View File

@ -221,16 +221,17 @@ class Channel(ObjectBase):
# 2. Premieres or live events which may now be over but were not # 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 # included in the requested batch of IDs because they are not the most
# recent. # recent.
query = 'SELECT * FROM videos WHERE author_id == ? AND live_broadcast IS NOT NULL' query = 'SELECT id FROM videos WHERE author_id == ? AND live_broadcast IS NOT NULL'
videos = self.ycdldb.get_videos_by_sql(query, [self.id]) bindings = [self.id]
refresh_ids.update(v.id for v in videos) premiere_ids = self.ycdldb.select_column(query, bindings)
refresh_ids.update(premiere_ids)
if refresh_ids: if refresh_ids:
log.debug('Refreshing %d ids separately.', len(refresh_ids)) log.debug('Refreshing %d ids separately.', len(refresh_ids))
# We call ingest_video instead of insert_video so that # We call ingest_video instead of insert_video so that
# premieres / livestreams which have finished can be automarked. # premieres / livestreams which have finished can be automarked.
for video_id in self.ycdldb.youtube.get_videos(refresh_ids): for video in self.ycdldb.youtube.get_videos(refresh_ids):
self.ycdldb.ingest_video(video_id) self.ycdldb.ingest_video(video)
def reset_uploads_playlist_id(self): def reset_uploads_playlist_id(self):
''' '''

View File

@ -139,7 +139,7 @@ class Youtube:
id=chunk, id=chunk,
).execute() ).execute()
snippets = data['items'] 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) total_snippets += len(snippets)
self.log.loud(snippets) self.log.loud(snippets)
for snippet in snippets: for snippet in snippets: