self.duration = duration
self.definition = definition
- def set_duration_from_yt_string(self, yt_string) -> None:
+ def set_duration_from_yt_string(self, yt_string: str) -> None:
"""Set .duration from the kind of format the YouTube API provides."""
date_dur, time_dur = yt_string.split('T')
seconds = 0
ids_for_details = ','.join([r.id_ for r in results])
videos_request = youtube.videos().list(id=ids_for_details,
part='content_details')
+ unfinished_streams: list[YoutubeId] = []
for i, detailed in enumerate(videos_request.execute()['items']):
result = results[i]
assert result.id_ == detailed['id']
content_details: dict[str, str] = detailed['contentDetails']
+ if 'P0D' == content_details['duration']:
+ unfinished_streams += [result.id_]
+ continue
result.set_duration_from_yt_string(content_details['duration'])
result.definition = content_details['definition'].upper()
- return results
+ return [r for r in results if r.id_ not in unfinished_streams]
query_data = YoutubeQuery(
None, query_txt,