2 from __future__ import unicode_literals
7 from .common import InfoExtractor
8 from ..compat import compat_urllib_request
9 from ..utils import qualities
12 class DumpertIE(InfoExtractor):
13 _VALID_URL = r'(?P<protocol>https?)://(?:www\.)?dumpert\.nl/(?:mediabase|embed)/(?P<id>[0-9]+/[0-9a-zA-Z]+)'
15 'url': 'http://www.dumpert.nl/mediabase/6646981/951bc60f/',
16 'md5': '1b9318d7d5054e7dcb9dc7654f21d643',
18 'id': '6646981/951bc60f',
20 'title': 'Ik heb nieuws voor je',
21 'description': 'Niet schrikken hoor',
22 'thumbnail': 're:^https?://.*\.jpg$',
25 'url': 'http://www.dumpert.nl/embed/6675421/dc440fe7/',
26 'only_matching': True,
29 def _real_extract(self, url):
30 mobj = re.match(self._VALID_URL, url)
31 video_id = mobj.group('id')
32 protocol = mobj.group('protocol')
34 url = '%s://www.dumpert.nl/mediabase/%s' % (protocol, video_id)
35 req = compat_urllib_request.Request(url)
36 req.add_header('Cookie', 'nsfw=1; cpc=10')
37 webpage = self._download_webpage(req, video_id)
39 files_base64 = self._search_regex(
40 r'data-files="([^"]+)"', webpage, 'data files')
42 files = self._parse_json(
43 base64.b64decode(files_base64.encode('utf-8')).decode('utf-8'),
46 quality = qualities(['flv', 'mobile', 'tablet', '720p'])
50 'format_id': format_id,
51 'quality': quality(format_id),
52 } for format_id, video_url in files.items() if format_id != 'still']
53 self._sort_formats(formats)
55 title = self._html_search_meta(
56 'title', webpage) or self._og_search_title(webpage)
57 description = self._html_search_meta(
58 'description', webpage) or self._og_search_description(webpage)
59 thumbnail = files.get('still') or self._og_search_thumbnail(webpage)
64 'description': description,
65 'thumbnail': thumbnail,