mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-02 14:37:21 +00:00
[extractor/echo360] use traverse_obj with lambda and parse_duration
This commit is contained in:
parent
333eb58c77
commit
333e92b1e5
|
@ -1,7 +1,13 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import determine_ext, float_or_none, traverse_obj, update_url
|
from ..utils import (
|
||||||
|
determine_ext,
|
||||||
|
float_or_none,
|
||||||
|
parse_duration,
|
||||||
|
traverse_obj,
|
||||||
|
update_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Echo360IE(InfoExtractor):
|
class Echo360IE(InfoExtractor):
|
||||||
|
@ -50,19 +56,14 @@ def _get_query_string(self, uri, query_strings):
|
||||||
|
|
||||||
def _parse_mediapackage(self, video):
|
def _parse_mediapackage(self, video):
|
||||||
video_id = video['playableAudioVideo']['mediaId']
|
video_id = video['playableAudioVideo']['mediaId']
|
||||||
query_strings = traverse_obj(video, ('sourceQueryStrings', 'queryStrings')) or []
|
query_strings = traverse_obj(video, ('sourceQueryStrings', 'queryStrings', ...))
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for track in traverse_obj(video, ('playableAudioVideo', 'playableMedias', ...)):
|
for track in traverse_obj(video, ('playableAudioVideo', 'playableMedias', lambda _, v: v['uri'])):
|
||||||
href = track.get('uri')
|
href = update_url(track['uri'], query=self._get_query_string(track['uri'], query_strings))
|
||||||
if href is None:
|
if track.get('isHls') or determine_ext(href) == 'm3u8':
|
||||||
continue
|
|
||||||
href = update_url(href, query=self._get_query_string(href, query_strings))
|
|
||||||
if track.get('isHls') or determine_ext(href, None) == 'm3u8':
|
|
||||||
hls_formats = self._extract_m3u8_formats(
|
hls_formats = self._extract_m3u8_formats(
|
||||||
href, video_id, live=track.get('isLive'), m3u8_id='hls',
|
href, video_id, live=track.get('isLive'), m3u8_id='hls', fatal=False)
|
||||||
entry_protocol='m3u8_native', fatal=False
|
|
||||||
)
|
|
||||||
|
|
||||||
for hls_format in hls_formats:
|
for hls_format in hls_formats:
|
||||||
query_string = self._get_query_string(hls_format['url'], query_strings)
|
query_string = self._get_query_string(hls_format['url'], query_strings)
|
||||||
|
@ -75,9 +76,7 @@ def _parse_mediapackage(self, video):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'title': video.get('mediaName'),
|
'title': video.get('mediaName'),
|
||||||
'duration': float_or_none(self._search_regex(
|
'duration': traverse_obj(video, ('playableAudioVideo', 'duration', {parse_duration})),
|
||||||
r'PT([\d.]+)S', traverse_obj(video, ('playableAudioVideo', 'duration')),
|
|
||||||
'video duration', fatal=False)),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
|
Loading…
Reference in a new issue