]>
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|ebd)\.)?cda\.pl/(?:video|[0-9]+x[0-9]+)/(?P<id>[0-9a-z]+)'
18 'url': 'http://www.cda.pl/video/5749950c',
19 'md5': '6f844bf51b15f31fae165365707ae970',
24 'title': 'Oto dlaczego przed zakrętem należy zwolnić.',
29 'url': 'http://www.cda.pl/video/57413289',
30 'md5': 'a88828770a8310fc00be6c95faf7f4d5',
34 'title': 'Lądowanie na lotnisku na Maderze',
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', fatal
=False)
49 def _get_format(page
, version
=''):
50 unpacked
= decode_packed_codes(page
)
51 duration
= self
._search
_regex
(r
"duration:\\'(.+?)\\'", unpacked
, 'duration', fatal
=False)
55 m
= re
.search(r
'<a data-quality="(?P<format_id>[^"]+)" href="[^"]+" class="quality-btn quality-btn-active">(?P<height>[0-9]+)p<\/a>', page
)
57 format_id
= m
.group('format_id')
58 height
= int(m
.group('height'))
60 url
= self
._search
_regex
(r
"url:\\'(.+?)\\'", unpacked
, version
+ ' url', fatal
=False)
65 'format_id': format_id
,
68 }, parse_duration(duration
)
72 format_desc
, duration
= _get_format(webpage
) or (None, None)
73 if format_desc
is not None:
74 formats
.append(format_desc
)
76 pattern
= re
.compile(r
'<a data-quality="[^"]+" href="([^"]+)" class="quality-btn">([0-9]+p)<\/a>')
77 for version
in re
.findall(pattern
, webpage
):
78 webpage
= self
._download
_webpage
(version
[0], video_id
, 'Downloading %s version information' % version
[1], fatal
=False)
80 # Manually report warning because empty page is returned when invalid version is requested.
81 self
.report_warning('Unable to download %s version information' % version
[1])
84 format_desc
, duration_
= _get_format(webpage
, version
[1]) or (None, None)
85 duration
= duration
or duration_
86 if format_desc
is not None:
87 formats
.append(format_desc
)
89 self
._sort
_formats
(formats
)