Skip to content

Commit

Permalink
Version 0.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco8 committed Mar 31, 2023
1 parent a87d52b commit e1dc3ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.skyott"
name="Peacock"
version="0.1.9"
version="0.1.10"
provider-name="Paco8">
<requires>
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, host='skyshowtime.com'):
'get-video-info-uuid': atom + '/adapter-calypso/v3/query/nodes/uuid/{uuid}?exclude=expired%2Cfuture%2Cshortform',
'login': rango +'/signin/service/international',
'profiles': webclients +'/bff/personas/v2',
'select-profile': webclients + '/bff/personas/v2/{profile_id}?skipPinValidation=true',
'get-profile-info': webclients + '/bff/personas/v2/{profile_id}?skipPinValidation=true',
'my-stuff': webclients + '/bff/sections/v1?partition_id=no-partition&template=sections&segment=default&slug=%2Fmy-stuff',
'my-list': webclients + '/bff/sections/v1/personalised?partition_id=no-partition&template=sections&segment=default&slug={slug}&filter=byw&filter=pg&filter=wl&filter=cw',
'localisation': ovp + '/ls/localisation',
Expand Down
36 changes: 31 additions & 5 deletions resources/lib/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SkyShowtime(object):
'x-skyott-activeterritory': 'ES',
'x-skyott-client-version': '4.3.12',
'x-skyott-device': 'COMPUTER',
'x-skyott-language': 'es-ES',
'x-skyott-language': 'en-US',
'x-skyott-platform': 'PC',
'x-skyott-proposition': 'SKYSHOWTIME',
'x-skyott-provider': 'SKYSHOWTIME',
Expand Down Expand Up @@ -129,6 +129,18 @@ def __init__(self, config_directory, platform='skyshowtime'):
else:
self.account['profile_id'], self.account['profile_type'] = self.select_default_profile()

if self.account['profile_id']:
profile_info_filename = self.pldir + '/profile_info.json'
content = self.cache.load_file(profile_info_filename)
if content:
data = json.loads(content)
else:
data = self.get_profile_info(self.account['profile_id'])
self.cache.save_json(profile_info_filename, data)
if 'persona' in data and 'displayLanguage' in data['persona']:
self.platform['headers']['x-skyott-language'] = data['persona']['displayLanguage']
self.net.headers.update(self.platform['headers'])

# Load user token
token_filename = self.pldir + '/token.json'
content = self.cache.load(token_filename, 60)
Expand Down Expand Up @@ -339,7 +351,7 @@ def login(self, username='', password=''):
#print_json(data)
if data.get('properties', []).get('eventType') == 'success':
device_id = data['properties']['data']['deviceid']
self.account['device_id'] = device_id
#self.account['device_id'] = device_id
self.account['cookie'] += '; deviceid=' + device_id
cookie_filename = self.pldir + '/cookie.conf'
self.cache.save_file(cookie_filename, self.account['cookie'])
Expand Down Expand Up @@ -379,7 +391,9 @@ def change_profile(self, id):
for profile in profiles:
if profile['id'] == id:
self.cache.save_json(self.pldir + '/profile.json', profile)
self.cache.remove_file(self.pldir + '/token.json')
files = ['profile_info.json', 'token.json', 'menu.json']
for f in files:
self.cache.remove_file(self.pldir +'/'+ f)
return
else:
LOG('profile {} not found'.format(id))
Expand Down Expand Up @@ -414,7 +428,8 @@ def get_localisation(self):
headers['x-skyott-proposition'] = self.platform['headers']['x-skyott-proposition']
sig_header = self.sig.calculate_signature('GET', url, headers)
headers.update(sig_header)
print_json(headers)
#print_json(headers)
LOG(headers)
data = self.net.load_data(url, headers)
LOG('get_localisation: data: {}'.format(data))
return data
Expand All @@ -429,6 +444,17 @@ def get_me(self):
sig_header = self.sig.calculate_signature('GET', url, headers)
headers.update(sig_header)
data = self.net.load_data(url, headers)
#self.cache.save_json('me.json', data)
return data

def get_profile_info(self, profile_id):
url = self.endpoints['get-profile-info'].format(profile_id=profile_id)
headers = self.net.headers.copy()
headers['Content-Type'] = 'application/json'
headers['cookie'] = self.account['cookie']
sig_header = self.sig.calculate_signature('GET', url, headers)
headers.update(sig_header)
data = self.net.load_data(url, headers)
return data

def create_device_id(self):
Expand Down Expand Up @@ -773,6 +799,6 @@ def install_cookie_file(self, filename):
shutil.copyfile(filename, self.cache.config_directory + self.pldir + '/cookie.conf')

def clear_session(self):
files = ['device_id.conf', 'localisation.json', 'profile.json', 'token.json', 'menu.json']
files = ['device_id.conf', 'localisation.json', 'profile.json', 'profile_info.json', 'token.json', 'menu.json']
for f in files:
self.cache.remove_file(self.pldir +'/'+ f)

0 comments on commit e1dc3ad

Please sign in to comment.