]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tv5mondeplus.py
1 from .common
import InfoExtractor
11 class TV5MondePlusIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)'
16 'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/ceux-qui-travaillent',
17 'md5': '32fa0cde16a4480d1251502a66856d5f',
19 'id': 'dc57a011-ec4b-4648-2a9a-4f03f8352ed3',
20 'display_id': 'ceux-qui-travaillent',
22 'title': 'Ceux qui travaillent',
23 'description': 'md5:570e8bb688036ace873b2d50d24c026d',
24 'upload_date': '20210819',
28 'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/vestiaires-caro-actrice',
30 'id': '9e9d599e-23af-6915-843e-ecbf62e97925',
31 'display_id': 'vestiaires-caro-actrice',
33 'title': "Vestiaires - Caro actrice",
34 'description': 'md5:db15d2e1976641e08377f942778058ea',
35 'upload_date': '20210819',
36 'series': "Vestiaires",
37 'episode': 'Caro actrice',
40 'skip_download': True,
43 'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/neuf-jours-en-hiver-neuf-jours-en-hiver',
44 'only_matching': True,
46 'url': 'https://revoir.tv5monde.com/toutes-les-videos/info-societe/le-journal-de-la-rts-edition-du-30-01-20-19h30',
47 'only_matching': True,
51 def _real_extract(self
, url
):
52 display_id
= self
._match
_id
(url
)
53 webpage
= self
._download
_webpage
(url
, display_id
)
55 if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage
:
56 self
.raise_geo_restricted(countries
=['FR'])
58 title
= episode
= self
._html
_search
_regex
(r
'<h1>([^<]+)', webpage
, 'title')
59 vpl_data
= extract_attributes(self
._search
_regex
(
60 r
'(<[^>]+class="video_player_loader"[^>]+>)',
61 webpage
, 'video player loader'))
63 video_files
= self
._parse
_json
(
64 vpl_data
['data-broadcast'], display_id
)
66 for video_file
in video_files
:
67 v_url
= video_file
.get('url')
70 video_format
= video_file
.get('format') or determine_ext(v_url
)
71 if video_format
== 'm3u8':
72 formats
.extend(self
._extract
_m
3u8_formats
(
73 v_url
, display_id
, 'mp4', 'm3u8_native',
74 m3u8_id
='hls', fatal
=False))
78 'format_id': video_format
,
81 metadata
= self
._parse
_json
(
82 vpl_data
['data-metadata'], display_id
)
83 duration
= (int_or_none(try_get(metadata
, lambda x
: x
['content']['duration']))
84 or parse_duration(self
._html
_search
_meta
('duration', webpage
)))
86 description
= self
._html
_search
_regex
(
87 r
'(?s)<div[^>]+class=["\']episode
-texte
[^
>]+>(.+?
)</div
>', webpage,
88 'description
', fatal=False)
90 series = self._html_search_regex(
91 r'<p
[^
>]+class=["\']episode-emission[^>]+>([^<]+)', webpage,
92 'series', default=None)
94 if series and series != title:
95 title = '%s - %s' % (series, title)
97 upload_date = self._search_regex(
98 r'(?:date_publication|publish_date)["\']\s
*:\s
*["\'](\d{4}_\d{2}_\d{2})',
99 webpage, 'upload date', default=None)
101 upload_date = upload_date.replace('_', '')
103 video_id = self._search_regex(
104 (r'data-guid=["\']([\da
-f
]{8}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{4}
-[\da
-f
]{12}
)',
105 r'id_contenu
["\']\s:\s*(\d+)'), webpage, 'video id',
110 'display_id': display_id,
112 'description': description,
113 'thumbnail': vpl_data.get('data-image'),
114 'duration': duration,
115 'upload_date': upload_date,