]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myspass.py
Fix the changelog.
[youtubedl] / youtube_dl / extractor / myspass.py
1 from __future__ import unicode_literals
2 import os.path
3
4 from .common import InfoExtractor
5 from ..compat import (
6 compat_urllib_parse_urlparse,
7 )
8 from ..utils import (
9 ExtractorError,
10 )
11
12
13 class MySpassIE(InfoExtractor):
14 _VALID_URL = r'https?://(?:www\.)?myspass\.de/.*'
15 _TEST = {
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': '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 },
24 }
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
38 metadata = self._download_xml(
39 metadata_url, video_id, transform_source=lambda s: s.strip())
40
41 # extract values from metadata
42 url_flv_el = metadata.find('url_flv')
43 if url_flv_el is None:
44 raise ExtractorError('Unable to extract download url')
45 video_url = url_flv_el.text
46 title_el = metadata.find('title')
47 if title_el is None:
48 raise ExtractorError('Unable to extract title')
49 title = title_el.text
50 format_id_el = metadata.find('format_id')
51 if format_id_el is None:
52 format = 'mp4'
53 else:
54 format = format_id_el.text
55 description_el = metadata.find('description')
56 if description_el is not None:
57 description = description_el.text
58 else:
59 description = None
60 imagePreview_el = metadata.find('imagePreview')
61 if imagePreview_el is not None:
62 thumbnail = imagePreview_el.text
63 else:
64 thumbnail = None
65
66 return {
67 'id': video_id,
68 'url': video_url,
69 'title': title,
70 'format': format,
71 'thumbnail': thumbnail,
72 'description': description,
73 }