mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-23 20:50:10 +09:00
[youtube] Move decrypt_sig out of _parse_dash_manifest
This commit is contained in:
parent
c140629995
commit
05d0d131a7
@ -1035,22 +1035,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
url = 'https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=%s' % video_id
|
url = 'https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=%s' % video_id
|
||||||
return self._download_webpage(url, video_id, note='Searching for annotations.', errnote='Unable to download video annotations.')
|
return self._download_webpage(url, video_id, note='Searching for annotations.', errnote='Unable to download video annotations.')
|
||||||
|
|
||||||
def _parse_dash_manifest(
|
def _parse_dash_manifest(self, video_id, dash_doc, fatal=True):
|
||||||
self, video_id, dash_manifest_url, player_url, age_gate, fatal=True):
|
|
||||||
def decrypt_sig(mobj):
|
|
||||||
s = mobj.group(1)
|
|
||||||
dec_s = self._decrypt_signature(s, video_id, player_url, age_gate)
|
|
||||||
return '/signature/%s' % dec_s
|
|
||||||
dash_manifest_url = re.sub(r'/s/([a-fA-F0-9\.]+)', decrypt_sig, dash_manifest_url)
|
|
||||||
dash_doc = self._download_xml(
|
|
||||||
dash_manifest_url, video_id,
|
|
||||||
note='Downloading DASH manifest',
|
|
||||||
errnote='Could not download DASH manifest',
|
|
||||||
fatal=fatal)
|
|
||||||
|
|
||||||
if dash_doc is False:
|
|
||||||
return []
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for a in dash_doc.findall('.//{urn:mpeg:DASH:schema:MPD:2011}AdaptationSet'):
|
for a in dash_doc.findall('.//{urn:mpeg:DASH:schema:MPD:2011}AdaptationSet'):
|
||||||
mime_type = a.attrib.get('mimeType')
|
mime_type = a.attrib.get('mimeType')
|
||||||
@ -1533,8 +1518,19 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
for dash_manifest_url in dash_mpds:
|
for dash_manifest_url in dash_mpds:
|
||||||
dash_formats = {}
|
dash_formats = {}
|
||||||
try:
|
try:
|
||||||
for df in self._parse_dash_manifest(
|
def decrypt_sig(mobj):
|
||||||
video_id, dash_manifest_url, player_url, age_gate, dash_mpd_fatal):
|
s = mobj.group(1)
|
||||||
|
dec_s = self._decrypt_signature(s, video_id, player_url, age_gate)
|
||||||
|
return '/signature/%s' % dec_s
|
||||||
|
|
||||||
|
dash_manifest_url = re.sub(r'/s/([a-fA-F0-9\.]+)', decrypt_sig, dash_manifest_url)
|
||||||
|
dash_doc = self._download_xml(
|
||||||
|
dash_manifest_url, video_id,
|
||||||
|
note='Downloading DASH manifest',
|
||||||
|
errnote='Could not download DASH manifest',
|
||||||
|
fatal=dash_mpd_fatal)
|
||||||
|
|
||||||
|
for df in self._parse_dash_manifest(video_id, dash_doc, dash_mpd_fatal):
|
||||||
# Do not overwrite DASH format found in some previous DASH manifest
|
# Do not overwrite DASH format found in some previous DASH manifest
|
||||||
if df['format_id'] not in dash_formats:
|
if df['format_id'] not in dash_formats:
|
||||||
dash_formats[df['format_id']] = df
|
dash_formats[df['format_id']] = df
|
||||||
|
Loading…
Reference in New Issue
Block a user