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