]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ninenow.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   5 from ..compat 
import compat_str
 
  13 class NineNowIE(InfoExtractor
): 
  14     IE_NAME 
= '9now.com.au' 
  15     _VALID_URL 
= r
'https?://(?:www\.)?9now\.com\.au/(?:[^/]+/){2}(?P<id>[^/?#]+)' 
  18         'url': 'https://www.9now.com.au/afl-footy-show/2016/clip-ciql02091000g0hp5oktrnytc', 
  19         'md5': '17cf47d63ec9323e562c9957a968b565', 
  23             'title': 'St. Kilda\'s Joey Montagna on the potential for a player\'s strike', 
  24             'description': 'Is a boycott of the NAB Cup "on the table"?', 
  25             'uploader_id': '4460760524001', 
  26             'upload_date': '20160713', 
  27             'timestamp': 1468421266, 
  29         'skip': 'Only available in Australia', 
  32         'url': 'https://www.9now.com.au/afl-footy-show/2016/episode-19', 
  33         'only_matching': True, 
  36         'url': 'https://www.9now.com.au/andrew-marrs-history-of-the-world/season-1/episode-1', 
  37         'only_matching': True, 
  39     BRIGHTCOVE_URL_TEMPLATE 
= 'http://players.brightcove.net/4460760524001/default_default/index.html?videoId=%s' 
  41     def _real_extract(self
, url
): 
  42         display_id 
= self
._match
_id
(url
) 
  43         webpage 
= self
._download
_webpage
(url
, display_id
) 
  44         page_data 
= self
._parse
_json
(self
._search
_regex
( 
  45             r
'window\.__data\s*=\s*({.*?});', webpage
, 
  46             'page data'), display_id
) 
  48         for kind 
in ('episode', 'clip'): 
  49             current_key 
= page_data
.get(kind
, {}).get( 
  50                 'current%sKey' % kind
.capitalize()) 
  53             cache 
= page_data
.get(kind
, {}).get('%sCache' % kind
, {}) 
  56             common_data 
= (cache
.get(current_key
) or list(cache
.values())[0])[kind
] 
  59             raise ExtractorError('Unable to find video data') 
  61         video_data 
= common_data
['video'] 
  63         if video_data
.get('drm'): 
  64             raise ExtractorError('This video is DRM protected.', expected
=True) 
  66         brightcove_id 
= video_data
.get('brightcoveId') or 'ref:' + video_data
['referenceId'] 
  67         video_id 
= compat_str(video_data
.get('id') or brightcove_id
) 
  68         title 
= common_data
['name'] 
  73             'width': int_or_none(thumbnail_id
[1:]) 
  74         } for thumbnail_id
, thumbnail_url 
in common_data
.get('image', {}).get('sizes', {}).items()] 
  77             '_type': 'url_transparent', 
  78             'url': self
.BRIGHTCOVE_URL_TEMPLATE 
% brightcove_id
, 
  81             'description': common_data
.get('description'), 
  82             'duration': float_or_none(video_data
.get('duration'), 1000), 
  83             'thumbnails': thumbnails
, 
  84             'ie_key': 'BrightcoveNew',