]>
Commit | Line | Data |
---|---|---|
f4858a71 CK |
1 | # -*- coding: utf-8 -*- |
2 | ||
3 | from __future__ import unicode_literals | |
4 | ||
5 | import re | |
6 | ||
7 | from .common import InfoExtractor | |
9d247bbd | 8 | from ..utils import parse_duration |
f4858a71 CK |
9 | |
10 | ||
11 | class RadioBremenIE(InfoExtractor): | |
9d247bbd | 12 | _VALID_URL = r'http?://(?:www\.)?radiobremen\.de/mediathek/(?:index\.html)?\?id=(?P<id>[0-9]+)' |
f4858a71 CK |
13 | IE_NAME = 'radiobremen' |
14 | ||
15 | _TEST = { | |
16 | 'url': 'http://www.radiobremen.de/mediathek/index.html?id=114720', | |
17 | 'info_dict': { | |
18 | 'id': '114720', | |
19 | 'ext': 'mp4', | |
9d247bbd | 20 | 'duration': 1685, |
f4858a71 CK |
21 | 'width': 512, |
22 | 'title': 'buten un binnen vom 22. Dezember', | |
aa80652f | 23 | 'thumbnail': 're:https?://.*\.jpg$', |
f4858a71 CK |
24 | 'description': 'Unter anderem mit diesen Themen: 45 Flüchtlinge sind in Worpswede angekommen +++ Freies Internet für alle: Bremer arbeiten an einem flächendeckenden W-Lan-Netzwerk +++ Aktivisten kämpfen für das Unibad +++ So war das Wetter 2014 +++', |
25 | }, | |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
9d247bbd | 29 | video_id = self._match_id(url) |
f4858a71 CK |
30 | |
31 | meta_url = "http://www.radiobremen.de/apps/php/mediathek/metadaten.php?id=%s" % video_id | |
dda620e8 PH |
32 | meta_doc = self._download_webpage( |
33 | meta_url, video_id, 'Downloading metadata') | |
34 | title = self._html_search_regex( | |
35 | r"<h1.*>(?P<title>.+)</h1>", meta_doc, "title") | |
36 | description = self._html_search_regex( | |
37 | r"<p>(?P<description>.*)</p>", meta_doc, "description", fatal=False) | |
38 | duration = parse_duration(self._html_search_regex( | |
39 | r"Länge:</td>\s+<td>(?P<duration>[0-9]+:[0-9]+)</td>", | |
40 | meta_doc, "duration", fatal=False)) | |
41 | ||
42 | page_doc = self._download_webpage( | |
43 | url, video_id, 'Downloading video information') | |
44 | mobj = re.search( | |
45 | r"ardformatplayerclassic\(\'playerbereich\',\'(?P<width>[0-9]+)\',\'.*\',\'(?P<video_id>[0-9]+)\',\'(?P<secret>[0-9]+)\',\'(?P<thumbnail>.+)\',\'\'\)", | |
46 | page_doc) | |
9d247bbd PH |
47 | video_url = ( |
48 | "http://dl-ondemand.radiobremen.de/mediabase/%s/%s_%s_%s.mp4" % | |
49 | (video_id, video_id, mobj.group("secret"), mobj.group('width'))) | |
f4858a71 | 50 | |
9d247bbd PH |
51 | formats = [{ |
52 | 'url': video_url, | |
53 | 'ext': 'mp4', | |
54 | 'width': int(mobj.group("width")), | |
55 | }] | |
f4858a71 CK |
56 | return { |
57 | 'id': video_id, | |
58 | 'title': title, | |
59 | 'description': description, | |
60 | 'duration': duration, | |
9d247bbd PH |
61 | 'formats': formats, |
62 | 'thumbnail': mobj.group('thumbnail'), | |
f4858a71 | 63 | } |