]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/dumpert.py
[SpankBang] Use python2.6 compatible string formatting spec
[youtube-dl] / youtube_dl / extractor / dumpert.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import base64
5
6 from .common import InfoExtractor
7 from ..utils import qualities
8
9
10 class DumpertIE(InfoExtractor):
11     _VALID_URL = r'https?://(?:www\.)?dumpert\.nl/mediabase/(?P<id>[0-9]+/[0-9a-zA-Z]+)'
12     _TEST = {
13         'url': 'http://www.dumpert.nl/mediabase/6646981/951bc60f/',
14         'md5': '1b9318d7d5054e7dcb9dc7654f21d643',
15         'info_dict': {
16             'id': '6646981/951bc60f',
17             'ext': 'mp4',
18             'title': 'Ik heb nieuws voor je',
19             'description': 'Niet schrikken hoor',
20             'thumbnail': 're:^https?://.*\.jpg$',
21         }
22     }
23
24     def _real_extract(self, url):
25         video_id = self._match_id(url)
26         webpage = self._download_webpage(url, video_id)
27
28         files_base64 = self._search_regex(
29             r'data-files="([^"]+)"', webpage, 'data files')
30
31         files = self._parse_json(
32             base64.b64decode(files_base64.encode('utf-8')).decode('utf-8'),
33             video_id)
34
35         quality = qualities(['flv', 'mobile', 'tablet', '720p'])
36
37         formats = [{
38             'url': video_url,
39             'format_id': format_id,
40             'quality': quality(format_id),
41         } for format_id, video_url in files.items() if format_id != 'still']
42         self._sort_formats(formats)
43
44         title = self._html_search_meta(
45             'title', webpage) or self._og_search_title(webpage)
46         description = self._html_search_meta(
47             'description', webpage) or self._og_search_description(webpage)
48         thumbnail = files.get('still') or self._og_search_thumbnail(webpage)
49
50         return {
51             'id': video_id,
52             'title': title,
53             'description': description,
54             'thumbnail': thumbnail,
55             'formats': formats
56         }