Fix 'secondSubtitle' KeyError for some playlists (#399)
* Fix 'secondSubtitle' KeyError for some playlists * Feedback.
This commit is contained in:
parent
7c9455e42c
commit
e26335e664
1 changed files with 10 additions and 8 deletions
|
|
@ -132,14 +132,16 @@ class PlaylistsMixin:
|
||||||
if run_count == 5:
|
if run_count == 5:
|
||||||
playlist['year'] = nav(header, SUBTITLE3)
|
playlist['year'] = nav(header, SUBTITLE3)
|
||||||
|
|
||||||
second_subtitle_runs = header['secondSubtitle']['runs']
|
playlist['views'] = None
|
||||||
|
playlist['duration'] = None
|
||||||
has_views = (len(second_subtitle_runs) > 3) * 2
|
if 'runs' in header['secondSubtitle']:
|
||||||
playlist['views'] = None if not has_views else to_int(second_subtitle_runs[0]['text'])
|
second_subtitle_runs = header['secondSubtitle']['runs']
|
||||||
has_duration = (len(second_subtitle_runs) > 1) * 2
|
has_views = (len(second_subtitle_runs) > 3) * 2
|
||||||
playlist['duration'] = None if not has_duration else second_subtitle_runs[has_views + has_duration]['text']
|
playlist['views'] = None if not has_views else to_int(second_subtitle_runs[0]['text'])
|
||||||
song_count = second_subtitle_runs[has_views + 0]['text'].split(" ")
|
has_duration = (len(second_subtitle_runs) > 1) * 2
|
||||||
song_count = to_int(song_count[0]) if len(song_count) > 1 else 0
|
playlist['duration'] = None if not has_duration else second_subtitle_runs[has_views + has_duration]['text']
|
||||||
|
|
||||||
|
song_count = len(results['contents'])
|
||||||
playlist['trackCount'] = song_count
|
playlist['trackCount'] = song_count
|
||||||
|
|
||||||
request_func = lambda additionalParams: self._send_request(endpoint, body, additionalParams)
|
request_func = lambda additionalParams: self._send_request(endpoint, body, additionalParams)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue