]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/dumpert.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / dumpert.py
CommitLineData
4d5d14f5 1from .common import InfoExtractor
5c2266df 2from ..utils import (
f8ae4415 3 determine_ext,
e29e96a9 4 int_or_none,
5c2266df 5 qualities,
5c2266df 6)
4d5d14f5
JS
7
8
9class DumpertIE(InfoExtractor):
f8ae4415 10 _VALID_URL = r'''(?x)
eedb38ce
R
11 (?P<protocol>https?)://(?:(?:www|legacy)\.)?dumpert\.nl/(?:
12 (?:mediabase|embed|item)/|
13 [^#]*[?&]selectedId=
f8ae4415 14 )(?P<id>[0-9]+[/_][0-9a-zA-Z]+)'''
aa3f9867 15 _TESTS = [{
e29e96a9 16 'url': 'https://www.dumpert.nl/item/6646981_951bc60f',
4d5d14f5
JS
17 'md5': '1b9318d7d5054e7dcb9dc7654f21d643',
18 'info_dict': {
19 'id': '6646981/951bc60f',
20 'ext': 'mp4',
21 'title': 'Ik heb nieuws voor je',
87270c84 22 'description': 'Niet schrikken hoor',
ec85ded8 23 'thumbnail': r're:^https?://.*\.jpg$',
f8ae4415
D
24 'duration': 9,
25 'view_count': int,
26 'like_count': int,
add96eb9 27 },
aa3f9867 28 }, {
e29e96a9
RA
29 'url': 'https://www.dumpert.nl/embed/6675421_dc440fe7',
30 'only_matching': True,
31 }, {
32 'url': 'http://legacy.dumpert.nl/mediabase/6646981/951bc60f',
33 'only_matching': True,
34 }, {
35 'url': 'http://legacy.dumpert.nl/embed/6675421/dc440fe7',
aa3f9867 36 'only_matching': True,
f8ae4415
D
37 }, {
38 'url': 'https://www.dumpert.nl/item/100031688_b317a185',
39 'info_dict': {
40 'id': '100031688/b317a185',
41 'ext': 'mp4',
42 'title': 'Epic schijnbeweging',
43 'description': '<p>Die zag je niet eh</p>',
44 'thumbnail': r're:^https?://.*\.(?:jpg|png)$',
45 'duration': 12,
46 'view_count': int,
47 'like_count': int,
48 },
add96eb9 49 'params': {'skip_download': 'm3u8'},
f8ae4415
D
50 }, {
51 'url': 'https://www.dumpert.nl/toppers?selectedId=100031688_b317a185',
52 'only_matching': True,
53 }, {
54 'url': 'https://www.dumpert.nl/latest?selectedId=100031688_b317a185',
55 'only_matching': True,
56 }, {
57 'url': 'https://www.dumpert.nl/?selectedId=100031688_b317a185',
58 'only_matching': True,
eedb38ce
R
59 }, {
60 'url': 'https://www.dumpert.nl/toppers/dag?selectedId=100086074_f5cef3ac',
61 'only_matching': True,
aa3f9867 62 }]
4d5d14f5
JS
63
64 def _real_extract(self, url):
e29e96a9
RA
65 video_id = self._match_id(url).replace('_', '/')
66 item = self._download_json(
67 'http://api-live.dumpert.nl/mobile_api/json/info/' + video_id.replace('/', '_'),
68 video_id)['items'][0]
69 title = item['title']
70 media = next(m for m in item['media'] if m.get('mediatype') == 'VIDEO')
4d5d14f5 71
f8ae4415 72 quality = qualities(['flv', 'mobile', 'tablet', '720p', '1080p'])
e29e96a9
RA
73 formats = []
74 for variant in media.get('variants', []):
75 uri = variant.get('uri')
76 if not uri:
77 continue
78 version = variant.get('version')
f8ae4415
D
79 preference = quality(version)
80 if determine_ext(uri) == 'm3u8':
81 formats.extend(self._extract_m3u8_formats(
82 uri, video_id, 'mp4', m3u8_id=version, quality=preference))
83 else:
84 formats.append({
85 'url': uri,
86 'format_id': version,
87 'quality': preference,
88 })
87270c84 89
e29e96a9
RA
90 thumbnails = []
91 stills = item.get('stills') or {}
92 for t in ('thumb', 'still'):
93 for s in ('', '-medium', '-large'):
94 still_id = t + s
95 still_url = stills.get(still_id)
96 if not still_url:
97 continue
98 thumbnails.append({
99 'id': still_id,
100 'url': still_url,
101 })
102
103 stats = item.get('stats') or {}
4d5d14f5
JS
104
105 return {
106 'id': video_id,
107 'title': title,
e29e96a9
RA
108 'description': item.get('description'),
109 'thumbnails': thumbnails,
110 'formats': formats,
111 'duration': int_or_none(media.get('duration')),
112 'like_count': int_or_none(stats.get('kudos_total')),
113 'view_count': int_or_none(stats.get('views_total')),
4d5d14f5 114 }