]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/myspass.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / myspass.py
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 parse_duration,
5 xpath_text,
6 )
7
8
9 class MySpassIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?myspass\.de/(?:[^/]+/)*(?P<id>\d+)/?[^/]*$'
11 _TESTS = [{
12 'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
13 'md5': '0b49f4844a068f8b33f4b7c88405862b',
14 'info_dict': {
15 'id': '11741',
16 'ext': 'mp4',
17 'description': 'md5:9f0db5044c8fe73f528a390498f7ce9b',
18 'title': '17.02.2013 - Die Highlights, Teil 2',
19 'thumbnail': r're:.*\.jpg',
20 'duration': 323.0,
21 'episode': '17.02.2013 - Die Highlights, Teil 2',
22 'season_id': '544',
23 'episode_number': 1,
24 'series': 'Absolute Mehrheit',
25 'season_number': 2,
26 'season': 'Season 2',
27 },
28 },
29 {
30 'url': 'https://www.myspass.de/shows/tvshows/tv-total/Novak-Puffovic-bei-bester-Laune--/44996/',
31 'md5': 'eb28b7c5e254192046e86ebaf7deac8f',
32 'info_dict': {
33 'id': '44996',
34 'ext': 'mp4',
35 'description': 'md5:74c7f886e00834417f1e427ab0da6121',
36 'title': 'Novak Puffovic bei bester Laune',
37 'thumbnail': r're:.*\.jpg',
38 'episode_number': 8,
39 'episode': 'Novak Puffovic bei bester Laune',
40 'series': 'TV total',
41 'season': 'Season 19',
42 'season_id': '987',
43 'duration': 2941.0,
44 'season_number': 19,
45 },
46 },
47 {
48 'url': 'https://www.myspass.de/channels/tv-total-raabigramm/17033/20831/',
49 'md5': '7b293a6b9f3a7acdd29304c8d0dbb7cc',
50 'info_dict': {
51 'id': '20831',
52 'ext': 'mp4',
53 'description': 'Gefühle pur: Schaut euch die ungeschnittene Version von Stefans Liebesbeweis an die Moderationsgrazie von Welt, Verona Feldbusch, an.',
54 'title': 'Raabigramm Verona Feldbusch',
55 'thumbnail': r're:.*\.jpg',
56 'episode_number': 6,
57 'episode': 'Raabigramm Verona Feldbusch',
58 'series': 'TV total',
59 'season': 'Season 1',
60 'season_id': '34',
61 'duration': 105.0,
62 'season_number': 1,
63 },
64 }]
65
66 def _real_extract(self, url):
67 video_id = self._match_id(url)
68
69 metadata = self._download_xml('http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=' + video_id, video_id)
70
71 title = xpath_text(metadata, 'title', fatal=True)
72 video_url = xpath_text(metadata, 'url_flv', 'download url', True)
73 video_id_int = int(video_id)
74 for group in self._search_regex(r'/myspass2009/\d+/(\d+)/(\d+)/(\d+)/', video_url, 'myspass', group=(1, 2, 3), default=[]):
75 group_int = int(group)
76 if group_int > video_id_int:
77 video_url = video_url.replace(group, str(group_int // video_id_int))
78
79 return {
80 'id': video_id,
81 'url': video_url,
82 'title': title,
83 'thumbnail': xpath_text(metadata, 'imagePreview'),
84 'description': xpath_text(metadata, 'description'),
85 'duration': parse_duration(xpath_text(metadata, 'duration')),
86 'series': xpath_text(metadata, 'format'),
87 'season_number': int_or_none(xpath_text(metadata, 'season')),
88 'season_id': xpath_text(metadata, 'season_id'),
89 'episode': title,
90 'episode_number': int_or_none(xpath_text(metadata, 'episode')),
91 }