Skip to content

Commit

Permalink
Version 0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco8 committed Feb 20, 2024
1 parent bb7e7c2 commit c2020a4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 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.8.0"
version="0.8.1"
provider-name="Paco8">
<requires>
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from __future__ import unicode_literals, absolute_import, division

#API_URL = 'https://pc.orangetv.orange.es/pc/api/'
API_URL = 'https://smarttv.orangetv.orange.es/stb/api/'
API_URL = 'https://pc.orangetv.orange.es/pc/api/'
#API_URL = 'https://smarttv.orangetv.orange.es/stb/api/'
API_RTV = API_URL + 'rtv/v1/'
API_RECO = API_URL + 'reco/v1/'
API_IMAGES = API_RTV + 'images'
Expand Down
36 changes: 18 additions & 18 deletions resources/lib/orange.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def __init__(self, config_directory):
'Accept-Language': 'es-ES,es;q=0.9',
'Origin': 'https://orangetv.orange.es',
'Referer': 'https://orangetv.orange.es/',
#'User-Agent': useragent,
'User-Agent': 'okhttp/4.10.0',
'User-Agent': useragent,
#'User-Agent': 'okhttp/4.10.0',
}
self.net = Network()
self.net.headers = headers
Expand Down Expand Up @@ -739,32 +739,32 @@ def search_vod(self, search_term, content_type):

return res

def download_epg(self, day = None):
def download_epg(self, datestr=None):
from datetime import datetime,timedelta

if day == None:
if not datestr:
cache_filename = 'epg.json'
day = datetime.today()
date = datetime.today()
days = 2
hours = []
for n in range(0, days):
datestr = date.strftime('%Y%m%d')
hours += [datestr+ '_8h_1', datestr + '_8h_2', datestr + '_8h_3']
date += timedelta(days=1)
else:
cache_filename = 'epg_' + day.strftime('%Y%m%d') + '.json'
days = 1
cache_filename = 'cache/epg_' + datestr + '.json'
hours = [datestr+ '_8h_1', datestr + '_8h_2', datestr + '_8h_3']

content = self.cache.load(cache_filename, 12*60)
if content:
return json.loads(content)

hours = []
for n in range(0, days):
datestr = day.strftime('%Y%m%d')
hours += [datestr+ '_8h_1', datestr + '_8h_2', datestr + '_8h_3']
day += timedelta(days=1)

epg = {}
for h in hours:
filename = h + '.json'
#url = 'https://epg.orangetv.orange.es/epg/Smartphone_Android/3_PRO/' + filename
url = 'https://epg.orangetv.orange.es/epg/Smartphone_Android/1_PRO/' + filename
#LOG(url)
data = self.load_json(url)

#print(data)
Expand All @@ -778,9 +778,9 @@ def download_epg(self, day = None):
self.cache.save_file(cache_filename, json.dumps(epg, ensure_ascii=False))
return epg

def get_epg(self):
def get_epg(self, date=None):
from datetime import datetime
channels = self.download_epg()
channels = self.download_epg(date)
epg = {}
for id in channels:
if not id in epg: epg[id] = []
Expand Down Expand Up @@ -1019,8 +1019,8 @@ def add_live_extra_info(self, program_id, t):
t['art'] = self.get_art(data['attachments'])
if 'prName' in data: t['info']['mpaa'] = data['prName'].replace('ML_', '')

def epg_to_movies(self, channel_id):
epg = self.get_epg()
def epg_to_movies(self, channel_id, date=None):
epg = self.get_epg(date=date)
videos = []
if not channel_id in epg: return videos
for p in epg[channel_id]:
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def login(self):
self.cookie = new_cookie

# Get missing part of the cookie from the channels response header
if False:
if '/pc/' in url:
#data = self.download_bouquet()
#bouquet = data['response'][0]['id']
#_, response_cookie = self.download_channels(bouquet)
Expand Down
11 changes: 10 additions & 1 deletion resources/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,17 @@ def list_vod():

def list_epg(params):
LOG('list_epg: {}'.format(params))
from datetime import datetime, timedelta
from .timeconv import my_strftime
if 'id' in params:
add_videos(params['name'], 'movies', o.epg_to_movies(params['id']))
if not 'date' in params:
today = datetime.today()
for i in range(6, 0, -1):
past_date = today - timedelta(days=i)
date_str = past_date.strftime('%Y%m%d')
display_str = my_strftime(past_date, '%a %d')
add_menu_option(display_str, get_url(action='epg', id=params['id'], name=params['name'], date=date_str))
add_videos(params['name'], 'movies', o.epg_to_movies(params['id'], params.get('date')))
else:
channels = o.get_channels_list()
open_folder(addon.getLocalizedString(30107)) # EPG
Expand Down
12 changes: 7 additions & 5 deletions resources/lib/timeconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

from datetime import datetime

weekdays = ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab']

def timestamp2str(timestamp, format='%H:%M'):
time = datetime.fromtimestamp(timestamp / 1000)
def my_strftime(time, format):
weekdays = ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab']
if '%a' in format:
w = int(time.strftime('%w'))
format = format.replace('%a', weekdays[w])
return time.strftime(format).capitalize()
return time.strftime(format)

def timestamp2str(timestamp, format='%H:%M'):
time = datetime.fromtimestamp(timestamp / 1000)
return my_strftime(time, format)

0 comments on commit c2020a4

Please sign in to comment.