]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/radiobremen.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / radiobremen.py
1 # coding: utf-8
2
3 from __future__ import unicode_literals
4
5 import re
6
7 from .common import InfoExtractor
8 from ..utils import parse_duration
9
10
11 class RadioBremenIE(InfoExtractor):
12 _VALID_URL = r'http?://(?:www\.)?radiobremen\.de/mediathek/(?:index\.html)?\?id=(?P<id>[0-9]+)'
13 IE_NAME = 'radiobremen'
14
15 _TEST = {
16 'url': 'http://www.radiobremen.de/mediathek/?id=141876',
17 'info_dict': {
18 'id': '141876',
19 'ext': 'mp4',
20 'duration': 178,
21 'width': 512,
22 'title': 'Druck auf Patrick Öztürk',
23 'thumbnail': r're:https?://.*\.jpg$',
24 'description': 'Gegen den SPD-Bürgerschaftsabgeordneten Patrick Öztürk wird wegen Beihilfe zum gewerbsmäßigen Betrug ermittelt. Am Donnerstagabend sollte er dem Vorstand des SPD-Unterbezirks Bremerhaven dazu Rede und Antwort stehen.',
25 },
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30
31 meta_url = 'http://www.radiobremen.de/apps/php/mediathek/metadaten.php?id=%s' % video_id
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&auml;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)
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')))
50
51 formats = [{
52 'url': video_url,
53 'ext': 'mp4',
54 'width': int(mobj.group('width')),
55 }]
56 return {
57 'id': video_id,
58 'title': title,
59 'description': description,
60 'duration': duration,
61 'formats': formats,
62 'thumbnail': mobj.group('thumbnail'),
63 }