]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/myspass.py
[ssa] Add extractor (Closes #5169)
[yt-dlp.git] / youtube_dl / extractor / myspass.py
CommitLineData
fb2a706d 1from __future__ import unicode_literals
97d2db01 2import os.path
97d2db01
PH
3
4from .common import InfoExtractor
1cc79574 5from ..compat import (
97d2db01 6 compat_urllib_parse_urlparse,
1cc79574
PH
7)
8from ..utils import (
97d2db01
PH
9 ExtractorError,
10)
11
12
13class MySpassIE(InfoExtractor):
c0ade33e 14 _VALID_URL = r'http://www\.myspass\.de/.*'
6f5ac90c 15 _TEST = {
fb2a706d 16 'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
fb2a706d
JMF
17 'md5': '0b49f4844a068f8b33f4b7c88405862b',
18 'info_dict': {
ef89dba5
PH
19 'id': '11741',
20 'ext': 'mp4',
fb2a706d
JMF
21 "description": "Wer kann in die Fu\u00dfstapfen von Wolfgang Kubicki treten und die Mehrheit der Zuschauer hinter sich versammeln? Wird vielleicht sogar die Absolute Mehrheit geknackt und der Jackpot von 200.000 Euro mit nach Hause genommen?",
22 "title": "Absolute Mehrheit vom 17.02.2013 - Die Highlights, Teil 2",
23 },
6f5ac90c 24 }
97d2db01
PH
25
26 def _real_extract(self, url):
27 META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
28
29 # video id is the last path element of the URL
30 # usually there is a trailing slash, so also try the second but last
31 url_path = compat_urllib_parse_urlparse(url).path
32 url_parent_path, video_id = os.path.split(url_path)
33 if not video_id:
34 _, video_id = os.path.split(url_parent_path)
35
36 # get metadata
37 metadata_url = META_DATA_URL_TEMPLATE % video_id
e26f8712 38 metadata = self._download_xml(metadata_url, video_id)
97d2db01
PH
39
40 # extract values from metadata
41 url_flv_el = metadata.find('url_flv')
42 if url_flv_el is None:
fb2a706d 43 raise ExtractorError('Unable to extract download url')
97d2db01 44 video_url = url_flv_el.text
97d2db01
PH
45 title_el = metadata.find('title')
46 if title_el is None:
fb2a706d 47 raise ExtractorError('Unable to extract title')
97d2db01
PH
48 title = title_el.text
49 format_id_el = metadata.find('format_id')
50 if format_id_el is None:
51 format = 'mp4'
52 else:
53 format = format_id_el.text
54 description_el = metadata.find('description')
55 if description_el is not None:
56 description = description_el.text
57 else:
58 description = None
59 imagePreview_el = metadata.find('imagePreview')
60 if imagePreview_el is not None:
61 thumbnail = imagePreview_el.text
62 else:
63 thumbnail = None
fb2a706d
JMF
64
65 return {
97d2db01
PH
66 'id': video_id,
67 'url': video_url,
68 'title': title,
97d2db01
PH
69 'format': format,
70 'thumbnail': thumbnail,
fb2a706d 71 'description': description,
97d2db01 72 }