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