Skip to content

Commit

Permalink
[ie/francetv] Detect and raise errors for DRM (#10165)
Browse files Browse the repository at this point in the history
Closes #10163
Authored by: bashonly
  • Loading branch information
bashonly authored Jun 13, 2024
1 parent 081708d commit 3690c2f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions yt_dlp/extractor/francetv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .dailymotion import DailymotionIE
from ..networking import HEADRequest
from ..utils import (
clean_html,
determine_ext,
filter_dict,
format_field,
Expand Down Expand Up @@ -82,6 +83,7 @@ class FranceTVIE(InfoExtractor):
def _extract_video(self, video_id, hostname=None):
is_live = None
videos = []
drm_formats = False
title = None
subtitle = None
episode_number = None
Expand All @@ -99,23 +101,32 @@ def _extract_video(self, video_id, hostname=None):
'device_type': device_type,
'browser': browser,
'domain': hostname,
}), fatal=False)
}), fatal=False, expected_status=422) # 422 json gives detailed error code/message

if not dinfo:
continue

video = traverse_obj(dinfo, ('video', {dict}))
if video:
if video := traverse_obj(dinfo, ('video', {dict})):
videos.append(video)
if duration is None:
duration = video.get('duration')
if is_live is None:
is_live = video.get('is_live')
if spritesheets is None:
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:
if meta := traverse_obj(dinfo, ('meta', {dict})):
if title is None:
title = meta.get('title')
# meta['pre_title'] contains season and episode number for series in format "S<ID> E<ID>"
Expand All @@ -128,6 +139,9 @@ def _extract_video(self, video_id, hostname=None):
if timestamp is None:
timestamp = parse_iso8601(meta.get('broadcasted_at'))

if not videos and drm_formats:
self.report_drm(video_id)

formats, subtitles, video_url = [], {}, None
for video in traverse_obj(videos, lambda _, v: url_or_none(v['url'])):
video_url = video['url']
Expand Down

0 comments on commit 3690c2f

Please sign in to comment.