1 from datetime
import datetime
4 from .common
import InfoExtractor
12 class TenPlayIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
14 _NETRC_MACHINE
= '10play'
16 'url': 'https://10play.com.au/neighbours/web-extras/season-39/nathan-borg-is-the-first-aussie-actor-with-a-cochlear-implant-to-join-neighbours/tpv210128qupwd',
18 'id': '6226844312001',
20 'title': 'Nathan Borg Is The First Aussie Actor With A Cochlear Implant To Join Neighbours',
21 'alt_title': 'Nathan Borg Is The First Aussie Actor With A Cochlear Implant To Join Neighbours',
22 'description': 'md5:a02d0199c901c2dd4c796f1e7dd0de43',
25 'series': 'Neighbours',
26 'thumbnail': r
're:https://.*\.jpg',
27 'uploader': 'Channel 10',
29 'timestamp': 1611810000,
30 'upload_date': '20210128',
31 'uploader_id': '2199827728001',
34 'skip_download': True,
36 'skip': 'Only available in Australia',
38 'url': 'https://10play.com.au/todd-sampsons-body-hack/episodes/season-4/episode-7/tpv200921kvngh',
40 'id': '6192880312001',
42 'title': "Todd Sampson's Body Hack - S4 Ep. 2",
43 'description': 'md5:fa278820ad90f08ea187f9458316ac74',
45 'timestamp': 1600770600,
46 'upload_date': '20200922',
47 'uploader': 'Channel 10',
48 'uploader_id': '2199827728001'
51 'skip_download': True,
54 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
55 'only_matching': True,
69 def _get_bearer_token(self
, video_id
):
70 username
, password
= self
._get
_login
_info
()
71 if username
is None or password
is None:
72 self
.raise_login_required('Your 10play account\'s details must be provided with --username and --password.')
73 _timestamp
= datetime
.now().strftime('%Y%m%d000000')
74 _auth_header
= base64
.b64encode(_timestamp
.encode('ascii')).decode('ascii')
75 data
= self
._download
_json
('https://10play.com.au/api/user/auth', video_id
, 'Getting bearer token', headers
={
76 'X-Network-Ten-Auth': _auth_header
,
77 }, data
=urlencode_postdata({
81 return 'Bearer ' + data
['jwt']['accessToken']
83 def _real_extract(self
, url
):
84 content_id
= self
._match
_id
(url
)
85 data
= self
._download
_json
(
86 'https://10play.com.au/api/v1/videos/' + content_id
, content_id
)
89 if data
.get('memberGated') is True:
90 _token
= self
._get
_bearer
_token
(content_id
)
91 headers
= {'Authorization': _token}
93 _video_url
= self
._download
_json
(
94 data
.get('playbackApiEndpoint'), content_id
, 'Downloading video JSON',
95 headers
=headers
).get('source')
96 m3u8_url
= self
._request
_webpage
(HEADRequest(
97 _video_url
), content_id
).geturl()
98 if '10play-not-in-oz' in m3u8_url
:
99 self
.raise_geo_restricted(countries
=['AU'])
100 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, content_id
, 'mp4')
104 'subtitles': {'en': [{'url': data.get('captionUrl')}
]} if data
.get('captionUrl') else None,
105 'id': data
.get('altId') or content_id
,
106 'duration': data
.get('duration'),
107 'title': data
.get('subtitle'),
108 'alt_title': data
.get('title'),
109 'description': data
.get('description'),
110 'age_limit': self
._AUS
_AGES
.get(data
.get('classification')),
111 'series': data
.get('tvShow'),
112 'season': int_or_none(data
.get('season')),
113 'episode_number': int_or_none(data
.get('episode')),
114 'timestamp': data
.get('published'),
115 'thumbnail': data
.get('imageUrl'),
116 'uploader': 'Channel 10',
117 'uploader_id': '2199827728001',