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