2 from __future__
import unicode_literals
4 from datetime
import datetime
7 from .common
import InfoExtractor
15 class TenPlayIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
17 _NETRC_MACHINE
= '10play'
19 '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',
21 'id': '6226844312001',
23 'title': 'Nathan Borg Is The First Aussie Actor With A Cochlear Implant To Join Neighbours',
24 'alt_title': 'Nathan Borg Is The First Aussie Actor With A Cochlear Implant To Join Neighbours',
25 'description': 'md5:a02d0199c901c2dd4c796f1e7dd0de43',
28 'series': 'Neighbours',
29 'thumbnail': r
're:https://.*\.jpg',
30 'uploader': 'Channel 10',
32 'timestamp': 1611810000,
33 'upload_date': '20210128',
34 'uploader_id': '2199827728001',
37 'skip_download': True,
39 'skip': 'Only available in Australia',
41 'url': 'https://10play.com.au/todd-sampsons-body-hack/episodes/season-4/episode-7/tpv200921kvngh',
43 'id': '6192880312001',
45 'title': "Todd Sampson's Body Hack - S4 Ep. 2",
46 'description': 'md5:fa278820ad90f08ea187f9458316ac74',
48 'timestamp': 1600770600,
49 'upload_date': '20200922',
50 'uploader': 'Channel 10',
51 'uploader_id': '2199827728001'
54 'skip_download': True,
57 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
58 'only_matching': True,
72 def _get_bearer_token(self
, video_id
):
73 username
, password
= self
._get
_login
_info
()
74 if username
is None or password
is None:
75 self
.raise_login_required('Your 10play account\'s details must be provided with --username and --password.')
76 _timestamp
= datetime
.now().strftime('%Y%m%d000000')
77 _auth_header
= base64
.b64encode(_timestamp
.encode('ascii')).decode('ascii')
78 data
= self
._download
_json
('https://10play.com.au/api/user/auth', video_id
, 'Getting bearer token', headers
={
79 'X-Network-Ten-Auth': _auth_header
,
80 }, data
=urlencode_postdata({
84 return 'Bearer ' + data
['jwt']['accessToken']
86 def _real_extract(self
, url
):
87 content_id
= self
._match
_id
(url
)
88 data
= self
._download
_json
(
89 'https://10play.com.au/api/v1/videos/' + content_id
, content_id
)
92 if data
.get('memberGated') is True:
93 _token
= self
._get
_bearer
_token
(content_id
)
94 headers
= {'Authorization': _token}
96 _video_url
= self
._download
_json
(
97 data
.get('playbackApiEndpoint'), content_id
, 'Downloading video JSON',
98 headers
=headers
).get('source')
99 m3u8_url
= self
._request
_webpage
(HEADRequest(
100 _video_url
), content_id
).geturl()
101 if '10play-not-in-oz' in m3u8_url
:
102 self
.raise_geo_restricted(countries
=['AU'])
103 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, content_id
, 'mp4')
104 self
._sort
_formats
(formats
)
108 'subtitles': {'en': [{'url': data.get('captionUrl')}
]} if data
.get('captionUrl') else None,
109 'id': data
.get('altId') or content_id
,
110 'duration': data
.get('duration'),
111 'title': data
.get('subtitle'),
112 'alt_title': data
.get('title'),
113 'description': data
.get('description'),
114 'age_limit': self
._AUS
_AGES
.get(data
.get('classification')),
115 'series': data
.get('tvShow'),
116 'season': int_or_none(data
.get('season')),
117 'episode_number': int_or_none(data
.get('episode')),
118 'timestamp': data
.get('published'),
119 'thumbnail': data
.get('imageUrl'),
120 'uploader': 'Channel 10',
121 'uploader_id': '2199827728001',