youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

myspass.py (2229B)


      1 # coding: utf-8
      2 from __future__ import unicode_literals
      3 
      4 import re
      5 
      6 from .common import InfoExtractor
      7 from ..compat import compat_str
      8 from ..utils import (
      9     int_or_none,
     10     parse_duration,
     11     xpath_text,
     12 )
     13 
     14 
     15 class MySpassIE(InfoExtractor):
     16     _VALID_URL = r'https?://(?:www\.)?myspass\.de/([^/]+/)*(?P<id>\d+)'
     17     _TEST = {
     18         'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
     19         'md5': '0b49f4844a068f8b33f4b7c88405862b',
     20         'info_dict': {
     21             'id': '11741',
     22             'ext': 'mp4',
     23             'description': 'Wer kann in die Fußstapfen 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?',
     24             'title': '17.02.2013 - Die Highlights, Teil 2',
     25         },
     26     }
     27 
     28     def _real_extract(self, url):
     29         video_id = self._match_id(url)
     30 
     31         metadata = self._download_xml(
     32             'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=' + video_id,
     33             video_id)
     34 
     35         title = xpath_text(metadata, 'title', fatal=True)
     36         video_url = xpath_text(metadata, 'url_flv', 'download url', True)
     37         video_id_int = int(video_id)
     38         for group in re.search(r'/myspass2009/\d+/(\d+)/(\d+)/(\d+)/', video_url).groups():
     39             group_int = int(group)
     40             if group_int > video_id_int:
     41                 video_url = video_url.replace(
     42                     group, compat_str(group_int // video_id_int))
     43 
     44         return {
     45             'id': video_id,
     46             'url': video_url,
     47             'title': title,
     48             'thumbnail': xpath_text(metadata, 'imagePreview'),
     49             'description': xpath_text(metadata, 'description'),
     50             'duration': parse_duration(xpath_text(metadata, 'duration')),
     51             'series': xpath_text(metadata, 'format'),
     52             'season_number': int_or_none(xpath_text(metadata, 'season')),
     53             'season_id': xpath_text(metadata, 'season_id'),
     54             'episode': title,
     55             'episode_number': int_or_none(xpath_text(metadata, 'episode')),
     56         }