]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/wat.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
13 class WatIE(InfoExtractor
):
14 _VALID_URL
= r
'(?:wat:|https?://(?:www\.)?wat\.tv/video/.*-)(?P<id>[0-9a-z]+)'
18 'url': 'http://www.wat.tv/video/soupe-figues-l-orange-aux-epices-6z1uz_2hvf7_.html',
22 'title': 'Soupe de figues à l\'orange et aux épices',
23 'description': 'Retrouvez l\'émission "Petits plats en équilibre", diffusée le 18 août 2014.',
24 'upload_date': '20140819',
29 'skip_download': True,
31 'expected_warnings': ['HTTP Error 404'],
34 'url': 'http://www.wat.tv/video/gregory-lemarchal-voix-ange-6z1v7_6ygkj_.html',
35 'md5': 'b16574df2c3cd1a36ca0098f2a791925',
39 'title': 'Grégory Lemarchal, une voix d\'ange depuis 10 ans (1/3)',
40 'upload_date': '20140816',
42 'expected_warnings': ["Ce contenu n'est pas disponible pour l'instant."],
46 def _real_extract(self
, url
):
47 video_id
= self
._match
_id
(url
)
48 video_id
= video_id
if video_id
.isdigit() and len(video_id
) > 6 else compat_str(int(video_id
, 36))
50 # 'contentv4' is used in the website, but it also returns the related
51 # videos, we don't need them
52 video_data
= self
._download
_json
(
53 'http://www.wat.tv/interface/contentv4s/' + video_id
, video_id
)
54 video_info
= video_data
['media']
56 error_desc
= video_info
.get('error_desc')
59 '%s returned error: %s' % (self
.IE_NAME
, error_desc
))
61 chapters
= video_info
['chapters']
63 first_chapter
= chapters
[0]
65 def video_id_for_chapter(chapter
):
66 return chapter
['tc_start'].split('-')[0]
68 if video_id_for_chapter(first_chapter
) != video_id
:
69 self
.to_screen('Multipart video detected')
70 entries
= [self
.url_result('wat:%s' % video_id_for_chapter(chapter
)) for chapter
in chapters
]
71 return self
.playlist_result(entries
, video_id
, video_info
['title'])
72 # Otherwise we can continue and extract just one part, we have to use
73 # the video id for getting the video url
75 first_chapter
= video_info
77 title
= first_chapter
['title']
79 def extract_url(path_template
, url_type
):
80 req_url
= 'http://www.wat.tv/get/%s' % (path_template
% video_id
)
81 head
= self
._request
_webpage
(HEADRequest(req_url
), video_id
, 'Extracting %s url' % url_type
, fatal
=False)
83 red_url
= head
.geturl()
84 if req_url
!= red_url
:
89 manifest_urls
= self
._download
_json
(
90 'http://www.wat.tv/get/webhtml/' + video_id
, video_id
)
91 m3u8_url
= manifest_urls
.get('hls')
93 formats
.extend(self
._extract
_m
3u8_formats
(
94 m3u8_url
, video_id
, 'mp4',
95 'm3u8_native', m3u8_id
='hls', fatal
=False))
96 mpd_url
= manifest_urls
.get('mpd')
98 formats
.extend(self
._extract
_mpd
_formats
(
99 mpd_url
.replace('://das-q1.tf1.fr/', '://das-q1-ssl.tf1.fr/'),
100 video_id
, mpd_id
='dash', fatal
=False))
101 self
._sort
_formats
(formats
)
103 date_diffusion
= first_chapter
.get('date_diffusion') or video_data
.get('configv4', {}).get('estatS4')
104 upload_date
= unified_strdate(date_diffusion
) if date_diffusion
else None
106 files
= video_info
['files']
108 duration
= int_or_none(files
[0].get('duration'))
113 'thumbnail': first_chapter
.get('preview'),
114 'description': first_chapter
.get('description'),
115 'view_count': int_or_none(video_info
.get('views')),
116 'upload_date': upload_date
,
117 'duration': duration
,