Improve use of SQL selecting livestream video ids.
This commit is contained in:
parent
03b88ec5f8
commit
ecf96d531a
2 changed files with 7 additions and 6 deletions
|
@ -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):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue