]>
Commit | Line | Data |
---|---|---|
705f6f35 | 1 | # coding: utf-8 |
2da67107 | 2 | from __future__ import unicode_literals |
705f6f35 | 3 | |
705f6f35 JMF |
4 | from .common import InfoExtractor |
5 | ||
9c2aaac2 EF |
6 | from ..utils import js_to_json |
7 | ||
2da67107 | 8 | |
705f6f35 | 9 | class TF1IE(InfoExtractor): |
0725f584 | 10 | """TF1 uses the wat.tv player.""" |
db3b8b21 | 11 | _VALID_URL = r'https?://(?:(?:videos|www|lci)\.tf1|(?:www\.)?(?:tfou|ushuaiatv|histoire|tvbreizh))\.fr/(?:[^/]+/)*(?P<id>[^/?#.]+)' |
42833b44 | 12 | _TESTS = [{ |
2da67107 JMF |
13 | 'url': 'http://videos.tf1.fr/auto-moto/citroen-grand-c4-picasso-2013-presentation-officielle-8062060.html', |
14 | 'info_dict': { | |
15 | 'id': '10635995', | |
16 | 'ext': 'mp4', | |
17 | 'title': 'Citroën Grand C4 Picasso 2013 : présentation officielle', | |
18 | 'description': 'Vidéo officielle du nouveau Citroën Grand C4 Picasso, lancé à l\'automne 2013.', | |
19 | }, | |
20 | 'params': { | |
21 | # Sometimes wat serves the whole file with the --test option | |
22 | 'skip_download': True, | |
fa800269 | 23 | }, |
8b183bd5 | 24 | 'expected_warnings': ['HTTP Error 404'], |
382e05fa | 25 | }, { |
26 | 'url': 'http://www.tfou.fr/chuggington/videos/le-grand-mysterioso-chuggington-7085291-739.html', | |
27 | 'info_dict': { | |
ad1b6017 | 28 | 'id': 'le-grand-mysterioso-chuggington-7085291-739', |
382e05fa | 29 | 'ext': 'mp4', |
30 | 'title': 'Le grand Mystérioso - Chuggington', | |
2bf098ed | 31 | 'description': 'Le grand Mystérioso - Emery rêve qu\'un article lui soit consacré dans le journal.', |
32 | 'upload_date': '20150103', | |
382e05fa | 33 | }, |
34 | 'params': { | |
35 | # Sometimes wat serves the whole file with the --test option | |
36 | 'skip_download': True, | |
37 | }, | |
ad1b6017 | 38 | 'skip': 'HTTP Error 410: Gone', |
42833b44 YCH |
39 | }, { |
40 | 'url': 'http://www.tf1.fr/tf1/koh-lanta/videos/replay-koh-lanta-22-mai-2015.html', | |
41 | 'only_matching': True, | |
e6e63e91 S |
42 | }, { |
43 | 'url': 'http://lci.tf1.fr/sept-a-huit/videos/sept-a-huit-du-24-mai-2015-8611550.html', | |
44 | 'only_matching': True, | |
05467d5a S |
45 | }, { |
46 | 'url': 'http://www.tf1.fr/hd1/documentaire/videos/mylene-farmer-d-une-icone.html', | |
47 | 'only_matching': True, | |
9c2aaac2 EF |
48 | }, { |
49 | 'url': 'https://www.tf1.fr/tmc/quotidien-avec-yann-barthes/videos/quotidien-premiere-partie-11-juin-2019.html', | |
50 | 'info_dict': { | |
51 | 'id': '13641379', | |
52 | 'ext': 'mp4', | |
53 | 'title': 'md5:f392bc52245dc5ad43771650c96fb620', | |
54 | 'description': 'md5:44bc54f0a21322f5b91d68e76a544eae', | |
55 | 'upload_date': '20190611', | |
56 | }, | |
57 | 'params': { | |
58 | # Sometimes wat serves the whole file with the --test option | |
59 | 'skip_download': True, | |
60 | }, | |
42833b44 | 61 | }] |
705f6f35 JMF |
62 | |
63 | def _real_extract(self, url): | |
382e05fa | 64 | video_id = self._match_id(url) |
2da67107 | 65 | webpage = self._download_webpage(url, video_id) |
9c2aaac2 EF |
66 | vids_data_string = self._html_search_regex( |
67 | r'<script>\s*window\.__APOLLO_STATE__\s*=\s*(?P<vids_data_string>\{.*?\})\s*;?\s*</script>', | |
68 | webpage, 'videos data string', group='vids_data_string', default=None) | |
69 | wat_id = None | |
70 | if vids_data_string is not None: | |
71 | vids_data = self._parse_json( | |
72 | vids_data_string, video_id, | |
73 | transform_source=js_to_json) | |
74 | video_data = [v for v in vids_data.values() | |
75 | if 'slug' in v and v['slug'] == video_id] | |
76 | if len(video_data) > 0 and 'streamId' in video_data[0]: | |
77 | wat_id = video_data[0]['streamId'] | |
78 | if wat_id is None: | |
79 | wat_id = self._html_search_regex( | |
80 | [r'(["\'])(?:https?:)?//www\.wat\.tv/embedframe/.*?(?P<id>\d{8})\1', | |
81 | r'(["\']?)streamId\1\s*:\s*(["\']?)(?P<id>\d+)\2' | |
82 | ], | |
83 | webpage, 'wat id', group='id') | |
6212bcb1 | 84 | return self.url_result('wat:%s' % wat_id, 'Wat') |