]>
jfr.im git - yt-dlp.git/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
"url:\\'(.+?)\\'", unpacked
, '%s url' % version
, fatal
=False)
68 r
'<a[^>]+data-quality="(?P<format_id>[^"]+)"[^>]+href="[^"]+"[^>]+class="[^"]*quality-btn-active[^"]*">(?P<height>[0-9]+)p',
72 'format_id': m
.group('format_id'),
73 'height': int(m
.group('height')),
75 info_dict
['formats'].append(f
)
76 if not info_dict
['duration']:
77 info_dict
['duration'] = parse_duration(self
._search
_regex
(
78 r
"duration:\\'(.+?)\\'", unpacked
, 'duration', fatal
=False))
80 extract_format(webpage
, 'default')
82 for href
, resolution
in re
.findall(
83 r
'<a[^>]+data-quality="[^"]+"[^>]+href="([^"]+)"[^>]+class="quality-btn"[^>]*>([0-9]+p)',
85 webpage
= self
._download
_webpage
(
86 href
, video_id
, 'Downloading %s version information' % resolution
, fatal
=False)
88 # Manually report warning because empty page is returned when
89 # invalid version is requested.
90 self
.report_warning('Unable to download %s version information' % resolution
)
92 extract_format(webpage
, resolution
)
94 self
._sort
_formats
(formats
)