]>
Commit | Line | Data |
---|---|---|
4d5d14f5 | 1 | from .common import InfoExtractor |
5c2266df | 2 | from ..utils import ( |
e29e96a9 | 3 | int_or_none, |
5c2266df | 4 | qualities, |
5c2266df | 5 | ) |
4d5d14f5 JS |
6 | |
7 | ||
8 | class DumpertIE(InfoExtractor): | |
e29e96a9 | 9 | _VALID_URL = r'(?P<protocol>https?)://(?:(?:www|legacy)\.)?dumpert\.nl/(?:mediabase|embed|item)/(?P<id>[0-9]+[/_][0-9a-zA-Z]+)' |
aa3f9867 | 10 | _TESTS = [{ |
e29e96a9 | 11 | 'url': 'https://www.dumpert.nl/item/6646981_951bc60f', |
4d5d14f5 JS |
12 | 'md5': '1b9318d7d5054e7dcb9dc7654f21d643', |
13 | 'info_dict': { | |
14 | 'id': '6646981/951bc60f', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'Ik heb nieuws voor je', | |
87270c84 | 17 | 'description': 'Niet schrikken hoor', |
ec85ded8 | 18 | 'thumbnail': r're:^https?://.*\.jpg$', |
4d5d14f5 | 19 | } |
aa3f9867 | 20 | }, { |
e29e96a9 RA |
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', | |
aa3f9867 JMF |
28 | 'only_matching': True, |
29 | }] | |
4d5d14f5 JS |
30 | |
31 | def _real_extract(self, url): | |
e29e96a9 RA |
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') | |
4d5d14f5 | 38 | |
87270c84 | 39 | quality = qualities(['flv', 'mobile', 'tablet', '720p']) |
e29e96a9 RA |
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 | }) | |
87270c84 | 51 | |
e29e96a9 RA |
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 {} | |
4d5d14f5 JS |
66 | |
67 | return { | |
68 | 'id': video_id, | |
69 | 'title': title, | |
e29e96a9 RA |
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')), | |
4d5d14f5 | 76 | } |