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