]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/toutv.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class TouTvIE(InfoExtractor
): 
  15     _VALID_URL 
= r
'https?://www\.tou\.tv/(?P<id>[a-zA-Z0-9_-]+(?:/(?P<episode>S[0-9]+E[0-9]+)))' 
  18         'url': 'http://www.tou.tv/30-vies/S04E41', 
  20             'id': '30-vies_S04E41', 
  22             'title': '30 vies Saison 4 / Épisode 41', 
  23             'description': 'md5:da363002db82ccbe4dafeb9cab039b09', 
  25             'uploader': 'Groupe des Nouveaux Médias', 
  27             'upload_date': '20131118', 
  28             'thumbnail': 'http://static.tou.tv/medias/images/2013-11-18_19_00_00_30VIES_0341_01_L.jpeg', 
  31             'skip_download': True,  # Requires rtmpdump 
  33         'skip': 'Only available in Canada' 
  36     def _real_extract(self
, url
): 
  37         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  38         video_id 
= mobj
.group('id') 
  39         webpage 
= self
._download
_webpage
(url
, video_id
) 
  41         mediaId 
= self
._search
_regex
( 
  42             r
'"idMedia":\s*"([^"]+)"', webpage
, 'media ID') 
  44         streams_url 
= 'http://release.theplatform.com/content.select?pid=' + mediaId
 
  45         streams_doc 
= self
._download
_xml
( 
  46             streams_url
, video_id
, note
='Downloading stream list') 
  48         video_url 
= next(n
.text
 
  49                          for n 
in streams_doc
.findall('.//choice/url') 
  50                          if '//ad.doubleclick' not in n
.text
) 
  51         if video_url
.endswith('/Unavailable.flv'): 
  53                 'Access to this video is blocked from outside of Canada', 
  56         duration_str 
= self
._html
_search
_meta
( 
  57             'video:duration', webpage
, 'duration') 
  58         duration 
= int(duration_str
) if duration_str 
else None 
  59         upload_date_str 
= self
._html
_search
_meta
( 
  60             'video:release_date', webpage
, 'upload date') 
  61         upload_date 
= unified_strdate(upload_date_str
) if upload_date_str 
else None 
  65             'title': self
._og
_search
_title
(webpage
), 
  67             'description': self
._og
_search
_description
(webpage
), 
  68             'uploader': self
._dc
_search
_uploader
(webpage
), 
  69             'thumbnail': self
._og
_search
_thumbnail
(webpage
), 
  70             'age_limit': self
._media
_rating
_search
(webpage
), 
  72             'upload_date': upload_date
,