Skip to content

Commit

Permalink
Version 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco8 committed Mar 25, 2023
1 parent e11daa6 commit 6291e68
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 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.3"
version="0.1.4"
provider-name="Paco8">
<requires>
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
Expand Down
45 changes: 25 additions & 20 deletions resources/lib/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,6 @@ def __init__(self, config_directory, platform='skyshowtime'):
self.platform['device_id'] = self.create_device_id()
self.cache.save_file(self.pldir + '/device_id.conf', self.platform['device_id'])

# Load localisation
localisation_filename = self.pldir + '/localisation.json'
content = self.cache.load_file(localisation_filename)
if content:
extra_headers = json.loads(content)
else:
extra_headers = self.get_localisation()
if 'headers' in extra_headers:
self.cache.save_json(localisation_filename, data)
if extra_headers and 'headers' in extra_headers:
h = extra_headers['headers']
self.platform['headers'].update({
'x-skyott-activeterritory': h.get('x-skyott-activeterritory'),
'x-skyott-language': h.get('x-skyott-language'),
'x-skyott-territory': h.get('x-skyott-territory'),
})
self.net.headers.update(self.platform['headers'])
#print_json(self.net.headers)

# Load profile
content = self.cache.load_file(self.pldir + '/profile.json')
if content:
Expand All @@ -141,6 +122,25 @@ def __init__(self, config_directory, platform='skyshowtime'):
if data and 'userToken' in data:
self.account['user_token'] = data['userToken']

# Load localisation
localisation_filename = self.pldir + '/localisation.json'
content = self.cache.load_file(localisation_filename)
if content:
extra_headers = json.loads(content)
else:
extra_headers = self.get_localisation()
if 'headers' in extra_headers:
self.cache.save_json(localisation_filename, data)
if extra_headers and 'headers' in extra_headers:
h = extra_headers['headers']
self.platform['headers'].update({
'x-skyott-activeterritory': h.get('x-skyott-activeterritory'),
'x-skyott-language': h.get('x-skyott-language'),
'x-skyott-territory': h.get('x-skyott-territory'),
})
self.net.headers.update(self.platform['headers'])
#print_json(self.net.headers)

# Search
data = self.cache.load_file('searchs.json')
self.search_list = json.loads(data) if data else []
Expand Down Expand Up @@ -409,10 +409,14 @@ def get_localisation(self):
url = self.endpoints['localisation']
headers = self.net.headers.copy()
headers['Accept'] = 'application/vnd.localisationinfo.v1+json'
headers['cookie'] = self.account['cookie']
#headers['cookie'] = self.account['cookie']
headers['x-skyott-provider'] = self.platform['headers']['x-skyott-provider']
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)
data = self.net.load_data(url, headers)
LOG('get_localisation: data: {}'.format(data))
return data

def get_me(self):
Expand Down Expand Up @@ -459,6 +463,7 @@ def get_tokens(self):
sig_header = self.sig.calculate_signature('POST', url, headers, post_data)
headers.update(sig_header)
data = self.net.post_data(url, post_data, headers)
LOG('get_tokens: data: {}'.format(data))
return data

def request_playback_tokens(self, url, post_data, content_type, preferred_server=''):
Expand Down

0 comments on commit 6291e68

Please sign in to comment.