Skip to content

Commit

Permalink
Version 0.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco8 committed Oct 22, 2023
1 parent bcb0423 commit 224978f
Show file tree
Hide file tree
Showing 4 changed files with 35 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.orange.spain"
name="Orange TV España"
version="0.7.1"
version="0.7.4"
provider-name="Paco8">
<requires>
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
Expand Down
Binary file added resources/icons/continue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/icons/mylist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 34 additions & 6 deletions resources/lib/orange.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, config_directory):
'Origin': 'https://orangetv.orange.es',
'Referer': 'https://orangetv.orange.es/',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0'
#'User-Agent': 'okhttp/4.10.0'
}
self.net = Network()
self.net.headers = headers
Expand Down Expand Up @@ -86,8 +87,10 @@ def __init__(self, config_directory):
self.search_list = json.loads(data) if data else []

def load_json(self, url, check_errors = True):
#print(url)
headers = self.net.headers.copy()
headers['Cookie'] = self.cookie
#print_json(headers)
content = self.net.load_url(url, headers)
data = json.loads(content)
if check_errors and ('response' in data) and ('status' in data['response']) and data['response']['status'] == 'FAILURE':
Expand Down Expand Up @@ -904,16 +907,34 @@ def get_channels_list(self):
return res
"""

def download_bouquet(self):
url = endpoints['get-bouquet-list']
data = self.load_json(url)
self.cache.save_file('bouquet.json', json.dumps(data, ensure_ascii=False))
return data

def download_channels(self, bouquet):
url = endpoints['get-channel-list'].format(bouquet_id=bouquet, model_external_id=self.device['type'])
headers = self.net.headers.copy()
headers['Cookie'] = self.cookie
response = self.net.session.get(url, headers=headers)
content = response.content.decode('utf-8')
data = json.loads(content)
self.cache.save_file('channels2.json', json.dumps(data, ensure_ascii=False))

# Get response cookies
cookie_dict = requests.utils.dict_from_cookiejar(response.cookies)
response_cookie = '; '.join([key + '=' + value for key, value in cookie_dict.items()])
return data, response_cookie

def get_channels_list(self):
res = []

content = self.cache.load('bouquet.json')
if content:
data = json.loads(content)
else:
url = endpoints['get-bouquet-list']
data = self.load_json(url)
self.cache.save_file('bouquet.json', json.dumps(data, ensure_ascii=False))
data = self.download_bouquet()

#LOG(json.dumps(data, indent=4))
bouquet = data['response'][0]['id']
Expand All @@ -922,9 +943,7 @@ def get_channels_list(self):
if content:
data = json.loads(content)
else:
url = endpoints['get-channel-list'].format(bouquet_id=bouquet, model_external_id=self.device['type'])
data = self.load_json(url)
self.cache.save_file('channels2.json', json.dumps(data, ensure_ascii=False))
data, _ = self.download_channels(bouquet)

for d in data['response']:
t = {}
Expand Down Expand Up @@ -1187,6 +1206,15 @@ def login(self):
LOG('new cookie: {}'.format(new_cookie))
self.cookie = new_cookie

# Get missing part of the cookie from the channels response header
if True:
data = self.download_bouquet()
bouquet = data['response'][0]['id']
_, response_cookie = self.download_channels(bouquet)
LOG('response_cookie: {}'.format(response_cookie))
if response_cookie:
self.cookie = response_cookie +'; '+ self.cookie

self.cache.save_file('cookie.conf', self.cookie)
return True

Expand Down

0 comments on commit 224978f

Please sign in to comment.