]>
Commit | Line | Data |
---|---|---|
69a0c470 | 1 | # encoding: utf-8 |
3798eadc PH |
2 | from __future__ import unicode_literals |
3 | ||
d5822b96 | 4 | import re |
d5822b96 PH |
5 | |
6 | from .common import InfoExtractor | |
393ca8c9 S |
7 | from ..compat import ( |
8 | compat_parse_qs, | |
9 | compat_urllib_parse_urlparse, | |
10 | ) | |
d5822b96 | 11 | from ..utils import ( |
df50a412 | 12 | find_xpath_attr, |
d5822b96 | 13 | unified_strdate, |
56a8ab7d | 14 | get_element_by_attribute, |
d24a2b20 | 15 | int_or_none, |
3f7e8750 | 16 | NO_DEFAULT, |
aff2f4f4 | 17 | qualities, |
d5822b96 PH |
18 | ) |
19 | ||
5f6a1245 | 20 | # There are different sources of video in arte.tv, the extraction process |
c40f5cf4 JMF |
21 | # is different for each one. The videos usually expire in 7 days, so we can't |
22 | # add tests. | |
23 | ||
d5822b96 | 24 | |
515bbe4b | 25 | class ArteTvIE(InfoExtractor): |
5886b38d | 26 | _VALID_URL = r'https?://videos\.arte\.tv/(?P<lang>fr|de|en|es)/.*-(?P<id>.*?)\.html' |
3798eadc | 27 | IE_NAME = 'arte.tv' |
d5822b96 | 28 | |
d5822b96 | 29 | def _real_extract(self, url): |
7a249480 PH |
30 | mobj = re.match(self._VALID_URL, url) |
31 | lang = mobj.group('lang') | |
32 | video_id = mobj.group('id') | |
33 | ||
8de64cac PH |
34 | ref_xml_url = url.replace('/videos/', '/do_delegate/videos/') |
35 | ref_xml_url = ref_xml_url.replace('.html', ',view,asPlayerXml.xml') | |
a4ff6c47 PH |
36 | ref_xml_doc = self._download_xml( |
37 | ref_xml_url, video_id, note='Downloading metadata') | |
df50a412 | 38 | config_node = find_xpath_attr(ref_xml_doc, './/video', 'lang', lang) |
8de64cac | 39 | config_xml_url = config_node.attrib['ref'] |
878d11ec | 40 | config = self._download_xml( |
a4ff6c47 | 41 | config_xml_url, video_id, note='Downloading configuration') |
37b6a661 | 42 | |
878d11ec | 43 | formats = [{ |
5a184030 | 44 | 'format_id': q.attrib['quality'], |
459af434 JMF |
45 | # The playpath starts at 'mp4:', if we don't manually |
46 | # split the url, rtmpdump will incorrectly parse them | |
47 | 'url': q.text.split('mp4:', 1)[0], | |
48 | 'play_path': 'mp4:' + q.text.split('mp4:', 1)[1], | |
b2799ff9 | 49 | 'ext': 'flv', |
878d11ec | 50 | 'quality': 2 if q.attrib['quality'] == 'hd' else 1, |
b2799ff9 | 51 | } for q in config.findall('./urls/url')] |
878d11ec PH |
52 | self._sort_formats(formats) |
53 | ||
54 | title = config.find('.//name').text | |
55 | thumbnail = config.find('.//firstThumbnailUrl').text | |
56 | return { | |
57 | 'id': video_id, | |
58 | 'title': title, | |
59 | 'thumbnail': thumbnail, | |
7a249480 | 60 | 'formats': formats, |
515bbe4b | 61 | } |
c40f5cf4 JMF |
62 | |
63 | ||
6e6b9f60 | 64 | class ArteTVBaseIE(InfoExtractor): |
69a0c470 JMF |
65 | @classmethod |
66 | def _extract_url_info(cls, url): | |
67 | mobj = re.match(cls._VALID_URL, url) | |
c40f5cf4 | 68 | lang = mobj.group('lang') |
a8f1d167 JMF |
69 | query = compat_parse_qs(compat_urllib_parse_urlparse(url).query) |
70 | if 'vid' in query: | |
71 | video_id = query['vid'][0] | |
72 | else: | |
73 | # This is not a real id, it can be for example AJT for the news | |
74 | # http://www.arte.tv/guide/fr/emissions/AJT/arte-journal | |
75 | video_id = mobj.group('id') | |
69a0c470 | 76 | return video_id, lang |
c40f5cf4 | 77 | |
46c329d6 | 78 | def _extract_from_json_url(self, json_url, video_id, lang, title=None): |
893f8832 | 79 | info = self._download_json(json_url, video_id) |
c40f5cf4 JMF |
80 | player_info = info['videoJsonPlayer'] |
81 | ||
99b67fec PH |
82 | upload_date_str = player_info.get('shootingDate') |
83 | if not upload_date_str: | |
8bbd3d14 | 84 | upload_date_str = (player_info.get('VRA') or player_info.get('VDA') or '').split(' ')[0] |
99b67fec | 85 | |
46c329d6 | 86 | title = (player_info.get('VTI') or title or player_info['VID']).strip() |
74214d35 S |
87 | subtitle = player_info.get('VSU', '').strip() |
88 | if subtitle: | |
89 | title += ' - %s' % subtitle | |
90 | ||
c40f5cf4 JMF |
91 | info_dict = { |
92 | 'id': player_info['VID'], | |
74214d35 | 93 | 'title': title, |
c40f5cf4 | 94 | 'description': player_info.get('VDE'), |
99b67fec | 95 | 'upload_date': unified_strdate(upload_date_str), |
c40f5cf4 JMF |
96 | 'thumbnail': player_info.get('programImage') or player_info.get('VTU', {}).get('IUR'), |
97 | } | |
aff2f4f4 | 98 | qfunc = qualities(['HQ', 'MQ', 'EQ', 'SQ']) |
c40f5cf4 | 99 | |
08d65046 S |
100 | LANGS = { |
101 | 'fr': 'F', | |
102 | 'de': 'A', | |
103 | 'en': 'E[ANG]', | |
104 | 'es': 'E[ESP]', | |
105 | } | |
106 | ||
9c072d38 S |
107 | langcode = LANGS.get(lang, lang) |
108 | ||
aff2f4f4 | 109 | formats = [] |
d24a2b20 | 110 | for format_id, format_dict in player_info['VSR'].items(): |
aff2f4f4 PH |
111 | f = dict(format_dict) |
112 | versionCode = f.get('versionCode') | |
9c072d38 S |
113 | l = re.escape(langcode) |
114 | ||
115 | # Language preference from most to least priority | |
116 | # Reference: section 5.6.3 of | |
117 | # http://www.arte.tv/sites/en/corporate/files/complete-technical-guidelines-arte-geie-v1-05.pdf | |
118 | PREFERENCES = ( | |
119 | # original version in requested language, without subtitles | |
120 | r'VO{0}$'.format(l), | |
121 | # original version in requested language, with partial subtitles in requested language | |
122 | r'VO{0}-ST{0}$'.format(l), | |
123 | # original version in requested language, with subtitles for the deaf and hard-of-hearing in requested language | |
124 | r'VO{0}-STM{0}$'.format(l), | |
125 | # non-original (dubbed) version in requested language, without subtitles | |
126 | r'V{0}$'.format(l), | |
127 | # non-original (dubbed) version in requested language, with subtitles partial subtitles in requested language | |
128 | r'V{0}-ST{0}$'.format(l), | |
129 | # non-original (dubbed) version in requested language, with subtitles for the deaf and hard-of-hearing in requested language | |
130 | r'V{0}-STM{0}$'.format(l), | |
131 | # original version in requested language, with partial subtitles in different language | |
132 | r'VO{0}-ST(?!{0}).+?$'.format(l), | |
133 | # original version in requested language, with subtitles for the deaf and hard-of-hearing in different language | |
134 | r'VO{0}-STM(?!{0}).+?$'.format(l), | |
135 | # original version in different language, with partial subtitles in requested language | |
136 | r'VO(?:(?!{0}).+?)?-ST{0}$'.format(l), | |
137 | # original version in different language, with subtitles for the deaf and hard-of-hearing in requested language | |
138 | r'VO(?:(?!{0}).+?)?-STM{0}$'.format(l), | |
139 | # original version in different language, without subtitles | |
140 | r'VO(?:(?!{0}))?$'.format(l), | |
141 | # original version in different language, with partial subtitles in different language | |
142 | r'VO(?:(?!{0}).+?)?-ST(?!{0}).+?$'.format(l), | |
143 | # original version in different language, with subtitles for the deaf and hard-of-hearing in different language | |
144 | r'VO(?:(?!{0}).+?)?-STM(?!{0}).+?$'.format(l), | |
145 | ) | |
146 | ||
147 | for pref, p in enumerate(PREFERENCES): | |
148 | if re.match(p, versionCode): | |
149 | lang_pref = len(PREFERENCES) - pref | |
150 | break | |
151 | else: | |
152 | lang_pref = -1 | |
153 | ||
aff2f4f4 PH |
154 | format = { |
155 | 'format_id': format_id, | |
156 | 'preference': -10 if f.get('videoFormat') == 'M3U8' else None, | |
157 | 'language_preference': lang_pref, | |
158 | 'format_note': '%s, %s' % (f.get('versionCode'), f.get('versionLibelle')), | |
159 | 'width': int_or_none(f.get('width')), | |
160 | 'height': int_or_none(f.get('height')), | |
161 | 'tbr': int_or_none(f.get('bitrate')), | |
1b7b1d6e | 162 | 'quality': qfunc(f.get('quality')), |
c40f5cf4 | 163 | } |
aff2f4f4 PH |
164 | |
165 | if f.get('mediaType') == 'rtmp': | |
166 | format['url'] = f['streamer'] | |
167 | format['play_path'] = 'mp4:' + f['url'] | |
168 | format['ext'] = 'flv' | |
c40f5cf4 | 169 | else: |
aff2f4f4 PH |
170 | format['url'] = f['url'] |
171 | ||
172 | formats.append(format) | |
173 | ||
c06a9f87 | 174 | self._check_formats(formats, video_id) |
aff2f4f4 | 175 | self._sort_formats(formats) |
c40f5cf4 | 176 | |
aff2f4f4 | 177 | info_dict['formats'] = formats |
c40f5cf4 JMF |
178 | return info_dict |
179 | ||
180 | ||
6e6b9f60 S |
181 | class ArteTVPlus7IE(ArteTVBaseIE): |
182 | IE_NAME = 'arte.tv:+7' | |
90b6288c | 183 | _VALID_URL = r'https?://(?:(?:www|sites)\.)?arte\.tv/[^/]+/(?P<lang>fr|de|en|es)/(?:[^/]+/)*(?P<id>[^/?#&]+)' |
6e6b9f60 S |
184 | |
185 | _TESTS = [{ | |
186 | 'url': 'http://www.arte.tv/guide/de/sendungen/XEN/xenius/?vid=055918-015_PLUS7-D', | |
187 | 'only_matching': True, | |
90b6288c | 188 | }, { |
d7c6c656 S |
189 | 'url': 'http://sites.arte.tv/karambolage/de/video/karambolage-22', |
190 | 'only_matching': True, | |
6e6b9f60 S |
191 | }] |
192 | ||
193 | @classmethod | |
194 | def suitable(cls, url): | |
195 | return False if ArteTVPlaylistIE.suitable(url) else super(ArteTVPlus7IE, cls).suitable(url) | |
196 | ||
197 | def _real_extract(self, url): | |
198 | video_id, lang = self._extract_url_info(url) | |
199 | webpage = self._download_webpage(url, video_id) | |
200 | return self._extract_from_webpage(webpage, video_id, lang) | |
201 | ||
202 | def _extract_from_webpage(self, webpage, video_id, lang): | |
203 | patterns_templates = (r'arte_vp_url=["\'](.*?%s.*?)["\']', r'data-url=["\']([^"]+%s[^"]+)["\']') | |
204 | ids = (video_id, '') | |
205 | # some pages contain multiple videos (like | |
206 | # http://www.arte.tv/guide/de/sendungen/XEN/xenius/?vid=055918-015_PLUS7-D), | |
207 | # so we first try to look for json URLs that contain the video id from | |
208 | # the 'vid' parameter. | |
209 | patterns = [t % re.escape(_id) for _id in ids for t in patterns_templates] | |
210 | json_url = self._html_search_regex( | |
211 | patterns, webpage, 'json vp url', default=None) | |
212 | if not json_url: | |
213 | def find_iframe_url(webpage, default=NO_DEFAULT): | |
214 | return self._html_search_regex( | |
215 | r'<iframe[^>]+src=(["\'])(?P<url>.+\bjson_url=.+?)\1', | |
216 | webpage, 'iframe url', group='url', default=default) | |
217 | ||
218 | iframe_url = find_iframe_url(webpage, None) | |
219 | if not iframe_url: | |
220 | embed_url = self._html_search_regex( | |
221 | r'arte_vp_url_oembed=\'([^\']+?)\'', webpage, 'embed url', default=None) | |
222 | if embed_url: | |
223 | player = self._download_json( | |
224 | embed_url, video_id, 'Downloading player page') | |
225 | iframe_url = find_iframe_url(player['html']) | |
226 | # en and es URLs produce react-based pages with different layout (e.g. | |
227 | # http://www.arte.tv/guide/en/053330-002-A/carnival-italy?zone=world) | |
228 | if not iframe_url: | |
229 | program = self._search_regex( | |
230 | r'program\s*:\s*({.+?["\']embed_html["\'].+?}),?\s*\n', | |
231 | webpage, 'program', default=None) | |
232 | if program: | |
233 | embed_html = self._parse_json(program, video_id) | |
234 | if embed_html: | |
235 | iframe_url = find_iframe_url(embed_html['embed_html']) | |
236 | if iframe_url: | |
237 | json_url = compat_parse_qs( | |
238 | compat_urllib_parse_urlparse(iframe_url).query)['json_url'][0] | |
239 | if json_url: | |
240 | title = self._search_regex( | |
241 | r'<h3[^>]+title=(["\'])(?P<title>.+?)\1', | |
242 | webpage, 'title', default=None, group='title') | |
243 | return self._extract_from_json_url(json_url, video_id, lang, title=title) | |
244 | # Different kind of embed URL (e.g. | |
245 | # http://www.arte.tv/magazine/trepalium/fr/episode-0406-replay-trepalium) | |
09e3f91e YCH |
246 | entries = [ |
247 | self.url_result(url) | |
248 | for _, url in re.findall(r'<iframe[^>]+src=(["\'])(?P<url>.+?)\1', webpage)] | |
249 | return self.playlist_result(entries) | |
6e6b9f60 S |
250 | |
251 | ||
c40f5cf4 JMF |
252 | # It also uses the arte_vp_url url from the webpage to extract the information |
253 | class ArteTVCreativeIE(ArteTVPlus7IE): | |
3798eadc | 254 | IE_NAME = 'arte.tv:creative' |
9e285387 | 255 | _VALID_URL = r'https?://creative\.arte\.tv/(?P<lang>fr|de|en|es)/(?:[^/]+/)*(?P<id>[^/?#&]+)' |
c40f5cf4 | 256 | |
01d906ff | 257 | _TESTS = [{ |
09e3f91e | 258 | 'url': 'http://creative.arte.tv/fr/episode/osmosis-episode-1', |
3798eadc | 259 | 'info_dict': { |
09e3f91e | 260 | 'id': '057405-001-A', |
39a743fb | 261 | 'ext': 'mp4', |
09e3f91e YCH |
262 | 'title': 'OSMOSIS - N\'AYEZ PLUS PEUR D\'AIMER (1)', |
263 | 'upload_date': '20150716', | |
c40f5cf4 | 264 | }, |
01d906ff PH |
265 | }, { |
266 | 'url': 'http://creative.arte.tv/fr/Monty-Python-Reunion', | |
09e3f91e YCH |
267 | 'playlist_count': 11, |
268 | 'add_ie': ['Youtube'], | |
9e285387 S |
269 | }, { |
270 | 'url': 'http://creative.arte.tv/de/episode/agentur-amateur-4-der-erste-kunde', | |
271 | 'only_matching': True, | |
01d906ff | 272 | }] |
c40f5cf4 | 273 | |
69a0c470 | 274 | |
40428413 S |
275 | class ArteTVInfoIE(ArteTVPlus7IE): |
276 | IE_NAME = 'arte.tv:info' | |
277 | _VALID_URL = r'https?://info\.arte\.tv/(?P<lang>fr|de|en|es)/(?:[^/]+/)*(?P<id>[^/?#&]+)' | |
278 | ||
6e6b9f60 | 279 | _TESTS = [{ |
40428413 S |
280 | 'url': 'http://info.arte.tv/fr/service-civique-un-cache-misere', |
281 | 'info_dict': { | |
282 | 'id': '067528-000-A', | |
283 | 'ext': 'mp4', | |
284 | 'title': 'Service civique, un cache misère ?', | |
285 | 'upload_date': '20160403', | |
286 | }, | |
6e6b9f60 | 287 | }] |
40428413 S |
288 | |
289 | ||
69a0c470 | 290 | class ArteTVFutureIE(ArteTVPlus7IE): |
3798eadc | 291 | IE_NAME = 'arte.tv:future' |
d48502b8 | 292 | _VALID_URL = r'https?://future\.arte\.tv/(?P<lang>fr|de|en|es)/(?P<id>[^/?#&]+)' |
24114fee | 293 | |
9c54ae33 S |
294 | _TESTS = [{ |
295 | 'url': 'http://future.arte.tv/fr/info-sciences/les-ecrevisses-aussi-sont-anxieuses', | |
296 | 'info_dict': { | |
297 | 'id': '050940-028-A', | |
298 | 'ext': 'mp4', | |
299 | 'title': 'Les écrevisses aussi peuvent être anxieuses', | |
92c5e11b | 300 | 'upload_date': '20140902', |
69a0c470 | 301 | }, |
9c54ae33 S |
302 | }, { |
303 | 'url': 'http://future.arte.tv/fr/la-science-est-elle-responsable', | |
304 | 'only_matching': True, | |
305 | }] | |
56a8ab7d | 306 | |
ac5118bc | 307 | |
56a8ab7d | 308 | class ArteTVDDCIE(ArteTVPlus7IE): |
3798eadc | 309 | IE_NAME = 'arte.tv:ddc' |
d48502b8 | 310 | _VALID_URL = r'https?://ddc\.arte\.tv/(?P<lang>emission|folge)/(?P<id>[^/?#&]+)' |
56a8ab7d | 311 | |
6e6b9f60 S |
312 | _TESTS = [] |
313 | ||
56a8ab7d CD |
314 | def _real_extract(self, url): |
315 | video_id, lang = self._extract_url_info(url) | |
316 | if lang == 'folge': | |
317 | lang = 'de' | |
318 | elif lang == 'emission': | |
319 | lang = 'fr' | |
320 | webpage = self._download_webpage(url, video_id) | |
321 | scriptElement = get_element_by_attribute('class', 'visu_video_block', webpage) | |
322 | script_url = self._html_search_regex(r'src="(.*?)"', scriptElement, 'script url') | |
323 | javascriptPlayerGenerator = self._download_webpage(script_url, video_id, 'Download javascript player generator') | |
324 | json_url = self._search_regex(r"json_url=(.*)&rendering_place.*", javascriptPlayerGenerator, 'json url') | |
325 | return self._extract_from_json_url(json_url, video_id, lang) | |
4966a0b2 JMF |
326 | |
327 | ||
328 | class ArteTVConcertIE(ArteTVPlus7IE): | |
329 | IE_NAME = 'arte.tv:concert' | |
d48502b8 | 330 | _VALID_URL = r'https?://concert\.arte\.tv/(?P<lang>fr|de|en|es)/(?P<id>[^/?#&]+)' |
4966a0b2 | 331 | |
6e6b9f60 | 332 | _TESTS = [{ |
4966a0b2 JMF |
333 | 'url': 'http://concert.arte.tv/de/notwist-im-pariser-konzertclub-divan-du-monde', |
334 | 'md5': '9ea035b7bd69696b67aa2ccaaa218161', | |
335 | 'info_dict': { | |
336 | 'id': '186', | |
337 | 'ext': 'mp4', | |
338 | 'title': 'The Notwist im Pariser Konzertclub "Divan du Monde"', | |
339 | 'upload_date': '20140128', | |
a9c2896e | 340 | 'description': 'md5:486eb08f991552ade77439fe6d82c305', |
4966a0b2 | 341 | }, |
6e6b9f60 | 342 | }] |
893f8832 PH |
343 | |
344 | ||
4fcd9d14 S |
345 | class ArteTVCinemaIE(ArteTVPlus7IE): |
346 | IE_NAME = 'arte.tv:cinema' | |
44b97450 | 347 | _VALID_URL = r'https?://cinema\.arte\.tv/(?P<lang>fr|de|en|es)/(?P<id>.+)' |
4fcd9d14 | 348 | |
6e6b9f60 | 349 | _TESTS = [{ |
09e3f91e YCH |
350 | 'url': 'http://cinema.arte.tv/fr/article/les-ailes-du-desir-de-julia-reck', |
351 | 'md5': 'a5b9dd5575a11d93daf0e3f404f45438', | |
4fcd9d14 | 352 | 'info_dict': { |
09e3f91e | 353 | 'id': '062494-000-A', |
4fcd9d14 | 354 | 'ext': 'mp4', |
09e3f91e YCH |
355 | 'title': 'Film lauréat du concours web - "Les ailes du désir" de Julia Reck', |
356 | 'upload_date': '20150807', | |
4fcd9d14 | 357 | }, |
6e6b9f60 | 358 | }] |
4fcd9d14 S |
359 | |
360 | ||
49625662 TJ |
361 | class ArteTVMagazineIE(ArteTVPlus7IE): |
362 | IE_NAME = 'arte.tv:magazine' | |
479ec54a | 363 | _VALID_URL = r'https?://(?:www\.)?arte\.tv/magazine/[^/]+/(?P<lang>fr|de|en|es)/(?P<id>[^/?#&]+)' |
49625662 TJ |
364 | |
365 | _TESTS = [{ | |
305168ca | 366 | # Embedded via <iframe src="http://www.arte.tv/arte_vp/index.php?json_url=..." |
49625662 | 367 | 'url': 'http://www.arte.tv/magazine/trepalium/fr/entretien-avec-le-realisateur-vincent-lannoo-trepalium', |
0dd046c1 | 368 | 'md5': '2a9369bcccf847d1c741e51416299f25', |
49625662 TJ |
369 | 'info_dict': { |
370 | 'id': '065965-000-A', | |
371 | 'ext': 'mp4', | |
372 | 'title': 'Trepalium - Extrait Ep.01', | |
0dd046c1 | 373 | 'upload_date': '20160121', |
49625662 | 374 | }, |
305168ca S |
375 | }, { |
376 | # Embedded via <iframe src="http://www.arte.tv/guide/fr/embed/054813-004-A/medium" | |
377 | 'url': 'http://www.arte.tv/magazine/trepalium/fr/episode-0406-replay-trepalium', | |
378 | 'md5': 'fedc64fc7a946110fe311634e79782ca', | |
379 | 'info_dict': { | |
380 | 'id': '054813-004_PLUS7-F', | |
381 | 'ext': 'mp4', | |
382 | 'title': 'Trepalium (4/6)', | |
383 | 'description': 'md5:10057003c34d54e95350be4f9b05cb40', | |
384 | 'upload_date': '20160218', | |
385 | }, | |
49625662 TJ |
386 | }, { |
387 | 'url': 'http://www.arte.tv/magazine/metropolis/de/frank-woeste-german-paris-metropolis', | |
479ec54a | 388 | 'only_matching': True, |
49625662 TJ |
389 | }] |
390 | ||
391 | ||
893f8832 PH |
392 | class ArteTVEmbedIE(ArteTVPlus7IE): |
393 | IE_NAME = 'arte.tv:embed' | |
394 | _VALID_URL = r'''(?x) | |
395 | http://www\.arte\.tv | |
134c207e | 396 | /(?:playerv2/embed|arte_vp/index)\.php\?json_url= |
893f8832 PH |
397 | (?P<json_url> |
398 | http://arte\.tv/papi/tvguide/videos/stream/player/ | |
399 | (?P<lang>[^/]+)/(?P<id>[^/]+)[^&]* | |
400 | ) | |
401 | ''' | |
402 | ||
6e6b9f60 S |
403 | _TESTS = [] |
404 | ||
893f8832 PH |
405 | def _real_extract(self, url): |
406 | mobj = re.match(self._VALID_URL, url) | |
407 | video_id = mobj.group('id') | |
408 | lang = mobj.group('lang') | |
409 | json_url = mobj.group('json_url') | |
410 | return self._extract_from_json_url(json_url, video_id, lang) | |
6e6b9f60 S |
411 | |
412 | ||
413 | class ArteTVPlaylistIE(ArteTVBaseIE): | |
414 | IE_NAME = 'arte.tv:playlist' | |
415 | _VALID_URL = r'https?://(?:www\.)?arte\.tv/guide/(?P<lang>fr|de|en|es)/[^#]*#collection/(?P<id>PL-\d+)' | |
416 | ||
417 | _TESTS = [{ | |
418 | 'url': 'http://www.arte.tv/guide/de/plus7/?country=DE#collection/PL-013263/ARTETV', | |
419 | 'info_dict': { | |
420 | 'id': 'PL-013263', | |
421 | 'title': 'Areva & Uramin', | |
97124e57 | 422 | 'description': 'md5:a1dc0312ce357c262259139cfd48c9bf', |
6e6b9f60 S |
423 | }, |
424 | 'playlist_mincount': 6, | |
425 | }, { | |
426 | 'url': 'http://www.arte.tv/guide/de/playlists?country=DE#collection/PL-013190/ARTETV', | |
427 | 'only_matching': True, | |
428 | }] | |
429 | ||
430 | def _real_extract(self, url): | |
431 | playlist_id, lang = self._extract_url_info(url) | |
432 | collection = self._download_json( | |
433 | 'https://api.arte.tv/api/player/v1/collectionData/%s/%s?source=videos' | |
434 | % (lang, playlist_id), playlist_id) | |
435 | title = collection.get('title') | |
436 | description = collection.get('shortDescription') or collection.get('teaserText') | |
437 | entries = [ | |
438 | self._extract_from_json_url( | |
439 | video['jsonUrl'], video.get('programId') or playlist_id, lang) | |
440 | for video in collection['videos'] if video.get('jsonUrl')] | |
441 | return self.playlist_result(entries, playlist_id, title, description) |