]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/zdf.py
418509cb96df7822b6120909fa440e2186c677c4
3 from .common
import InfoExtractor
9 class ZDFIE(InfoExtractor
):
10 _VALID_URL
= r
'^http://www\.zdf\.de\/ZDFmediathek\/(.*beitrag\/video\/)(?P<video_id>[^/\?]+)(?:\?.*)?'
11 _TITLE
= r
'<h1(?: class="beitragHeadline")?>(?P<title>.*)</h1>'
12 _MEDIA_STREAM
= r
'<a href="(?P<video_url>.+(?P<media_type>.streaming).+/zdf/(?P<quality>[^\/]+)/[^"]*)".+class="play".+>'
13 _MMS_STREAM
= r
'href="(?P<video_url>mms://[^"]*)"'
14 _RTSP_STREAM
= r
'(?P<video_url>rtsp://[^"]*.mp4)'
16 def _real_extract(self
, url
):
17 mobj
= re
.match(self
._VALID
_URL
, url
)
19 raise ExtractorError(u
'Invalid URL: %s' % url
)
20 video_id
= mobj
.group('video_id')
22 html
= self
._download
_webpage
(url
, video_id
)
23 streams
= [m
.groupdict() for m
in re
.finditer(self
._MEDIA
_STREAM
, html
)]
25 raise ExtractorError(u
'No media url found.')
27 # s['media_type'] == 'wstreaming' -> use 'Windows Media Player' and mms url
28 # s['media_type'] == 'hstreaming' -> use 'Quicktime' and rtsp url
29 # choose first/default media type and highest quality for now
30 for s
in streams
: #find 300 - dsl1000mbit
31 if s
['quality'] == '300' and s
['media_type'] == 'wstreaming':
34 for s
in streams
: #find veryhigh - dsl2000mbit
35 if s
['quality'] == 'veryhigh' and s
['media_type'] == 'wstreaming': # 'hstreaming' - rtsp is not working
39 raise ExtractorError(u
'No stream found.')
41 media_link
= self
._download
_webpage
(stream_
['video_url'], video_id
,'Get stream URL')
43 self
.report_extraction(video_id
)
44 mobj
= re
.search(self
._TITLE
, html
)
46 raise ExtractorError(u
'Cannot extract title')
47 title
= unescapeHTML(mobj
.group('title'))
49 mobj
= re
.search(self
._MMS
_STREAM
, media_link
)
51 mobj
= re
.search(self
._RTSP
_STREAM
, media_link
)
53 raise ExtractorError(u
'Cannot extract mms:// or rtsp:// URL')
54 mms_url
= mobj
.group('video_url')
56 mobj
= re
.search('(.*)[.](?P<ext>[^.]+)', mms_url
)
58 raise ExtractorError(u
'Cannot extract extention')
59 ext
= mobj
.group('ext')
61 return [{'id': video_id
,