1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..utils import parse_filesize
10 class TagesschauIE(InfoExtractor):
11 _VALID_URL = r'https?://(?:www\.)?tagesschau\.de/multimedia/(?:[^/]+/)*?[^/#?]+?(?P<id>-?[0-9]+)(?:~_[^/#?]+?)?\.html'
14 'url': 'http://www.tagesschau.de/multimedia/video/video-102143.html',
15 'md5': '917a228bc7df7850783bc47979673a09',
19 'title': 'Regierungsumbildung in Athen: Neue Minister in Griechenland vereidigt',
20 'description': 'md5:171feccd9d9b3dd54d05d501568f6359',
21 'thumbnail': 're:^https?:.*\.jpg$',
24 'url': 'http://www.tagesschau.de/multimedia/sendung/ts-5727.html',
25 'md5': '3c54c1f6243d279b706bde660ceec633',
29 'description': 'md5:695c01bfd98b7e313c501386327aea59',
30 'title': 'Sendung: tagesschau \t04.12.2014 20:00 Uhr',
31 'thumbnail': 're:^https?:.*\.jpg$',
34 'url': 'http://www.tagesschau.de/multimedia/politikimradio/audio-18407.html',
35 'md5': 'aef45de271c4bf0a5db834aa40bf774c',
39 'title': 'Flüchtlingsdebatte: Hitzig, aber wenig hilfreich',
40 'description': 'Flüchtlingsdebatte: Hitzig, aber wenig hilfreich',
41 'thumbnail': 're:^https?:.*\.jpg$',
44 'url': 'http://www.tagesschau.de/multimedia/sendung/tsg-3771.html',
45 'only_matching': True,
47 'url': 'http://www.tagesschau.de/multimedia/sendung/tt-3827.html',
48 'only_matching': True,
50 'url': 'http://www.tagesschau.de/multimedia/sendung/nm-3475.html',
51 'only_matching': True,
53 'url': 'http://www.tagesschau.de/multimedia/sendung/weltspiegel-3167.html',
54 'only_matching': True,
56 'url': 'http://www.tagesschau.de/multimedia/tsvorzwanzig-959.html',
57 'only_matching': True,
59 'url': 'http://www.tagesschau.de/multimedia/sendung/bab/bab-3299~_bab-sendung-209.html',
60 'only_matching': True,
62 'url': 'http://www.tagesschau.de/multimedia/video/video-102303~_bab-sendung-211.html',
63 'only_matching': True,
68 's': {'width': 320, 'height': 180, 'quality': 1},
69 'm': {'width': 512, 'height': 288, 'quality': 2},
70 'l': {'width': 960, 'height': 540, 'quality': 3},
71 'xl': {'width': 1280, 'height': 720, 'quality': 4},
72 'xxl': {'quality': 5},
75 def _real_extract(self, url):
76 video_id = self._match_id(url)
77 display_id = video_id.lstrip('-')
78 webpage = self._download_webpage(url, display_id)
80 player_url = self._html_search_meta(
81 'twitter:player', webpage, 'player URL', default=None)
83 playerpage = self._download_webpage(
84 player_url, display_id, 'Downloading player page')
87 for media in re.finditer(
89 (?P<q_url>["\'])(?P<url>http://media.+?)(?P=q_url)
90 ,\s*type:(?P<q_type>["\'])(?P<type>video|audio)/(?P<ext>.+?)(?P=q_type)
91 (?:,\s*quality:(?P<q_quality>["\'])(?P<quality>.+?)(?P=q_quality))?
93 url = media.group('url')
94 type_ = media.group('type')
95 ext = media.group('ext')
96 res = media.group('quality')
98 'format_id': '%s_%s' % (res, ext) if res else ext,
101 'vcodec': 'none' if type_ == 'audio' else None,
103 f.update(self._FORMATS.get(res, {}))
105 thumbnail = self._og_search_thumbnail(playerpage)
106 title = self._og_search_title(webpage).strip()
107 description = self._og_search_description(webpage).strip()
109 download_text = self._search_regex(
110 r'(?s)<p>Wir bieten dieses Video in folgenden Formaten zum Download an:</p>\s*<div class="controls">(.*?)</div>\s*<p>',
111 webpage, 'download links')
113 r'<div class="button" title="(?P<title>[^"]*)"><a href="(?P<url>[^"]+)">(?P<name>.+?)</a></div>',
117 format_id = self._search_regex(
118 r'.*/[^/.]+\.([^/]+)\.[^/.]+', l.group('url'), 'format ID')
120 'format_id': format_id,
121 'url': l.group('url'),
122 'format_name': l.group('name'),
126 Video:\s*(?P<vcodec>[a-zA-Z0-9/._-]+)\s*&\#10;
127 (?P<width>[0-9]+)x(?P<height>[0-9]+)px&\#10;
128 (?P<vbr>[0-9]+)kbps&\#10;
129 Audio:\s*(?P<abr>[0-9]+)kbps,\s*(?P<audio_desc>[A-Za-z\.0-9]+)&\#10;
130 Größe:\s*(?P<filesize_approx>[0-9.,]+\s+[a-zA-Z]*B)''',
134 'format_note': m.group('audio_desc'),
135 'vcodec': m.group('vcodec'),
136 'width': int(m.group('width')),
137 'height': int(m.group('height')),
138 'abr': int(m.group('abr')),
139 'vbr': int(m.group('vbr')),
140 'filesize_approx': parse_filesize(m.group('filesize_approx')),
142 formats.append(format)
143 thumbnail = self._og_search_thumbnail(webpage)
144 description = self._html_search_regex(
145 r'(?s)<p class="teasertext">(.*?)</p>',
146 webpage, 'description', default=None)
147 title = self._html_search_regex(
148 r'<span class="headline".*?>(.*?)</span>', webpage, 'title')
150 self._sort_formats(formats)
155 'thumbnail': thumbnail,
157 'description': description,