]>
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
14 class NineNowIE(InfoExtractor
):
15 IE_NAME
= '9now.com.au'
16 _VALID_URL
= r
'https?://(?:www\.)?9now\.com\.au/(?:[^/]+/){2}(?P<id>[^/?#]+)'
17 _GEO_COUNTRIES
= ['AU']
20 'url': 'https://www.9now.com.au/afl-footy-show/2016/clip-ciql02091000g0hp5oktrnytc',
21 'md5': '17cf47d63ec9323e562c9957a968b565',
25 'title': 'St. Kilda\'s Joey Montagna on the potential for a player\'s strike',
26 'description': 'Is a boycott of the NAB Cup "on the table"?',
27 'uploader_id': '4460760524001',
28 'upload_date': '20160713',
29 'timestamp': 1468421266,
31 'skip': 'Only available in Australia',
34 'url': 'https://www.9now.com.au/afl-footy-show/2016/episode-19',
35 'only_matching': True,
38 'url': 'https://www.9now.com.au/andrew-marrs-history-of-the-world/season-1/episode-1',
39 'only_matching': True,
41 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/4460760524001/default_default/index.html?videoId=%s'
43 def _real_extract(self
, url
):
44 display_id
= self
._match
_id
(url
)
45 webpage
= self
._download
_webpage
(url
, display_id
)
46 page_data
= self
._parse
_json
(self
._search
_regex
(
47 r
'window\.__data\s*=\s*({.*?});', webpage
,
48 'page data', default
='{}'), display_id
, fatal
=False)
50 page_data
= self
._parse
_json
(self
._parse
_json
(self
._search
_regex
(
51 r
'window\.__data\s*=\s*JSON\.parse\s*\(\s*(".+?")\s*\)\s*;',
52 webpage
, 'page data'), display_id
), display_id
)
54 for kind
in ('episode', 'clip'):
55 current_key
= page_data
.get(kind
, {}).get(
56 'current%sKey' % kind
.capitalize())
59 cache
= page_data
.get(kind
, {}).get('%sCache' % kind
, {})
62 common_data
= (cache
.get(current_key
) or list(cache
.values())[0])[kind
]
65 raise ExtractorError('Unable to find video data')
67 video_data
= common_data
['video']
69 if video_data
.get('drm'):
70 raise ExtractorError('This video is DRM protected.', expected
=True)
72 brightcove_id
= video_data
.get('brightcoveId') or 'ref:' + video_data
['referenceId']
73 video_id
= compat_str(video_data
.get('id') or brightcove_id
)
74 title
= common_data
['name']
79 'width': int_or_none(thumbnail_id
[1:])
80 } for thumbnail_id
, thumbnail_url
in common_data
.get('image', {}).get('sizes', {}).items()]
83 '_type': 'url_transparent',
85 self
.BRIGHTCOVE_URL_TEMPLATE
% brightcove_id
,
86 {'geo_countries': self
._GEO
_COUNTRIES
}),
89 'description': common_data
.get('description'),
90 'duration': float_or_none(video_data
.get('duration'), 1000),
91 'thumbnails': thumbnails
,
92 'ie_key': 'BrightcoveNew',