]>
Commit | Line | Data |
---|---|---|
4d5d14f5 JS |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import base64 | |
5 | ||
6 | from .common import InfoExtractor | |
aa2af7ba | 7 | from ..compat import compat_urllib_request |
87270c84 | 8 | from ..utils import qualities |
4d5d14f5 JS |
9 | |
10 | ||
11 | class DumpertIE(InfoExtractor): | |
aa3f9867 JMF |
12 | _VALID_URL = r'https?://(?:www\.)?dumpert\.nl/(?:mediabase|embed)/(?P<id>[0-9]+/[0-9a-zA-Z]+)' |
13 | _TESTS = [{ | |
4d5d14f5 JS |
14 | 'url': 'http://www.dumpert.nl/mediabase/6646981/951bc60f/', |
15 | 'md5': '1b9318d7d5054e7dcb9dc7654f21d643', | |
16 | 'info_dict': { | |
17 | 'id': '6646981/951bc60f', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Ik heb nieuws voor je', | |
87270c84 S |
20 | 'description': 'Niet schrikken hoor', |
21 | 'thumbnail': 're:^https?://.*\.jpg$', | |
4d5d14f5 | 22 | } |
aa3f9867 JMF |
23 | }, { |
24 | 'url': 'http://www.dumpert.nl/embed/6675421/dc440fe7/', | |
25 | 'only_matching': True, | |
26 | }] | |
4d5d14f5 JS |
27 | |
28 | def _real_extract(self, url): | |
29 | video_id = self._match_id(url) | |
aa2af7ba | 30 | |
aa3f9867 | 31 | url = 'https://www.dumpert.nl/mediabase/' + video_id |
aa2af7ba | 32 | req = compat_urllib_request.Request(url) |
1f928654 | 33 | req.add_header('Cookie', 'nsfw=1; cpc=10') |
aa2af7ba | 34 | webpage = self._download_webpage(req, video_id) |
4d5d14f5 | 35 | |
87270c84 S |
36 | files_base64 = self._search_regex( |
37 | r'data-files="([^"]+)"', webpage, 'data files') | |
4d5d14f5 | 38 | |
87270c84 S |
39 | files = self._parse_json( |
40 | base64.b64decode(files_base64.encode('utf-8')).decode('utf-8'), | |
41 | video_id) | |
4d5d14f5 | 42 | |
87270c84 S |
43 | quality = qualities(['flv', 'mobile', 'tablet', '720p']) |
44 | ||
45 | formats = [{ | |
46 | 'url': video_url, | |
47 | 'format_id': format_id, | |
48 | 'quality': quality(format_id), | |
49 | } for format_id, video_url in files.items() if format_id != 'still'] | |
50 | self._sort_formats(formats) | |
51 | ||
52 | title = self._html_search_meta( | |
53 | 'title', webpage) or self._og_search_title(webpage) | |
54 | description = self._html_search_meta( | |
55 | 'description', webpage) or self._og_search_description(webpage) | |
56 | thumbnail = files.get('still') or self._og_search_thumbnail(webpage) | |
4d5d14f5 JS |
57 | |
58 | return { | |
59 | 'id': video_id, | |
60 | 'title': title, | |
61 | 'description': description, | |
87270c84 | 62 | 'thumbnail': thumbnail, |
4d5d14f5 JS |
63 | 'formats': formats |
64 | } |