]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/eitb.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / eitb.py
CommitLineData
5d7b253e 1from .common import InfoExtractor
3d2623a8 2from ..networking import Request
3from ..utils import float_or_none, int_or_none, parse_iso8601
5d7b253e
JMF
4
5
6class EitbIE(InfoExtractor):
c95eeb7b 7 IE_NAME = 'eitb.tv'
8a06999b 8 _VALID_URL = r'https?://(?:www\.)?eitb\.tv/(?:eu/bideoa|es/video)/[^/]+/\d+/(?P<id>\d+)'
5d7b253e
JMF
9
10 _TEST = {
80dcee5c 11 'url': 'http://www.eitb.tv/es/video/60-minutos-60-minutos-2013-2014/4104995148001/4090227752001/lasa-y-zabala-30-anos/',
c95eeb7b
PH
12 'md5': 'edf4436247185adee3ea18ce64c47998',
13 'info_dict': {
80dcee5c 14 'id': '4090227752001',
c95eeb7b
PH
15 'ext': 'mp4',
16 'title': '60 minutos (Lasa y Zabala, 30 años)',
8a06999b
S
17 'description': 'Programa de reportajes de actualidad.',
18 'duration': 3996.76,
19 'timestamp': 1381789200,
80dcee5c 20 'upload_date': '20131014',
8a06999b 21 'tags': list,
5d7b253e
JMF
22 },
23 }
24
25 def _real_extract(self, url):
80dcee5c 26 video_id = self._match_id(url)
8a06999b
S
27
28 video = self._download_json(
add96eb9 29 f'http://mam.eitb.eus/mam/REST/ServiceMultiweb/Video/MULTIWEBTV/{video_id}/',
8a06999b
S
30 video_id, 'Downloading video JSON')
31
32 media = video['web_media'][0]
80dcee5c 33
34 formats = []
8a06999b
S
35 for rendition in media['RENDITIONS']:
36 video_url = rendition.get('PMD_URL')
37 if not video_url:
38 continue
39 tbr = float_or_none(rendition.get('ENCODING_RATE'), 1000)
40 format_id = 'http'
41 if tbr:
add96eb9 42 format_id += f'-{int(tbr)}'
80dcee5c 43 formats.append({
44 'url': rendition['PMD_URL'],
8a06999b 45 'format_id': format_id,
80dcee5c 46 'width': int_or_none(rendition.get('FRAME_WIDTH')),
47 'height': int_or_none(rendition.get('FRAME_HEIGHT')),
8a06999b 48 'tbr': tbr,
80dcee5c 49 })
50
8a06999b
S
51 hls_url = media.get('HLS_SURL')
52 if hls_url:
3d2623a8 53 request = Request(
8a06999b
S
54 'http://mam.eitb.eus/mam/REST/ServiceMultiweb/DomainRestrictedSecurity/TokenAuth/',
55 headers={'Referer': url})
56 token_data = self._download_json(
57 request, video_id, 'Downloading auth token', fatal=False)
58 if token_data:
59 token = token_data.get('token')
60 if token:
7e5edcfd 61 formats.extend(self._extract_m3u8_formats(
add96eb9 62 f'{hls_url}?hdnts={token}', video_id, m3u8_id='hls', fatal=False))
8a06999b 63
999079b4 64 hds_url = media.get('HDS_SURL')
8a06999b 65 if hds_url:
7e5edcfd 66 formats.extend(self._extract_f4m_formats(
add96eb9 67 '{}?hdcore=3.7.0'.format(hds_url.replace('euskalsvod', 'euskalvod')),
7e5edcfd 68 video_id, f4m_id='hds', fatal=False))
80dcee5c 69
80dcee5c 70 return {
71 'id': video_id,
8a06999b
S
72 'title': media.get('NAME_ES') or media.get('name') or media['NAME_EU'],
73 'description': media.get('SHORT_DESC_ES') or video.get('desc_group') or media.get('SHORT_DESC_EU'),
74 'thumbnail': media.get('STILL_URL') or media.get('THUMBNAIL_URL'),
75 'duration': float_or_none(media.get('LENGTH'), 1000),
76 'timestamp': parse_iso8601(media.get('BROADCST_DATE'), ' '),
77 'tags': media.get('TAGS'),
80dcee5c 78 'formats': formats,
79 }