]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/sportdeutschland.py
057ef5251dc6855c32a8df5abed6917556d190e9
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class SportDeutschlandIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://sportdeutschland\.tv/(?P<sport>[^/?#]+)/(?P<id>[^?#/]+)(?:$|[?#])' 
  16         'url': 'http://sportdeutschland.tv/badminton/live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen', 
  18             'id': 'live-li-ning-badminton-weltmeisterschaft-2014-kopenhagen', 
  20             'title': 're:Li-Ning Badminton Weltmeisterschaft 2014 Kopenhagen', 
  21             'categories': ['Badminton'], 
  23             'thumbnail': 're:^https?://.*\.jpg$', 
  24             'description': 're:Die Badminton-WM 2014 aus Kopenhagen bei Sportdeutschland\.TV', 
  26             'upload_date': 're:^201408[23][0-9]$', 
  29             'skip_download': 'Live stream', 
  32         'url': 'http://sportdeutschland.tv/li-ning-badminton-wm-2014/lee-li-ning-badminton-weltmeisterschaft-2014-kopenhagen-herren-einzel-wei-vs', 
  34             'id': 'lee-li-ning-badminton-weltmeisterschaft-2014-kopenhagen-herren-einzel-wei-vs', 
  36             'upload_date': '20140825', 
  37             'description': 'md5:60a20536b57cee7d9a4ec005e8687504', 
  38             'timestamp': 1408976060, 
  39             'title': 'Li-Ning Badminton Weltmeisterschaft 2014 Kopenhagen: Herren Einzel, Wei Lee vs. Keun Lee', 
  40             'thumbnail': 're:^https?://.*\.jpg$', 
  42             'categories': ['Li-Ning Badminton WM 2014'], 
  46     def _real_extract(self
, url
): 
  47         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  48         video_id 
= mobj
.group('id') 
  49         sport_id 
= mobj
.group('sport') 
  51         api_url 
= 'http://splink.tv/api/permalinks/%s/%s' % ( 
  53         req 
= compat_urllib_request
.Request(api_url
, headers
={ 
  54             'Accept': 'application/vnd.vidibus.v2.html+json', 
  57         data 
= self
._download
_json
(req
, video_id
) 
  59         categories 
= list(data
.get('section', {}).get('tags', {}).values()) 
  63         smil_url 
= asset
['video'] 
  64         if '.smil' in smil_url
: 
  65             m3u8_url 
= smil_url
.replace('.smil', '.m3u8') 
  67                 self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, ext
='mp4')) 
  69             smil_doc 
= self
._download
_xml
( 
  70                 smil_url
, video_id
, note
='Downloading SMIL metadata') 
  71             base_url 
= smil_doc
.find('./head/meta').attrib
['base'] 
  75                 'play_path': n
.attrib
['src'], 
  78                 'format_note': 'Seems to fail at example stream', 
  79             } for n 
in smil_doc
.findall('./body/video')]) 
  81             formats
.append({'url': smil_url
}) 
  83         self
._sort
_formats
(formats
) 
  88             'title': asset
['title'], 
  89             'thumbnail': asset
.get('image'), 
  90             'description': asset
.get('teaser'), 
  91             'categories': categories
, 
  92             'view_count': asset
.get('views'), 
  93             'rtmp_live': asset
.get('live'), 
  94             'timestamp': parse_iso8601(asset
.get('date')),