]>
Commit | Line | Data |
---|---|---|
61e2331a RA |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | determine_ext, | |
4 | extract_attributes, | |
61e2331a RA |
5 | int_or_none, |
6 | parse_duration, | |
f79ec47d | 7 | try_get, |
61e2331a RA |
8 | ) |
9 | ||
10 | ||
11 | class TV5MondePlusIE(InfoExtractor): | |
12 | IE_DESC = 'TV5MONDE+' | |
d95a1cc9 S |
13 | _VALID_URL = r'https?://(?:www\.)?(?:tv5mondeplus|revoir\.tv5monde)\.com/toutes-les-videos/[^/]+/(?P<id>[^/?#]+)' |
14 | _TESTS = [{ | |
15 | # movie | |
f79ec47d JD |
16 | 'url': 'https://revoir.tv5monde.com/toutes-les-videos/cinema/ceux-qui-travaillent', |
17 | 'md5': '32fa0cde16a4480d1251502a66856d5f', | |
61e2331a | 18 | 'info_dict': { |
f79ec47d JD |
19 | 'id': 'dc57a011-ec4b-4648-2a9a-4f03f8352ed3', |
20 | 'display_id': 'ceux-qui-travaillent', | |
61e2331a | 21 | 'ext': 'mp4', |
f79ec47d JD |
22 | 'title': 'Ceux qui travaillent', |
23 | 'description': 'md5:570e8bb688036ace873b2d50d24c026d', | |
24 | 'upload_date': '20210819', | |
d95a1cc9 S |
25 | }, |
26 | }, { | |
27 | # series episode | |
f79ec47d | 28 | 'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/vestiaires-caro-actrice', |
d95a1cc9 | 29 | 'info_dict': { |
f79ec47d JD |
30 | 'id': '9e9d599e-23af-6915-843e-ecbf62e97925', |
31 | 'display_id': 'vestiaires-caro-actrice', | |
d95a1cc9 | 32 | 'ext': 'mp4', |
f79ec47d JD |
33 | 'title': "Vestiaires - Caro actrice", |
34 | 'description': 'md5:db15d2e1976641e08377f942778058ea', | |
35 | 'upload_date': '20210819', | |
36 | 'series': "Vestiaires", | |
37 | 'episode': 'Caro actrice', | |
d95a1cc9 S |
38 | }, |
39 | 'params': { | |
40 | 'skip_download': True, | |
41 | }, | |
42 | }, { | |
43 | 'url': 'https://revoir.tv5monde.com/toutes-les-videos/series-fictions/neuf-jours-en-hiver-neuf-jours-en-hiver', | |
44 | 'only_matching': True, | |
45 | }, { | |
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, | |
48 | }] | |
61e2331a RA |
49 | _GEO_BYPASS = False |
50 | ||
51 | def _real_extract(self, url): | |
52 | display_id = self._match_id(url) | |
53 | webpage = self._download_webpage(url, display_id) | |
54 | ||
55 | if ">Ce programme n'est malheureusement pas disponible pour votre zone géographique.<" in webpage: | |
56 | self.raise_geo_restricted(countries=['FR']) | |
57 | ||
d95a1cc9 | 58 | title = episode = self._html_search_regex(r'<h1>([^<]+)', webpage, 'title') |
61e2331a RA |
59 | vpl_data = extract_attributes(self._search_regex( |
60 | r'(<[^>]+class="video_player_loader"[^>]+>)', | |
61 | webpage, 'video player loader')) | |
62 | ||
63 | video_files = self._parse_json( | |
f79ec47d | 64 | vpl_data['data-broadcast'], display_id) |
61e2331a RA |
65 | formats = [] |
66 | for video_file in video_files: | |
67 | v_url = video_file.get('url') | |
68 | if not v_url: | |
69 | continue | |
70 | video_format = video_file.get('format') or determine_ext(v_url) | |
71 | if video_format == 'm3u8': | |
72 | formats.extend(self._extract_m3u8_formats( | |
73 | v_url, display_id, 'mp4', 'm3u8_native', | |
74 | m3u8_id='hls', fatal=False)) | |
75 | else: | |
76 | formats.append({ | |
77 | 'url': v_url, | |
78 | 'format_id': video_format, | |
79 | }) | |
61e2331a | 80 | |
f79ec47d JD |
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))) | |
85 | ||
d95a1cc9 S |
86 | description = self._html_search_regex( |
87 | r'(?s)<div[^>]+class=["\']episode-texte[^>]+>(.+?)</div>', webpage, | |
88 | 'description', fatal=False) | |
89 | ||
90 | series = self._html_search_regex( | |
91 | r'<p[^>]+class=["\']episode-emission[^>]+>([^<]+)', webpage, | |
92 | 'series', default=None) | |
93 | ||
94 | if series and series != title: | |
95 | title = '%s - %s' % (series, title) | |
96 | ||
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) | |
100 | if upload_date: | |
101 | upload_date = upload_date.replace('_', '') | |
102 | ||
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', | |
106 | default=display_id) | |
107 | ||
61e2331a | 108 | return { |
d95a1cc9 | 109 | 'id': video_id, |
61e2331a RA |
110 | 'display_id': display_id, |
111 | 'title': title, | |
d95a1cc9 | 112 | 'description': description, |
61e2331a | 113 | 'thumbnail': vpl_data.get('data-image'), |
f79ec47d | 114 | 'duration': duration, |
d95a1cc9 | 115 | 'upload_date': upload_date, |
61e2331a | 116 | 'formats': formats, |
61e2331a | 117 | 'series': series, |
d95a1cc9 | 118 | 'episode': episode, |
61e2331a | 119 | } |