mirror of https://github.com/yt-dlp/yt-dlp.git
[ie/francetv] Detect and raise errors for DRM (#10165)
Closes #10163 Authored by: bashonly
This commit is contained in:
parent
081708d607
commit
3690c2f598
|
@ -5,6 +5,7 @@ from .common import InfoExtractor
|
||||||
from .dailymotion import DailymotionIE
|
from .dailymotion import DailymotionIE
|
||||||
from ..networking import HEADRequest
|
from ..networking import HEADRequest
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
clean_html,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
filter_dict,
|
filter_dict,
|
||||||
format_field,
|
format_field,
|
||||||
|
@ -82,6 +83,7 @@ class FranceTVIE(InfoExtractor):
|
||||||
def _extract_video(self, video_id, hostname=None):
|
def _extract_video(self, video_id, hostname=None):
|
||||||
is_live = None
|
is_live = None
|
||||||
videos = []
|
videos = []
|
||||||
|
drm_formats = False
|
||||||
title = None
|
title = None
|
||||||
subtitle = None
|
subtitle = None
|
||||||
episode_number = None
|
episode_number = None
|
||||||
|
@ -99,13 +101,12 @@ class FranceTVIE(InfoExtractor):
|
||||||
'device_type': device_type,
|
'device_type': device_type,
|
||||||
'browser': browser,
|
'browser': browser,
|
||||||
'domain': hostname,
|
'domain': hostname,
|
||||||
}), fatal=False)
|
}), fatal=False, expected_status=422) # 422 json gives detailed error code/message
|
||||||
|
|
||||||
if not dinfo:
|
if not dinfo:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
video = traverse_obj(dinfo, ('video', {dict}))
|
if video := traverse_obj(dinfo, ('video', {dict})):
|
||||||
if video:
|
|
||||||
videos.append(video)
|
videos.append(video)
|
||||||
if duration is None:
|
if duration is None:
|
||||||
duration = video.get('duration')
|
duration = video.get('duration')
|
||||||
|
@ -113,9 +114,19 @@ class FranceTVIE(InfoExtractor):
|
||||||
is_live = video.get('is_live')
|
is_live = video.get('is_live')
|
||||||
if spritesheets is None:
|
if spritesheets is None:
|
||||||
spritesheets = video.get('spritesheets')
|
spritesheets = video.get('spritesheets')
|
||||||
|
elif code := traverse_obj(dinfo, ('code', {int})):
|
||||||
|
if code == 2009:
|
||||||
|
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
|
||||||
|
elif code in (2015, 2017):
|
||||||
|
# 2015: L'accès à cette vidéo est impossible. (DRM-only)
|
||||||
|
# 2017: Cette vidéo n'est pas disponible depuis le site web mobile (b/c DRM)
|
||||||
|
drm_formats = True
|
||||||
|
continue
|
||||||
|
self.report_warning(
|
||||||
|
f'{self.IE_NAME} said: {code} "{clean_html(dinfo.get("message"))}"')
|
||||||
|
continue
|
||||||
|
|
||||||
meta = traverse_obj(dinfo, ('meta', {dict}))
|
if meta := traverse_obj(dinfo, ('meta', {dict})):
|
||||||
if meta:
|
|
||||||
if title is None:
|
if title is None:
|
||||||
title = meta.get('title')
|
title = meta.get('title')
|
||||||
# meta['pre_title'] contains season and episode number for series in format "S<ID> E<ID>"
|
# meta['pre_title'] contains season and episode number for series in format "S<ID> E<ID>"
|
||||||
|
@ -128,6 +139,9 @@ class FranceTVIE(InfoExtractor):
|
||||||
if timestamp is None:
|
if timestamp is None:
|
||||||
timestamp = parse_iso8601(meta.get('broadcasted_at'))
|
timestamp = parse_iso8601(meta.get('broadcasted_at'))
|
||||||
|
|
||||||
|
if not videos and drm_formats:
|
||||||
|
self.report_drm(video_id)
|
||||||
|
|
||||||
formats, subtitles, video_url = [], {}, None
|
formats, subtitles, video_url = [], {}, None
|
||||||
for video in traverse_obj(videos, lambda _, v: url_or_none(v['url'])):
|
for video in traverse_obj(videos, lambda _, v: url_or_none(v['url'])):
|
||||||
video_url = video['url']
|
video_url = video['url']
|
||||||
|
|
Loading…
Reference in New Issue