2 from __future__
import unicode_literals
4 from datetime
import datetime
7 from .common
import InfoExtractor
14 class TenPlayIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?10play\.com\.au/(?:[^/]+/)+(?P<id>tpv\d{6}[a-z]{5})'
16 _NETRC_MACHINE
= '10play'
18 'url': 'https://10play.com.au/todd-sampsons-body-hack/episodes/season-4/episode-7/tpv200921kvngh',
20 'id': '6192880312001',
22 'title': "Todd Sampson's Body Hack - S4 Ep. 2",
23 'description': 'md5:fa278820ad90f08ea187f9458316ac74',
25 'timestamp': 1600770600,
26 'upload_date': '20200922',
27 'uploader': 'Channel 10',
28 'uploader_id': '2199827728001'
31 'skip_download': True,
34 'url': 'https://10play.com.au/how-to-stay-married/web-extras/season-1/terrys-talks-ep-1-embracing-change/tpv190915ylupc',
35 'only_matching': True,
49 def _get_bearer_token(self
, video_id
):
50 username
, password
= self
._get
_login
_info
()
51 if username
is None or password
is None:
52 self
.raise_login_required('Your 10play account\'s details must be provided with --username and --password.')
53 _timestamp
= datetime
.now().strftime('%Y%m%d000000')
54 _auth_header
= base64
.b64encode(_timestamp
.encode('ascii')).decode('ascii')
55 data
= self
._download
_json
('https://10play.com.au/api/user/auth', video_id
, 'Getting bearer token', headers
={
56 'X-Network-Ten-Auth': _auth_header
,
57 }, data
=urlencode_postdata({
61 return 'Bearer ' + data
['jwt']['accessToken']
63 def _real_extract(self
, url
):
64 content_id
= self
._match
_id
(url
)
65 _token
= self
._get
_bearer
_token
(content_id
)
66 data
= self
._download
_json
(
67 'https://10play.com.au/api/v1/videos/' + content_id
, content_id
)
68 _video_url
= self
._download
_json
(
69 data
.get('playbackApiEndpoint'), content_id
, 'Downloading video JSON',
70 headers
={'Authorization': _token}
).get('source')
71 m3u8_url
= self
._request
_webpage
(HEADRequest(
72 _video_url
), content_id
).geturl()
73 if '10play-not-in-oz' in m3u8_url
:
74 self
.raise_geo_restricted(countries
=['AU'])
75 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, content_id
, 'mp4')
76 self
._sort
_formats
(formats
)
80 'id': data
.get('altId') or content_id
,
81 'title': data
.get('title'),
82 'description': data
.get('description'),
83 'age_limit': self
._AUS
_AGES
.get(data
.get('classification')),
84 'series': data
.get('showName'),
85 'season': data
.get('showContentSeason'),
86 'timestamp': data
.get('published'),
87 'thumbnail': data
.get('imageUrl'),
88 'uploader': 'Channel 10',
89 'uploader_id': '2199827728001',