3 from .common
import InfoExtractor
4 from ..networking
import HEADRequest
5 from ..utils
import int_or_none
, traverse_obj
, url_or_none
, urljoin
8 class TenPlayIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
10 _NETRC_MACHINE
= '10play'
12 'url': 'https://10play.com.au/neighbours/web-extras/season-41/heres-a-first-look-at-mischa-bartons-neighbours-debut/tpv230911hyxnz',
14 'id': '6336940246112',
16 'title': 'Here\'s A First Look At Mischa Barton\'s Neighbours Debut',
17 'alt_title': 'Here\'s A First Look At Mischa Barton\'s Neighbours Debut',
18 'description': 'Neighbours Premieres Monday, September 18 At 4:30pm On 10 And 10 Play And 6:30pm On 10 Peach',
20 'season': 'Season 41',
22 'series': 'Neighbours',
23 'thumbnail': r
're:https://.*\.jpg',
24 'uploader': 'Channel 10',
26 'timestamp': 1694386800,
27 'upload_date': '20230910',
28 'uploader_id': '2199827728001',
31 'skip_download': True,
33 'skip': 'Only available in Australia',
35 'url': 'https://10play.com.au/neighbours/episodes/season-42/episode-9107/tpv240902nzqyp',
37 'id': '9000000000091177',
39 'title': 'Neighbours - S42 Ep. 9107',
40 'alt_title': 'Thu 05 Sep',
41 'description': 'md5:37a1f4271be34b9ee2b533426a5fbaef',
43 'episode': 'Episode 9107',
44 'episode_number': 9107,
45 'season': 'Season 42',
47 'series': 'Neighbours',
48 'thumbnail': r
're:https://.*\.jpg',
50 'timestamp': 1725517860,
51 'upload_date': '20240905',
52 'uploader': 'Channel 10',
53 'uploader_id': '2199827728001',
56 'skip_download': True,
58 'skip': 'Only available in Australia',
60 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
61 'only_matching': True,
75 def _real_extract(self
, url
):
76 content_id
= self
._match
_id
(url
)
77 data
= self
._download
_json
(
78 'https://10play.com.au/api/v1/videos/' + content_id
, content_id
)
80 video_data
= self
._download
_json
(
81 f
'https://vod.ten.com.au/api/videos/bcquery?command=find_videos_by_id&video_id={data["altId"]}',
82 content_id
, 'Downloading video JSON')
83 m3u8_url
= self
._request
_webpage
(
84 HEADRequest(video_data
['items'][0]['HLSURL']),
85 content_id
, 'Checking stream URL').url
86 if '10play-not-in-oz' in m3u8_url
:
87 self
.raise_geo_restricted(countries
=['AU'])
88 # Attempt to get a higher quality stream
89 m3u8_url
= m3u8_url
.replace(',150,75,55,0000', ',300,150,75,55,0000')
90 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, content_id
, 'mp4')
95 'subtitles': {'en': [{'url': data
['captionUrl']}]} if url_or_none(data
.get('captionUrl')) else None,
96 'uploader': 'Channel 10',
97 'uploader_id': '2199827728001',
98 **traverse_obj(data
, {
99 'id': ('altId', {str}
),
100 'duration': ('duration', {int_or_none}
),
101 'title': ('subtitle', {str}
),
102 'alt_title': ('title', {str}
),
103 'description': ('description', {str}
),
104 'age_limit': ('classification', {self
._AUS
_AGES
.get
}),
105 'series': ('tvShow', {str}
),
106 'season_number': ('season', {int_or_none}
),
107 'episode_number': ('episode', {int_or_none}
),
108 'timestamp': ('published', {int_or_none}
),
109 'thumbnail': ('imageUrl', {url_or_none}
),
114 class TenPlaySeasonIE(InfoExtractor
):
115 _VALID_URL
= r
'https?://(?:www\.)?10play\.com\.au/(?P<show>[^/?#]+)/episodes/(?P<season>[^/?#]+)/?(?:$|[?#])'
117 'url': 'https://10play.com.au/masterchef/episodes/season-14',
119 'title': 'Season 14',
122 'playlist_mincount': 64,
124 'url': 'https://10play.com.au/the-bold-and-the-beautiful-fast-tracked/episodes/season-2022',
126 'title': 'Season 2022',
129 'playlist_mincount': 256,
132 def _entries(self
, load_more_url
, display_id
=None):
134 for page
in itertools
.count(1):
135 episodes_carousel
= self
._download
_json
(
136 load_more_url
, display_id
, query
={'skipIds[]': skip_ids
},
137 note
=f
'Fetching episodes page {page}')
139 episodes_chunk
= episodes_carousel
['items']
140 skip_ids
.extend(ep
['id'] for ep
in episodes_chunk
)
142 for ep
in episodes_chunk
:
144 if not episodes_carousel
['hasMore']:
147 def _real_extract(self
, url
):
148 show
, season
= self
._match
_valid
_url
(url
).group('show', 'season')
149 season_info
= self
._download
_json
(
150 f
'https://10play.com.au/api/shows/{show}/episodes/{season}', f
'{show}/{season}')
152 episodes_carousel
= traverse_obj(season_info
, (
153 'content', 0, 'components', (
154 lambda _
, v
: v
['title'].lower() == 'episodes',
156 )), get_all
=False) or {}
158 playlist_id
= episodes_carousel
['tpId']
160 return self
.playlist_from_matches(
161 self
._entries
(urljoin(url
, episodes_carousel
['loadMoreUrl']), playlist_id
),
162 playlist_id
, traverse_obj(season_info
, ('content', 0, 'title', {str}
)),