mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-04 02:12:54 +08:00
[seznamzpravy] use try_get
This commit is contained in:
parent
3c211cff37
commit
16ca00501a
@ -2,9 +2,11 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_str
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
urljoin,
|
urljoin,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +41,8 @@ class SeznamZpravyIE(InfoExtractor):
|
|||||||
def _extract_sdn_formats(self, sdn_url, video_id):
|
def _extract_sdn_formats(self, sdn_url, video_id):
|
||||||
sdn_data = self._download_json(sdn_url, video_id)
|
sdn_data = self._download_json(sdn_url, video_id)
|
||||||
formats = []
|
formats = []
|
||||||
for fmt, fmtdata in sdn_data.get('data', {}).get('mp4', {}).items():
|
mp4_formats = try_get(sdn_data, lambda x: x['data']['mp4'], dict) or {}
|
||||||
|
for fmt, fmtdata in mp4_formats.items():
|
||||||
relative_url = fmtdata.get('url')
|
relative_url = fmtdata.get('url')
|
||||||
if not relative_url:
|
if not relative_url:
|
||||||
continue
|
continue
|
||||||
@ -57,11 +60,11 @@ class SeznamZpravyIE(InfoExtractor):
|
|||||||
})
|
})
|
||||||
|
|
||||||
playlists = sdn_data.get('pls', {})
|
playlists = sdn_data.get('pls', {})
|
||||||
dash_rel_url = playlists.get('dash', {}).get('url')
|
dash_rel_url = try_get(playlists, lambda x: x['dash']['url'], compat_str)
|
||||||
if dash_rel_url:
|
if dash_rel_url:
|
||||||
formats.extend(self._extract_mpd_formats(urljoin(sdn_url, dash_rel_url), video_id, mpd_id='dash', fatal=False))
|
formats.extend(self._extract_mpd_formats(urljoin(sdn_url, dash_rel_url), video_id, mpd_id='dash', fatal=False))
|
||||||
|
|
||||||
hls_rel_url = playlists.get('hls', {}).get('url')
|
hls_rel_url = try_get(playlists, lambda x: x['hls']['url'], compat_str)
|
||||||
if hls_rel_url:
|
if hls_rel_url:
|
||||||
formats.extend(self._extract_m3u8_formats(urljoin(sdn_url, hls_rel_url), video_id, ext='mp4', m3u8_id='hls', fatal=False))
|
formats.extend(self._extract_m3u8_formats(urljoin(sdn_url, hls_rel_url), video_id, ext='mp4', m3u8_id='hls', fatal=False))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user