]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/srmediathek.py
Import Upstream version 2020.01.24
[youtubedl] / youtube_dl / extractor / srmediathek.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .ard import ARDMediathekBaseIE
5 from ..utils import (
6 ExtractorError,
7 get_element_by_attribute,
8 )
9
10
11 class SRMediathekIE(ARDMediathekBaseIE):
12 IE_NAME = 'sr:mediathek'
13 IE_DESC = 'Saarländischer Rundfunk'
14 _VALID_URL = r'https?://sr-mediathek(?:\.sr-online)?\.de/index\.php\?.*?&id=(?P<id>[0-9]+)'
15
16 _TESTS = [{
17 'url': 'http://sr-mediathek.sr-online.de/index.php?seite=7&id=28455',
18 'info_dict': {
19 'id': '28455',
20 'ext': 'mp4',
21 'title': 'sportarena (26.10.2014)',
22 '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 ',
23 'thumbnail': r're:^https?://.*\.jpg$',
24 },
25 'skip': 'no longer available',
26 }, {
27 'url': 'http://sr-mediathek.sr-online.de/index.php?seite=7&id=37682',
28 'info_dict': {
29 'id': '37682',
30 'ext': 'mp4',
31 'title': 'Love, Cakes and Rock\'n\'Roll',
32 'description': 'md5:18bf9763631c7d326c22603681e1123d',
33 },
34 'params': {
35 # m3u8 download
36 'skip_download': True,
37 },
38 }, {
39 'url': 'http://sr-mediathek.de/index.php?seite=7&id=7480',
40 'only_matching': True,
41 }]
42
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
45 webpage = self._download_webpage(url, video_id)
46
47 if '>Der gew&uuml;nschte Beitrag ist leider nicht mehr verf&uuml;gbar.<' in webpage:
48 raise ExtractorError('Video %s is no longer available' % video_id, expected=True)
49
50 media_collection_url = self._search_regex(
51 r'data-mediacollection-ardplayer="([^"]+)"', webpage, 'media collection url')
52 info = self._extract_media_info(media_collection_url, webpage, video_id)
53 info.update({
54 'id': video_id,
55 'title': get_element_by_attribute('class', 'ardplayer-title', webpage),
56 'description': self._og_search_description(webpage),
57 'thumbnail': self._og_search_thumbnail(webpage),
58 })
59 return info