2014-06-05 16:48:03 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2015-07-22 21:23:38 +00:00
|
|
|
from ..utils import parse_filesize
|
2014-06-05 16:48:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TagesschauIE(InfoExtractor):
|
2015-07-22 18:30:48 +00:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?tagesschau\.de/multimedia/(?:[^/]+/)*?[^/#?]+?(?P<id>-?[0-9]+)(?:~_[^/#?]+?)?\.html'
|
2014-06-05 16:48:03 +00:00
|
|
|
|
|
|
|
_TESTS = [{
|
2015-07-19 01:52:54 +00:00
|
|
|
'url': 'http://www.tagesschau.de/multimedia/video/video-102143.html',
|
|
|
|
'md5': '917a228bc7df7850783bc47979673a09',
|
2014-06-05 16:48:03 +00:00
|
|
|
'info_dict': {
|
2015-07-19 01:52:54 +00:00
|
|
|
'id': '102143',
|
2014-06-05 16:48:03 +00:00
|
|
|
'ext': 'mp4',
|
2015-07-19 01:52:54 +00:00
|
|
|
'title': 'Regierungsumbildung in Athen: Neue Minister in Griechenland vereidigt',
|
|
|
|
'description': 'md5:171feccd9d9b3dd54d05d501568f6359',
|
2015-07-22 19:01:35 +00:00
|
|
|
'thumbnail': 're:^https?:.*\.jpg$',
|
2014-06-05 16:48:03 +00:00
|
|
|
},
|
2014-12-05 23:42:39 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/ts-5727.html',
|
|
|
|
'md5': '3c54c1f6243d279b706bde660ceec633',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '5727',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'description': 'md5:695c01bfd98b7e313c501386327aea59',
|
|
|
|
'title': 'Sendung: tagesschau \t04.12.2014 20:00 Uhr',
|
2015-07-22 19:01:35 +00:00
|
|
|
'thumbnail': 're:^https?:.*\.jpg$',
|
2015-07-22 18:30:48 +00:00
|
|
|
},
|
2015-07-22 19:01:04 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/politikimradio/audio-18407.html',
|
|
|
|
'md5': 'aef45de271c4bf0a5db834aa40bf774c',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '18407',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': 'Flüchtlingsdebatte: Hitzig, aber wenig hilfreich',
|
|
|
|
'description': 'Flüchtlingsdebatte: Hitzig, aber wenig hilfreich',
|
|
|
|
'thumbnail': 're:^https?:.*\.jpg$',
|
|
|
|
},
|
2015-07-19 01:34:22 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/tsg-3771.html',
|
2015-07-22 18:30:48 +00:00
|
|
|
'only_matching': True,
|
2015-07-19 01:34:22 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/tt-3827.html',
|
2015-07-22 18:30:48 +00:00
|
|
|
'only_matching': True,
|
2015-07-19 01:34:22 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/nm-3475.html',
|
2015-07-22 18:30:48 +00:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/weltspiegel-3167.html',
|
|
|
|
'only_matching': True,
|
2015-07-19 01:34:22 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/tsvorzwanzig-959.html',
|
2015-07-22 18:30:48 +00:00
|
|
|
'only_matching': True,
|
2015-07-19 02:27:58 +00:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/sendung/bab/bab-3299~_bab-sendung-209.html',
|
2015-07-22 18:30:48 +00:00
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.tagesschau.de/multimedia/video/video-102303~_bab-sendung-211.html',
|
|
|
|
'only_matching': True,
|
2014-06-07 13:14:20 +00:00
|
|
|
}]
|
|
|
|
|
|
|
|
_FORMATS = {
|
|
|
|
's': {'width': 256, 'height': 144, 'quality': 1},
|
|
|
|
'm': {'width': 512, 'height': 288, 'quality': 2},
|
|
|
|
'l': {'width': 960, 'height': 544, 'quality': 3},
|
|
|
|
}
|
2014-06-05 16:48:03 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-12-05 09:59:55 +00:00
|
|
|
video_id = self._match_id(url)
|
|
|
|
display_id = video_id.lstrip('-')
|
2014-06-05 16:48:03 +00:00
|
|
|
webpage = self._download_webpage(url, display_id)
|
|
|
|
|
2014-12-05 23:42:39 +00:00
|
|
|
player_url = self._html_search_meta(
|
|
|
|
'twitter:player', webpage, 'player URL', default=None)
|
|
|
|
if player_url:
|
|
|
|
playerpage = self._download_webpage(
|
|
|
|
player_url, display_id, 'Downloading player page')
|
2014-06-05 16:48:03 +00:00
|
|
|
|
2014-12-05 23:42:39 +00:00
|
|
|
formats = []
|
2015-07-22 19:01:04 +00:00
|
|
|
for media in re.finditer(
|
|
|
|
r'''(?x)
|
|
|
|
(?P<q_url>["\'])(?P<url>http://media.+?)(?P=q_url)
|
|
|
|
,\s*type:(?P<q_type>["\'])(?P<type>video|audio)/(?P<ext>.+?)(?P=q_type)
|
|
|
|
(?:,\s*quality:(?P<q_quality>["\'])(?P<quality>.+?)(?P=q_quality))?
|
|
|
|
''', playerpage):
|
|
|
|
url = media.group('url')
|
|
|
|
type_ = media.group('type')
|
|
|
|
ext = media.group('ext')
|
|
|
|
res = media.group('quality')
|
2014-12-05 23:42:39 +00:00
|
|
|
f = {
|
2015-07-22 19:01:04 +00:00
|
|
|
'format_id': '%s_%s' % (res, ext) if res else ext,
|
2014-12-05 23:42:39 +00:00
|
|
|
'url': url,
|
|
|
|
'ext': ext,
|
2015-07-22 19:01:04 +00:00
|
|
|
'vcodec': 'none' if type_ == 'audio' else None,
|
2014-12-05 23:42:39 +00:00
|
|
|
}
|
|
|
|
f.update(self._FORMATS.get(res, {}))
|
|
|
|
formats.append(f)
|
2015-07-22 19:01:04 +00:00
|
|
|
thumbnail = self._og_search_thumbnail(playerpage)
|
2014-12-05 23:42:39 +00:00
|
|
|
title = self._og_search_title(webpage).strip()
|
|
|
|
description = self._og_search_description(webpage).strip()
|
|
|
|
else:
|
|
|
|
download_text = self._search_regex(
|
|
|
|
r'(?s)<p>Wir bieten dieses Video in folgenden Formaten zum Download an:</p>\s*<div class="controls">(.*?)</div>\s*<p>',
|
|
|
|
webpage, 'download links')
|
|
|
|
links = re.finditer(
|
|
|
|
r'<div class="button" title="(?P<title>[^"]*)"><a href="(?P<url>[^"]+)">(?P<name>.+?)</a></div>',
|
2014-12-06 12:59:10 +00:00
|
|
|
download_text)
|
2014-12-05 23:42:39 +00:00
|
|
|
formats = []
|
|
|
|
for l in links:
|
|
|
|
format_id = self._search_regex(
|
|
|
|
r'.*/[^/.]+\.([^/]+)\.[^/.]+', l.group('url'), 'format ID')
|
|
|
|
format = {
|
|
|
|
'format_id': format_id,
|
|
|
|
'url': l.group('url'),
|
|
|
|
'format_name': l.group('name'),
|
|
|
|
}
|
|
|
|
m = re.match(
|
|
|
|
r'''(?x)
|
|
|
|
Video:\s*(?P<vcodec>[a-zA-Z0-9/._-]+)\s*&\#10;
|
|
|
|
(?P<width>[0-9]+)x(?P<height>[0-9]+)px&\#10;
|
|
|
|
(?P<vbr>[0-9]+)kbps&\#10;
|
|
|
|
Audio:\s*(?P<abr>[0-9]+)kbps,\s*(?P<audio_desc>[A-Za-z\.0-9]+)&\#10;
|
|
|
|
Größe:\s*(?P<filesize_approx>[0-9.,]+\s+[a-zA-Z]*B)''',
|
|
|
|
l.group('title'))
|
|
|
|
if m:
|
|
|
|
format.update({
|
|
|
|
'format_note': m.group('audio_desc'),
|
|
|
|
'vcodec': m.group('vcodec'),
|
|
|
|
'width': int(m.group('width')),
|
|
|
|
'height': int(m.group('height')),
|
|
|
|
'abr': int(m.group('abr')),
|
|
|
|
'vbr': int(m.group('vbr')),
|
|
|
|
'filesize_approx': parse_filesize(m.group('filesize_approx')),
|
|
|
|
})
|
|
|
|
formats.append(format)
|
2015-07-22 19:01:04 +00:00
|
|
|
thumbnail = self._og_search_thumbnail(webpage)
|
2014-12-05 23:42:39 +00:00
|
|
|
description = self._html_search_regex(
|
|
|
|
r'(?s)<p class="teasertext">(.*?)</p>',
|
2015-07-22 18:30:48 +00:00
|
|
|
webpage, 'description', default=None)
|
2014-12-05 23:42:39 +00:00
|
|
|
title = self._html_search_regex(
|
|
|
|
r'<span class="headline".*?>(.*?)</span>', webpage, 'title')
|
2014-06-05 16:48:03 +00:00
|
|
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': display_id,
|
2014-12-05 23:42:39 +00:00
|
|
|
'title': title,
|
|
|
|
'thumbnail': thumbnail,
|
2014-06-05 16:48:03 +00:00
|
|
|
'formats': formats,
|
2014-12-05 23:42:39 +00:00
|
|
|
'description': description,
|
2014-06-05 16:48:03 +00:00
|
|
|
}
|