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