1 from .common
import InfoExtractor
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,
42 'url': 'https://www.9now.com.au/lego-masters/season-3/episode-3',
44 'id': '6249614030001',
49 'description': 'In the first elimination of the competition, teams will have 10 hours to build a world inside a snow globe.',
50 'uploader_id': '4460760524001',
51 'timestamp': 1619002200,
52 'upload_date': '20210421',
54 'expected_warnings': ['Ignoring subtitle tracks'],
56 'skip_download': True,
59 BRIGHTCOVE_URL_TEMPLATE
= 'http://players.brightcove.net/4460760524001/default_default/index.html?videoId=%s'
61 def _real_extract(self
, url
):
62 display_id
= self
._match
_id
(url
)
63 webpage
= self
._download
_webpage
(url
, display_id
)
64 page_data
= self
._parse
_json
(self
._search
_regex
(
65 r
'window\.__data\s*=\s*({.*?});', webpage
,
66 'page data', default
='{}'), display_id
, fatal
=False)
68 page_data
= self
._parse
_json
(self
._parse
_json
(self
._search
_regex
(
69 r
'window\.__data\s*=\s*JSON\.parse\s*\(\s*(".+?")\s*\)\s*;',
70 webpage
, 'page data'), display_id
), display_id
)
72 for kind
in ('episode', 'clip'):
73 current_key
= page_data
.get(kind
, {}).get(
74 f
'current{kind.capitalize()}Key')
77 cache
= page_data
.get(kind
, {}).get(f
'{kind}Cache', {})
81 'episode': (cache
.get(current_key
) or next(iter(cache
.values())))[kind
],
82 'season': (cache
.get(current_key
) or next(iter(cache
.values()))).get('season', None),
86 raise ExtractorError('Unable to find video data')
88 if not self
.get_param('allow_unplayable_formats') and try_get(common_data
, lambda x
: x
['episode']['video']['drm'], bool):
89 self
.report_drm(display_id
)
90 brightcove_id
= try_get(
91 common_data
, lambda x
: x
['episode']['video']['brightcoveId'], str) or 'ref:{}'.format(common_data
['episode']['video']['referenceId'])
92 video_id
= str_or_none(try_get(common_data
, lambda x
: x
['episode']['video']['id'])) or brightcove_id
94 title
= try_get(common_data
, lambda x
: x
['episode']['name'], str)
95 season_number
= try_get(common_data
, lambda x
: x
['season']['seasonNumber'], int)
96 episode_number
= try_get(common_data
, lambda x
: x
['episode']['episodeNumber'], int)
97 timestamp
= unified_timestamp(try_get(common_data
, lambda x
: x
['episode']['airDate'], str))
98 release_date
= unified_strdate(try_get(common_data
, lambda x
: x
['episode']['availability'], str))
99 thumbnails_data
= try_get(common_data
, lambda x
: x
['episode']['image']['sizes'], dict) or {}
102 'url': thumbnail_url
,
103 'width': int_or_none(thumbnail_id
[1:]),
104 } for thumbnail_id
, thumbnail_url
in thumbnails_data
.items()]
107 '_type': 'url_transparent',
109 self
.BRIGHTCOVE_URL_TEMPLATE
% brightcove_id
,
110 {'geo_countries': self
._GEO
_COUNTRIES
}),
113 'description': try_get(common_data
, lambda x
: x
['episode']['description'], str),
114 'duration': float_or_none(try_get(common_data
, lambda x
: x
['episode']['video']['duration'], float), 1000),
115 'thumbnails': thumbnails
,
116 'ie_key': 'BrightcoveNew',
117 'season_number': season_number
,
118 'episode_number': episode_number
,
119 'timestamp': timestamp
,
120 'release_date': release_date
,