]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/wat.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / wat.py
CommitLineData
99afb3dd 1from .common import InfoExtractor
86916dae 2from ..utils import (
7c60c33e 3 ExtractorError,
57ce8a6d 4 int_or_none,
7c60c33e 5 try_get,
6 unified_strdate,
86916dae 7)
99afb3dd
JMF
8
9
10class WatIE(InfoExtractor):
c5f51551 11 _VALID_URL = r'(?:wat:|https?://(?:www\.)?wat\.tv/video/.*-)(?P<id>[0-9a-z]+)'
99afb3dd 12 IE_NAME = 'wat.tv'
c28df247
S
13 _TESTS = [
14 {
15 'url': 'http://www.wat.tv/video/soupe-figues-l-orange-aux-epices-6z1uz_2hvf7_.html',
c28df247
S
16 'info_dict': {
17 'id': '11713067',
c28df247
S
18 'ext': 'mp4',
19 'title': 'Soupe de figues à l\'orange et aux épices',
20 'description': 'Retrouvez l\'émission "Petits plats en équilibre", diffusée le 18 août 2014.',
21 'upload_date': '20140819',
22 'duration': 120,
23 },
0adf213d
RA
24 'params': {
25 # m3u8 download
26 'skip_download': True,
27 },
28 'expected_warnings': ['HTTP Error 404'],
7c60c33e 29 'skip': 'This content is no longer available',
c28df247
S
30 },
31 {
32 'url': 'http://www.wat.tv/video/gregory-lemarchal-voix-ange-6z1v7_6ygkj_.html',
0adf213d 33 'md5': 'b16574df2c3cd1a36ca0098f2a791925',
c28df247
S
34 'info_dict': {
35 'id': '11713075',
c28df247
S
36 'ext': 'mp4',
37 'title': 'Grégory Lemarchal, une voix d\'ange depuis 10 ans (1/3)',
c28df247 38 'upload_date': '20140816',
c28df247 39 },
57ce8a6d 40 'expected_warnings': ["Ce contenu n'est pas disponible pour l'instant."],
7c60c33e 41 'skip': 'This content is no longer available',
fa800269 42 },
7cccab79
DK
43 {
44 'url': 'wat:14010600',
45 'info_dict': {
46 'id': '14010600',
47 'title': 'Burger Quiz - S03 EP21 avec Eye Haidara, Anne Depétrini, Jonathan Zaccaï et Pio Marmaï',
48 'thumbnail': 'https://photos.tf1.fr/1280/720/burger-quiz-11-9adb79-0@1x.jpg',
49 'upload_date': '20230819',
50 'duration': 2312,
51 'ext': 'mp4',
52 },
53 'params': {'skip_download': 'm3u8'},
add96eb9 54 },
c28df247 55 ]
7c60c33e 56 _GEO_BYPASS = False
e7916255 57
99afb3dd 58 def _real_extract(self, url):
c5f51551 59 video_id = self._match_id(url)
add96eb9 60 video_id = video_id if video_id.isdigit() and len(video_id) > 6 else str(int(video_id, 36))
8244288d 61
c5f51551 62 # 'contentv4' is used in the website, but it also returns the related
63 # videos, we don't need them
7c60c33e 64 # video_data = self._download_json(
65 # 'http://www.wat.tv/interface/contentv4s/' + video_id, video_id)
57ce8a6d 66 video_data = self._download_json(
7c60c33e 67 'https://mediainfo.tf1.fr/mediainfocombo/' + video_id,
7cccab79 68 video_id, query={'pver': '5010000'})
57ce8a6d 69 video_info = video_data['media']
a54bda3a 70
86916dae
S
71 error_desc = video_info.get('error_desc')
72 if error_desc:
7c60c33e 73 if video_info.get('error_code') == 'GEOBLOCKED':
74 self.raise_geo_restricted(error_desc, video_info.get('geoList'))
75 raise ExtractorError(error_desc, expected=True)
99afb3dd 76
7c60c33e 77 title = video_info['title']
8244288d 78
7c60c33e 79 formats = []
ec4f374c 80 subtitles = {}
c5f51551 81
7c60c33e 82 def extract_formats(manifest_urls):
83 for f, f_url in manifest_urls.items():
84 if not f_url:
85 continue
86 if f in ('dash', 'mpd'):
ec4f374c 87 fmts, subs = self._extract_mpd_formats_and_subtitles(
7c60c33e 88 f_url.replace('://das-q1.tf1.fr/', '://das-q1-ssl.tf1.fr/'),
ec4f374c 89 video_id, mpd_id='dash', fatal=False)
7c60c33e 90 elif f == 'hls':
ec4f374c 91 fmts, subs = self._extract_m3u8_formats_and_subtitles(
7c60c33e 92 f_url, video_id, 'mp4',
ec4f374c
F
93 'm3u8_native', m3u8_id='hls', fatal=False)
94 else:
95 continue
96 formats.extend(fmts)
97 self._merge_subtitles(subs, target=subtitles)
c5f51551 98
7c60c33e 99 delivery = video_data.get('delivery') or {}
100 extract_formats({delivery.get('format'): delivery.get('url')})
101 if not formats:
102 if delivery.get('drm'):
88acdbc2 103 self.report_drm(video_id)
7c60c33e 104 manifest_urls = self._download_json(
105 'http://www.wat.tv/get/webhtml/' + video_id, video_id, fatal=False)
106 if manifest_urls:
107 extract_formats(manifest_urls)
948cd5b7 108
e7916255 109 return {
c5f51551 110 'id': video_id,
57ce8a6d 111 'title': title,
7c60c33e 112 'thumbnail': video_info.get('preview'),
113 'upload_date': unified_strdate(try_get(
114 video_data, lambda x: x['mediametrie']['chapters'][0]['estatS4'])),
115 'duration': int_or_none(video_info.get('duration')),
a54bda3a 116 'formats': formats,
ec4f374c 117 'subtitles': subtitles,
e7916255 118 }