]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/srmediathek.py
Initiate new release.
[youtubedl] / youtube_dl / extractor / srmediathek.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import json
5
6 from .common import InfoExtractor
7 from ..utils import js_to_json
8
9
10 class SRMediathekIE(InfoExtractor):
11 IE_DESC = 'Saarländischer Rundfunk'
12 _VALID_URL = r'https?://sr-mediathek\.sr-online\.de/index\.php\?.*?&id=(?P<id>[0-9]+)'
13
14 _TEST = {
15 'url': 'http://sr-mediathek.sr-online.de/index.php?seite=7&id=28455',
16 'info_dict': {
17 'id': '28455',
18 'ext': 'mp4',
19 'title': 'sportarena (26.10.2014)',
20 'description': 'Ringen: KSV Köllerbach gegen Aachen-Walheim; Frauen-Fußball: 1. FC Saarbrücken gegen Sindelfingen; Motorsport: Rallye in Losheim; dazu: Interview mit Timo Bernhard; Turnen: TG Saar; Reitsport: Deutscher Voltigier-Pokal; Badminton: Interview mit Michael Fuchs ',
21 'thumbnail': 're:^https?://.*\.jpg$',
22 },
23 }
24
25 def _real_extract(self, url):
26 video_id = self._match_id(url)
27 webpage = self._download_webpage(url, video_id)
28
29 murls = json.loads(js_to_json(self._search_regex(
30 r'var mediaURLs\s*=\s*(.*?);\n', webpage, 'video URLs')))
31 formats = [{'url': murl} for murl in murls]
32 self._sort_formats(formats)
33
34 title = json.loads(js_to_json(self._search_regex(
35 r'var mediaTitles\s*=\s*(.*?);\n', webpage, 'title')))[0]
36
37 return {
38 'id': video_id,
39 'title': title,
40 'formats': formats,
41 'description': self._og_search_description(webpage),
42 'thumbnail': self._og_search_thumbnail(webpage),
43 }