]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tagesschau.py
debian/changelog: Finalize release.
[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 'url': 'http://www.tagesschau.de/multimedia/video/video-5964.html',
24 'md5': '66652566900963a3f962333579eeffcf',
25 'info_dict': {
26 'id': '5964',
27 'ext': 'mp4',
28 'title': 'Nahost-Konflikt: Israel bombadiert Ziele im Gazastreifen und Westjordanland',
29 'description': 'md5:07bfc78c48eec3145ed4805299a1900a',
30 'thumbnail': 're:http://.*\.jpg',
31 },
32 }]
33
34 _FORMATS = {
35 's': {'width': 256, 'height': 144, 'quality': 1},
36 'm': {'width': 512, 'height': 288, 'quality': 2},
37 'l': {'width': 960, 'height': 544, 'quality': 3},
38 }
39
40 def _real_extract(self, url):
41 mobj = re.match(self._VALID_URL, url)
42 video_id = mobj.group('id')
43
44 if video_id.startswith('-'):
45 display_id = video_id.strip('-')
46 else:
47 display_id = video_id
48
49 webpage = self._download_webpage(url, display_id)
50
51 playerpage = self._download_webpage(
52 'http://www.tagesschau.de/multimedia/video/video%s~player_autoplay-true.html' % video_id,
53 display_id, 'Downloading player page')
54
55 medias = re.findall(
56 r'"(http://media.+?)", type:"video/(.+?)", quality:"(.+?)"',
57 playerpage)
58
59 formats = []
60 for url, ext, res in medias:
61 f = {
62 'format_id': res + '_' + ext,
63 'url': url,
64 'ext': ext,
65 }
66 f.update(self._FORMATS.get(res, {}))
67 formats.append(f)
68
69 self._sort_formats(formats)
70
71 thumbnail = re.findall(r'"(/multimedia/.+?\.jpg)"', playerpage)[-1]
72
73 return {
74 'id': display_id,
75 'title': self._og_search_title(webpage).strip(),
76 'thumbnail': 'http://www.tagesschau.de' + thumbnail,
77 'formats': formats,
78 'description': self._og_search_description(webpage).strip(),
79 }