]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/myspass.py
51e540814be209856a9a71f891e55eeb4ba559c2
[youtubedl] / youtube_dl / extractor / myspass.py
1 from __future__ import unicode_literals
2 import os.path
3
4 from .common import InfoExtractor
5 from ..utils import (
6 compat_urllib_parse_urlparse,
7
8 ExtractorError,
9 )
10
11
12 class MySpassIE(InfoExtractor):
13 _VALID_URL = r'http://www\.myspass\.de/.*'
14 _TEST = {
15 'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
16 'md5': '0b49f4844a068f8b33f4b7c88405862b',
17 'info_dict': {
18 'id': '11741',
19 'ext': 'mp4',
20 "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?",
21 "title": "Absolute Mehrheit vom 17.02.2013 - Die Highlights, Teil 2",
22 },
23 }
24
25 def _real_extract(self, url):
26 META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
27
28 # video id is the last path element of the URL
29 # usually there is a trailing slash, so also try the second but last
30 url_path = compat_urllib_parse_urlparse(url).path
31 url_parent_path, video_id = os.path.split(url_path)
32 if not video_id:
33 _, video_id = os.path.split(url_parent_path)
34
35 # get metadata
36 metadata_url = META_DATA_URL_TEMPLATE % video_id
37 metadata = self._download_xml(metadata_url, video_id)
38
39 # extract values from metadata
40 url_flv_el = metadata.find('url_flv')
41 if url_flv_el is None:
42 raise ExtractorError('Unable to extract download url')
43 video_url = url_flv_el.text
44 title_el = metadata.find('title')
45 if title_el is None:
46 raise ExtractorError('Unable to extract title')
47 title = title_el.text
48 format_id_el = metadata.find('format_id')
49 if format_id_el is None:
50 format = 'mp4'
51 else:
52 format = format_id_el.text
53 description_el = metadata.find('description')
54 if description_el is not None:
55 description = description_el.text
56 else:
57 description = None
58 imagePreview_el = metadata.find('imagePreview')
59 if imagePreview_el is not None:
60 thumbnail = imagePreview_el.text
61 else:
62 thumbnail = None
63
64 return {
65 'id': video_id,
66 'url': video_url,
67 'title': title,
68 'format': format,
69 'thumbnail': thumbnail,
70 'description': description,
71 }