]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cda.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class CDAIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:(?:www\.)?cda\.pl/video|ebd\.cda\.pl/[0-9]+x[0-9]+)/(?P<id>[0-9a-z]+)'
17 'url': 'http://www.cda.pl/video/5749950c',
18 'md5': '6f844bf51b15f31fae165365707ae970',
23 'title': 'Oto dlaczego przed zakrętem należy zwolnić.',
27 'url': 'http://www.cda.pl/video/57413289',
28 'md5': 'a88828770a8310fc00be6c95faf7f4d5',
32 'title': 'Lądowanie na lotnisku na Maderze',
36 'url': 'http://ebd.cda.pl/0x0/5749950c',
37 'only_matching': True,
40 def _real_extract(self
, url
):
41 video_id
= self
._match
_id
(url
)
42 webpage
= self
._download
_webpage
('http://ebd.cda.pl/0x0/' + video_id
, video_id
)
44 if 'Ten film jest dostępny dla użytkowników premium' in webpage
:
45 raise ExtractorError('This video is only available for premium users.', expected
=True)
47 title
= self
._html
_search
_regex
(r
'<title>(.+?)</title>', webpage
, 'title')
58 def extract_format(page
, version
):
59 unpacked
= decode_packed_codes(page
)
60 format_url
= self
._search
_regex
(
61 r
"(?:file|url)\s*:\s*(\\?[\"'])(?P<url>http.+?)\1", unpacked,
62 '%s url
' % version, fatal=False, group='url
')
69 r'<a
[^
>]+data
-quality
="(?P<format_id>[^"]+)"[^>]+href="[^
"]+"[^
>]+class="[^"]*quality
-btn
-active
[^
"]*">(?P
<height
>[0-9]+)p
',
73 'format_id
': m.group('format_id
'),
74 'height
': int(m.group('height
')),
76 info_dict['formats
'].append(f)
77 if not info_dict['duration
']:
78 info_dict['duration
'] = parse_duration(self._search_regex(
79 r"duration\s*:\s*(\\?[\"'])(?P
<duration
>.+?
)\
1",
80 unpacked, 'duration', fatal=False, group='duration'))
82 extract_format(webpage, 'default')
84 for href, resolution in re.findall(
85 r'<a[^>]+data-quality="[^
"]+"[^
>]+href
="([^"]+)"[^>]+class="quality
-btn
"[^>]*>([0-9]+p)',
87 webpage = self._download_webpage(
88 href, video_id, 'Downloading %s version information' % resolution, fatal=False)
90 # Manually report warning because empty page is returned when
91 # invalid version is requested.
92 self.report_warning('Unable to download %s version information' % resolution)
94 extract_format(webpage, resolution)
96 self._sort_formats(formats)