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