mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 18:41:29 +00:00
[tv2] Fix and improve extraction (closes #22787)
This commit is contained in:
parent
c56b2ac43c
commit
9a621ddc3a
|
@ -11,6 +11,7 @@
|
||||||
js_to_json,
|
js_to_json,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
remove_end,
|
remove_end,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +45,14 @@ def _real_extract(self, url):
|
||||||
data = self._download_json(
|
data = self._download_json(
|
||||||
'http://sumo.tv2.no/api/web/asset/%s/play.json?protocol=%s&videoFormat=SMIL+ISMUSP' % (video_id, protocol),
|
'http://sumo.tv2.no/api/web/asset/%s/play.json?protocol=%s&videoFormat=SMIL+ISMUSP' % (video_id, protocol),
|
||||||
video_id, 'Downloading play JSON')['playback']
|
video_id, 'Downloading play JSON')['playback']
|
||||||
for item in data['items']['item']:
|
items = try_get(data, lambda x: x['items']['item'])
|
||||||
|
if not items:
|
||||||
|
continue
|
||||||
|
if not isinstance(items, list):
|
||||||
|
items = [items]
|
||||||
|
for item in items:
|
||||||
|
if not isinstance(item, dict):
|
||||||
|
continue
|
||||||
video_url = item.get('url')
|
video_url = item.get('url')
|
||||||
if not video_url or video_url in format_urls:
|
if not video_url or video_url in format_urls:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue