]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tagesschau.py
Update changelog.
[youtubedl] / youtube_dl / extractor / tagesschau.py
1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class TagesschauIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?tagesschau\.de/multimedia/video/video(?P<id>-?[0-9]+)\.html'
11
12 _TESTS = [{
13 'url': 'http://www.tagesschau.de/multimedia/video/video1399128.html',
14 'md5': 'bcdeac2194fb296d599ce7929dfa4009',
15 'info_dict': {
16 'id': '1399128',
17 'ext': 'mp4',
18 'title': 'Harald Range, Generalbundesanwalt, zu den Ermittlungen',
19 'description': 'md5:69da3c61275b426426d711bde96463ab',
20 'thumbnail': 're:^http:.*\.jpg$',
21 },
22 }]
23
24 _FORMATS = {
25 's': {'width': 256, 'height': 144, 'quality': 1},
26 'm': {'width': 512, 'height': 288, 'quality': 2},
27 'l': {'width': 960, 'height': 544, 'quality': 3},
28 }
29
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33
34 if video_id.startswith('-'):
35 display_id = video_id.strip('-')
36 else:
37 display_id = video_id
38
39 webpage = self._download_webpage(url, display_id)
40
41 playerpage = self._download_webpage(
42 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id,
43 display_id, 'Downloading player page')
44
45 medias = re.findall(
46 r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"',
47 playerpage)
48
49 formats = []
50 for url, ext, res in medias:
51 f = {
52 'format_id': res + '_' + ext,
53 'url': url,
54 'ext': ext,
55 }
56 f.update(self._FORMATS.get(res, {}))
57 formats.append(f)
58
59 self._sort_formats(formats)
60
61 thumbnail = re.findall(r'"(/multimedia/.+?\.jpg)"', playerpage)[-1]
62
63 return {
64 'id': display_id,
65 'title': self._og_search_title(webpage).strip(),
66 'thumbnail': 'http://www.tagesschau.de' + thumbnail,
67 'formats': formats,
68 'description': self._og_search_description(webpage).strip(),
69 }