]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/dumpert.py
010c2d092db6521796c046d5088e2e698094ec7f
[yt-dlp.git] / yt_dlp / extractor / dumpert.py
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 qualities,
5 )
6
7
8 class DumpertIE(InfoExtractor):
9 _VALID_URL = r'(?P<protocol>https?)://(?:(?:www|legacy)\.)?dumpert\.nl/(?:mediabase|embed|item)/(?P<id>[0-9]+[/_][0-9a-zA-Z]+)'
10 _TESTS = [{
11 'url': 'https://www.dumpert.nl/item/6646981_951bc60f',
12 'md5': '1b9318d7d5054e7dcb9dc7654f21d643',
13 'info_dict': {
14 'id': '6646981/951bc60f',
15 'ext': 'mp4',
16 'title': 'Ik heb nieuws voor je',
17 'description': 'Niet schrikken hoor',
18 'thumbnail': r're:^https?://.*\.jpg$',
19 }
20 }, {
21 'url': 'https://www.dumpert.nl/embed/6675421_dc440fe7',
22 'only_matching': True,
23 }, {
24 'url': 'http://legacy.dumpert.nl/mediabase/6646981/951bc60f',
25 'only_matching': True,
26 }, {
27 'url': 'http://legacy.dumpert.nl/embed/6675421/dc440fe7',
28 'only_matching': True,
29 }]
30
31 def _real_extract(self, url):
32 video_id = self._match_id(url).replace('_', '/')
33 item = self._download_json(
34 'http://api-live.dumpert.nl/mobile_api/json/info/' + video_id.replace('/', '_'),
35 video_id)['items'][0]
36 title = item['title']
37 media = next(m for m in item['media'] if m.get('mediatype') == 'VIDEO')
38
39 quality = qualities(['flv', 'mobile', 'tablet', '720p'])
40 formats = []
41 for variant in media.get('variants', []):
42 uri = variant.get('uri')
43 if not uri:
44 continue
45 version = variant.get('version')
46 formats.append({
47 'url': uri,
48 'format_id': version,
49 'quality': quality(version),
50 })
51
52 thumbnails = []
53 stills = item.get('stills') or {}
54 for t in ('thumb', 'still'):
55 for s in ('', '-medium', '-large'):
56 still_id = t + s
57 still_url = stills.get(still_id)
58 if not still_url:
59 continue
60 thumbnails.append({
61 'id': still_id,
62 'url': still_url,
63 })
64
65 stats = item.get('stats') or {}
66
67 return {
68 'id': video_id,
69 'title': title,
70 'description': item.get('description'),
71 'thumbnails': thumbnails,
72 'formats': formats,
73 'duration': int_or_none(media.get('duration')),
74 'like_count': int_or_none(stats.get('kudos_total')),
75 'view_count': int_or_none(stats.get('views_total')),
76 }