]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tf1.py
Imported Upstream version 2014.06.07
[youtubedl] / youtube_dl / extractor / tf1.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class TF1IE(InfoExtractor):
10 """TF1 uses the wat.tv player."""
11 _VALID_URL = r'http://videos\.tf1\.fr/.*-(?P<id>.*?)\.html'
12 _TEST = {
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,
23 },
24 }
25
26 def _real_extract(self, url):
27 mobj = re.match(self._VALID_URL, url)
28 video_id = mobj.group('id')
29 webpage = self._download_webpage(url, video_id)
30 embed_url = self._html_search_regex(
31 r'"(https://www.wat.tv/embedframe/.*?)"', webpage, 'embed url')
32 embed_page = self._download_webpage(embed_url, video_id,
33 'Downloading embed player page')
34 wat_id = self._search_regex(r'UVID=(.*?)&', embed_page, 'wat id')
35 wat_info = self._download_json(
36 'http://www.wat.tv/interface/contentv3/%s' % wat_id, video_id)
37 return self.url_result(wat_info['media']['url'], 'Wat')