mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 18:41:29 +00:00
[francetv] Improve manifest URL signing (closes #15536)
This commit is contained in:
parent
818df33fda
commit
8faa338ff3
|
@ -5,7 +5,10 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_urlparse
|
from ..compat import (
|
||||||
|
compat_str,
|
||||||
|
compat_urlparse,
|
||||||
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
@ -27,7 +30,8 @@ def _extract_video(self, video_id, catalogue=None):
|
||||||
|
|
||||||
if info.get('status') == 'NOK':
|
if info.get('status') == 'NOK':
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'%s returned error: %s' % (self.IE_NAME, info['message']), expected=True)
|
'%s returned error: %s' % (self.IE_NAME, info['message']),
|
||||||
|
expected=True)
|
||||||
allowed_countries = info['videos'][0].get('geoblocage')
|
allowed_countries = info['videos'][0].get('geoblocage')
|
||||||
if allowed_countries:
|
if allowed_countries:
|
||||||
georestricted = True
|
georestricted = True
|
||||||
|
@ -42,6 +46,19 @@ def _extract_video(self, video_id, catalogue=None):
|
||||||
else:
|
else:
|
||||||
georestricted = False
|
georestricted = False
|
||||||
|
|
||||||
|
def sign(manifest_url, manifest_id):
|
||||||
|
for host in ('hdfauthftv-a.akamaihd.net', 'hdfauth.francetv.fr'):
|
||||||
|
signed_url = self._download_webpage(
|
||||||
|
'https://%s/esi/TA' % host, video_id,
|
||||||
|
'Downloading signed %s manifest URL' % manifest_id,
|
||||||
|
fatal=False, query={
|
||||||
|
'url': manifest_url,
|
||||||
|
})
|
||||||
|
if (signed_url and isinstance(signed_url, compat_str) and
|
||||||
|
re.search(r'^(?:https?:)?//', signed_url)):
|
||||||
|
return signed_url
|
||||||
|
return manifest_url
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for video in info['videos']:
|
for video in info['videos']:
|
||||||
if video['statut'] != 'ONLINE':
|
if video['statut'] != 'ONLINE':
|
||||||
|
@ -56,21 +73,14 @@ def _extract_video(self, video_id, catalogue=None):
|
||||||
# See https://github.com/rg3/youtube-dl/issues/3963
|
# See https://github.com/rg3/youtube-dl/issues/3963
|
||||||
# m3u8 urls work fine
|
# m3u8 urls work fine
|
||||||
continue
|
continue
|
||||||
f4m_url = self._download_webpage(
|
formats.extend(self._extract_f4m_formats(
|
||||||
'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url,
|
sign(video_url, format_id) + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
|
||||||
video_id, 'Downloading f4m manifest token', fatal=False)
|
video_id, f4m_id=format_id, fatal=False))
|
||||||
if f4m_url:
|
|
||||||
formats.extend(self._extract_f4m_formats(
|
|
||||||
f4m_url + '&hdcore=3.7.0&plugin=aasp-3.7.0.39.44',
|
|
||||||
video_id, f4m_id=format_id, fatal=False))
|
|
||||||
elif ext == 'm3u8':
|
elif ext == 'm3u8':
|
||||||
m3u8_url = self._download_webpage(
|
formats.extend(self._extract_m3u8_formats(
|
||||||
'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url,
|
sign(video_url, format_id), video_id, 'mp4',
|
||||||
video_id, 'Downloading m3u8 token', fatal=False)
|
entry_protocol='m3u8_native', m3u8_id=format_id,
|
||||||
if m3u8_url:
|
fatal=False))
|
||||||
formats.extend(self._extract_m3u8_formats(
|
|
||||||
m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
|
||||||
m3u8_id=format_id, fatal=False))
|
|
||||||
elif video_url.startswith('rtmp'):
|
elif video_url.startswith('rtmp'):
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
|
|
Loading…
Reference in a new issue