1 # -*- coding: utf-8 -*-
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import parse_filesize
, ExtractorError
10 class TagesschauIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?tagesschau\.de/multimedia/(?:sendung/(ts|tsg|tt|nm)|video/video|tsvorzwanzig)(?P<id>-?[0-9]+)\.html'
14 'url': 'http://www.tagesschau.de/multimedia/video/video1399128.html',
15 'md5': 'bcdeac2194fb296d599ce7929dfa4009',
19 'title': 'Harald Range, Generalbundesanwalt, zu den Ermittlungen',
20 'description': 'md5:69da3c61275b426426d711bde96463ab',
21 'thumbnail': 're:^http:.*\.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:^http:.*\.jpg$',
34 'url': 'http://www.tagesschau.de/multimedia/sendung/tsg-3771.html',
35 'md5': '90757268b49ef56deae90c7b48928d58',
40 'title': 'Sendung: tagesschau (mit Gebärdensprache) \t14.07.2015 20:00 Uhr',
41 'thumbnail': 're:^http:.*\.jpg$',
44 'url': 'http://www.tagesschau.de/multimedia/sendung/tt-3827.html',
45 'md5': '6e3ebdc75e8d67da966a8d06721eda71',
49 'description': 'md5:d511d0e278b0ad341a95ad9ab992ce66',
50 'title': 'Sendung: tagesthemen \t14.07.2015 22:15 Uhr',
51 'thumbnail': 're:^http:.*\.jpg$',
54 'url': 'http://www.tagesschau.de/multimedia/sendung/nm-3475.html',
55 'md5': '8a8875a568f0a5ae5ceef93c501a225f',
59 'description': 'md5:ed149f5649cda3dac86813a9d777e131',
60 'title': 'Sendung: nachtmagazin \t15.07.2015 00:15 Uhr',
61 'thumbnail': 're:^http:.*\.jpg$',
64 'url': 'http://www.tagesschau.de/multimedia/tsvorzwanzig-959.html',
65 'md5': 'be4d6f0421f2acd8abe25ea29f6f015b',
70 'title': 'Sendung: tagesschau vor 20 Jahren \t14.07.2015 22:45 Uhr',
71 'thumbnail': 're:^http:.*\.jpg$',
76 's': {'width': 256, 'height': 144, 'quality': 1}
,
77 'm': {'width': 512, 'height': 288, 'quality': 2}
,
78 'l': {'width': 960, 'height': 544, 'quality': 3}
,
81 def _real_extract(self
, url
):
82 video_id
= self
._match
_id
(url
)
83 display_id
= video_id
.lstrip('-')
84 webpage
= self
._download
_webpage
(url
, display_id
)
86 player_url
= self
._html
_search
_meta
(
87 'twitter:player', webpage
, 'player URL', default
=None)
89 playerpage
= self
._download
_webpage
(
90 player_url
, display_id
, 'Downloading player page')
93 r
'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"',
96 for url
, ext
, res
in medias
:
98 'format_id': res
+ '_' + ext
,
102 f
.update(self
._FORMATS
.get(res
, {}))
104 thumbnail_fn
= re
.findall(r
'"(/multimedia/.+?\.jpg)"', playerpage
)[-1]
105 title
= self
._og
_search
_title
(webpage
).strip()
106 description
= self
._og
_search
_description
(webpage
).strip()
108 download_text
= self
._search
_regex
(
109 r
'(?s)<p>Wir bieten dieses Video in folgenden Formaten zum Download an:</p>\s*<div class="controls">(.*?)</div>\s*<p>',
110 webpage
, 'download links')
112 r
'<div class="button" title="(?P<title>[^"]*)"><a href="(?P<url>[^"]+)">(?P<name>.+?)</a></div>',
116 format_id
= self
._search
_regex
(
117 r
'.*/[^/.]+\.([^/]+)\.[^/.]+', l
.group('url'), 'format ID')
119 'format_id': format_id
,
120 'url': l
.group('url'),
121 'format_name': l
.group('name'),
125 Video:\s*(?P<vcodec>[a-zA-Z0-9/._-]+)\s*&\#10;
126 (?P<width>[0-9]+)x(?P<height>[0-9]+)px&\#10;
127 (?P<vbr>[0-9]+)kbps&\#10;
128 Audio:\s*(?P<abr>[0-9]+)kbps,\s*(?P<audio_desc>[A-Za-z\.0-9]+)&\#10;
129 Größe:\s*(?P<filesize_approx>[0-9.,]+\s+[a-zA-Z]*B)''',
133 'format_note': m
.group('audio_desc'),
134 'vcodec': m
.group('vcodec'),
135 'width': int(m
.group('width')),
136 'height': int(m
.group('height')),
137 'abr': int(m
.group('abr')),
138 'vbr': int(m
.group('vbr')),
139 'filesize_approx': parse_filesize(m
.group('filesize_approx')),
141 formats
.append(format
)
142 thumbnail_fn
= self
._search
_regex
(
143 r
'(?s)<img alt="Sendungsbild".*?src="([^"]+)"',
144 webpage
, 'thumbnail', fatal
=False)
145 # there are some videos without description
148 description
= self
._html
_search
_regex
(
149 r
'(?s)<p class="teasertext">(.*?)</p>',
150 webpage
, 'description', fatal
=False)
151 except ExtractorError
:
153 title
= self
._html
_search
_regex
(
154 r
'<span class="headline".*?>(.*?)</span>', webpage
, 'title')
156 self
._sort
_formats
(formats
)
157 thumbnail
= 'http://www.tagesschau.de' + thumbnail_fn
162 'thumbnail': thumbnail
,
164 'description': description
,