2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_str
18 class NineNowIE(InfoExtractor
):
19 IE_NAME
= '9now.com.au'
20 _VALID_URL
= r
'https?://(?:www\.)?9now\.com\.au/(?:[^/]+/){2}(?P<id>[^/?#]+)'
21 _GEO_COUNTRIES
= ['AU']
24 'url': 'https://www.9now.com.au/afl-footy-show/2016/clip-ciql02091000g0hp5oktrnytc',
25 'md5': '17cf47d63ec9323e562c9957a968b565',
29 'title': 'St. Kilda\'s Joey Montagna on the potential for a player\'s strike',
30 'description': 'Is a boycott of the NAB Cup "on the table"?',
31 'uploader_id': '4460760524001',
32 'upload_date': '20160713',
33 'timestamp': 1468421266,
35 'skip': 'Only available in Australia',
38 'url': 'https://www.9now.com.au/afl-footy-show/2016/episode-19',
39 'only_matching': True,
42 'url': 'https://www.9now.com.au/andrew-marrs-history-of-the-world/season-1/episode-1',
43 'only_matching': True,
46 'url': 'https://www.9now.com.au/lego-masters/season-3/episode-3',
48 'id': '6249614030001',
53 'description': 'In the first elimination of the competition, teams will have 10 hours to build a world inside a snow globe.',
54 'uploader_id': '4460760524001',
55 'timestamp': 1619002200,
56 'upload_date': '20210421',
58 'expected_warnings': ['Ignoring subtitle tracks'],
60 'skip_download': True,
63 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/4460760524001/default_default/index.html?videoId=%s'
65 def _real_extract(self
, url
):
66 display_id
= self
._match
_id
(url
)
67 webpage
= self
._download
_webpage
(url
, display_id
)
68 page_data
= self
._parse
_json
(self
._search
_regex
(
69 r
'window\.__data\s*=\s*({.*?});', webpage
,
70 'page data', default
='{}'), display_id
, fatal
=False)
72 page_data
= self
._parse
_json
(self
._parse
_json
(self
._search
_regex
(
73 r
'window\.__data\s*=\s*JSON\.parse\s*\(\s*(".+?")\s*\)\s*;',
74 webpage
, 'page data'), display_id
), display_id
)
76 for kind
in ('episode', 'clip'):
77 current_key
= page_data
.get(kind
, {}).get(
78 'current%sKey' % kind
.capitalize())
81 cache
= page_data
.get(kind
, {}).get('%sCache' % kind, {}
)
85 'episode': (cache
.get(current_key
) or list(cache
.values())[0])[kind
],
86 'season': (cache
.get(current_key
) or list(cache
.values())[0]).get('season', None)
90 raise ExtractorError('Unable to find video data')
92 if not self
.get_param('allow_unplayable_formats') and try_get(common_data
, lambda x
: x
['episode']['video']['drm'], bool):
93 self
.report_drm(display_id
)
94 brightcove_id
= try_get(
95 common_data
, lambda x
: x
['episode']['video']['brightcoveId'], compat_str
) or 'ref:%s' % common_data
['episode']['video']['referenceId']
96 video_id
= str_or_none(try_get(common_data
, lambda x
: x
['episode']['video']['id'])) or brightcove_id
98 title
= try_get(common_data
, lambda x
: x
['episode']['name'], compat_str
)
99 season_number
= try_get(common_data
, lambda x
: x
['season']['seasonNumber'], int)
100 episode_number
= try_get(common_data
, lambda x
: x
['episode']['episodeNumber'], int)
101 timestamp
= unified_timestamp(try_get(common_data
, lambda x
: x
['episode']['airDate'], compat_str
))
102 release_date
= unified_strdate(try_get(common_data
, lambda x
: x
['episode']['availability'], compat_str
))
103 thumbnails_data
= try_get(common_data
, lambda x
: x
['episode']['image']['sizes'], dict) or {}
106 'url': thumbnail_url
,
107 'width': int_or_none(thumbnail_id
[1:]),
108 } for thumbnail_id
, thumbnail_url
in thumbnails_data
.items()]
111 '_type': 'url_transparent',
113 self
.BRIGHTCOVE_URL_TEMPLATE
% brightcove_id
,
114 {'geo_countries': self._GEO_COUNTRIES}
),
117 'description': try_get(common_data
, lambda x
: x
['episode']['description'], compat_str
),
118 'duration': float_or_none(try_get(common_data
, lambda x
: x
['episode']['video']['duration'], float), 1000),
119 'thumbnails': thumbnails
,
120 'ie_key': 'BrightcoveNew',
121 'season_number': season_number
,
122 'episode_number': episode_number
,
123 'timestamp': timestamp
,
124 'release_date': release_date
,