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