]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/zdf.py
3 from .common
import InfoExtractor
10 class ZDFIE(InfoExtractor
):
11 _VALID_URL
= r
'^http://www\.zdf\.de\/ZDFmediathek(?P<hash>#)?\/(.*beitrag\/video\/)(?P<video_id>[^/\?]+)(?:\?.*)?'
12 _MEDIA_STREAM
= r
'<a href="(?P<video_url>.+(?P<media_type>.streaming).+/zdf/(?P<quality>[^\/]+)/[^"]*)".+class="play".+>'
14 def _real_extract(self
, url
):
15 mobj
= re
.match(self
._VALID
_URL
, url
)
17 raise ExtractorError(u
'Invalid URL: %s' % url
)
18 video_id
= mobj
.group('video_id')
20 if mobj
.group('hash'):
21 url
= url
.replace(u
'#', u
'', 1)
23 html
= self
._download
_webpage
(url
, video_id
)
24 streams
= [m
.groupdict() for m
in re
.finditer(self
._MEDIA
_STREAM
, html
)]
26 raise ExtractorError(u
'No media url found.')
28 # s['media_type'] == 'wstreaming' -> use 'Windows Media Player' and mms url
29 # s['media_type'] == 'hstreaming' -> use 'Quicktime' and rtsp url
30 # choose first/default media type and highest quality for now
32 TYPE_ORDER
= ['ostreaming', 'hstreaming', 'wstreaming']
34 type_pref
= TYPE_ORDER
.index(s
['media_type'])
38 QUALITY_ORDER
= ['veryhigh', '300']
40 quality_pref
= QUALITY_ORDER
.index(s
['quality'])
44 return (type_pref
, quality_pref
)
46 sorted_streams
= sorted(streams
, key
=stream_pref
)
47 if not sorted_streams
:
48 raise ExtractorError(u
'No stream found.')
49 stream
= sorted_streams
[0]
51 media_link
= self
._download
_webpage
(
56 #MMS_STREAM = r'href="(?P<video_url>mms://[^"]*)"'
57 RTSP_STREAM
= r
'(?P<video_url>rtsp://[^"]*.mp4)'
59 mobj
= re
.search(self
._MEDIA
_STREAM
, media_link
)
61 mobj
= re
.search(RTSP_STREAM
, media_link
)
63 raise ExtractorError(u
'Cannot extract mms:// or rtsp:// URL')
64 video_url
= mobj
.group('video_url')
66 title
= self
._html
_search
_regex
(
67 r
'<h1(?: class="beitragHeadline")?>(.*?)</h1>',
74 'ext': determine_ext(video_url
)