Skip to content

Commit

Permalink
fix(core): use ??? if duration cannot be found in search results
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Nov 9, 2023
1 parent 1e1ca2e commit 561468b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/ydcore/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def _parse_video(self, source: dict[Any, Any]) -> Video:
video_id = source['videoId']
url = HttpUrl(f'{_YOUTUBE_BASE_URL}/watch?v={video_id}')
title = _get(source, ['title', 'runs', 0, 'text'])
duration = _get(source, ['lengthText', 'simpleText'])
duration = '???'
try:
duration = _get(source, ['lengthText', 'simpleText'])
except KeyError:
pass
if duration is None:
duration = '--:--'
thumbnails = _get(source, ['thumbnail', 'thumbnails'])
Expand Down

0 comments on commit 561468b

Please sign in to comment.