diff options
author | Sergey M․ <dstftw@gmail.com> | 2019-10-30 02:21:52 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2019-10-30 02:21:52 +0700 |
commit | 9a621ddc3a42769f107f8bd0d67b2c7073ea8256 (patch) | |
tree | 7294ade798bd8fdd819e60fc8488648d0897aa72 /youtube_dl/extractor | |
parent | c56b2ac43ca27b32fb4f7b230d851a61b5fc7cbd (diff) |
[tv2] Fix and improve extraction (closes #22787)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/tv2.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/youtube_dl/extractor/tv2.py b/youtube_dl/extractor/tv2.py index d5071e8a5..1b6590767 100644 --- a/youtube_dl/extractor/tv2.py +++ b/youtube_dl/extractor/tv2.py @@ -11,6 +11,7 @@ from ..utils import ( js_to_json, parse_iso8601, remove_end, + try_get, ) @@ -44,7 +45,14 @@ class TV2IE(InfoExtractor): data = self._download_json( 'http://sumo.tv2.no/api/web/asset/%s/play.json?protocol=%s&videoFormat=SMIL+ISMUSP' % (video_id, protocol), 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') if not video_url or video_url in format_urls: continue |