Skip to content

Commit

Permalink
2.9.1 Repository
Browse files Browse the repository at this point in the history
  • Loading branch information
emveepee committed Dec 4, 2020
1 parent 12dc6d1 commit 829c1b5
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 253 deletions.
8 changes: 6 additions & 2 deletions 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="script.kodi.knewc" name="NextPVR New Client" version="2.8.0" provider-name="emveepee">
<addon id="script.kodi.knewc" name="NextPVR New Client" version="2.9.1" provider-name="emveepee">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<!--import addon="xbmc.python" version="2.1.0"/-->
<import addon="script.module.future" version="0.16.0.4"/>
<import addon="script.module.dateutil" version="2.7.3"/>
<import addon="script.module.kodi-six" />
Expand All @@ -14,5 +14,9 @@
<minversion>28764</minversion>
<summary lang="en">Python script to access NextPVR v4 or v5 using NEWA or v5 API</summary>
<description lang="en">Supplement NextPVR PVR Addon with additional functionality Compatible with python 2.7 or python 3</description>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
</extension>
</addon>
18 changes: 18 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[B]2.9.1[/B]
- Improved login logic
- Relogin on session change
UI Client
- Logic change for Back key stopping video

[B]2.9.0[/B]
- Remove warning on no data in EPG
- Matrix and Leia comnpatibility for repo
- PVR mode for in progress recordings using JSON RPC
- Improved PVR mode for live tv
- Save SID state on rentry
- Deprecated API change
- Fix error handling of ExtraDirectory call
UI Client
- Don't open window when loading channel icons
- Timeout http calls

[B]2.8.0[/B]
- Added linux mouse support (via xdo)
- This is rc4 with no other changes
Expand Down
2 changes: 2 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
else:
HomeWindow('nextpvr_home.xml', WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa).doModal()
else:
if my_settings.NextPVR_STREAM == 'PVR':
my_xnewa.GetNextPVRInfo(my_settings.NextPVR_USER, my_settings.NextPVR_PW, False)
ew = EmulateWindow("nextpvr_emulate.xml", WHERE_AM_I,my_settings.XNEWA_SKIN, settings=my_settings, xnewa=my_xnewa)
ew.doModal()
else:
Expand Down
2 changes: 1 addition & 1 deletion repo/addons.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addons>
<addon id="script.kodi.knewc" name="NextPVR New Client" version="2.9.0" provider-name="emveepee">
<addon id="script.kodi.knewc" name="NextPVR New Client" version="2.9.1" provider-name="emveepee">
<requires>
<!--import addon="xbmc.python" version="2.1.0"/-->
<import addon="script.module.future" version="0.16.0.4"/>
Expand Down
2 changes: 1 addition & 1 deletion repo/addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1f9d171ee2cfa59e3a85592044368fb4
3a5d7e20cdc99f66587869677ebb8780
Binary file added repo/script.kodi.knewc-2.9.1.zip
Binary file not shown.
34 changes: 26 additions & 8 deletions resources/src/KNEW_Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,18 @@ def doRequest5(self, method, isJSON = True):
json_file = urlopen(request)
getResult = _json.load(json_file)
json_file.close()
if 'stat' in getResult and getResult['stat'] != 'ok':
if getResult['code'] == 8 and not method.startswith('session'):
sidLogin5(self)
if self.offline == False:
return doRequest5(self, method)
else:
retval = True
else:
response = urlopen(url)
getResult = response.read()
response.close()
retval = True
retval = True
except HTTPError as e:
print (e)
xbmc.log("HTTPError")
Expand All @@ -83,9 +90,18 @@ def doRequest5(self, method, isJSON = True):

def sidLogin5(self):
self.settings.XNEWA_INTERFACE = "Version5"
#self.settings.XNEWA_WEBCLIENT = True

method = 'session.initiate&ver=1.0&device=emby'
cached = 'sid.p'
if self.checkCache(cached):
login = self.myCachedPickleLoad(cached)
self.sid = login['sid']
method = 'session.valid'
ret, keys = doRequest5(self,method)
if ret == True and keys['stat'] == 'ok':
xbmc.log(self.sid)
setClient5(self)
self.offline = False
return
method = 'session.initiate&ver=1.0&device=jellyfin'
ret, keys = doRequest5(self,method)
if ret == True:
self.sid = keys['sid']
Expand All @@ -100,6 +116,7 @@ def sidLogin5(self):
xbmc.log(self.sid)
setClient5(self)
self.offline = False
self.myCachedPickle(keys,cached)
else:
self.sid = 'xnewa'
else:
Expand Down Expand Up @@ -142,7 +159,7 @@ def getRecDirList_v5(self):
try:
dirs[extras[i]] = extras[i+1]
except:
xbmc.log('Duplicate of ' + dirs[extras[i]])
xbmc.log('Setting error ' + setting['value'])

xbmc.log("getRecDirList v5 end")
return dirs
Expand All @@ -163,7 +180,7 @@ def getChannelList_v5(self):
for channel in channels['channels']:
if (channel['channelIcon']):
cnt= cnt+1
if cnt > 0:
if cnt > 0 and self.settings.XNEWA_WEBCLIENT == False:
icons = glob.glob(os.path.join(self.cached_channelPath,'*.*'))
if cnt > len(icons) + 20:
myDlg = xbmcgui.DialogProgress()
Expand Down Expand Up @@ -210,7 +227,8 @@ def getChannelList_v5(self):
pass
except Exception as err:
xbmc.log(str(err))

if myDlg != None:
myDlg.close()
xbmc.log("getChannelList v5 end")
return dic

Expand Down Expand Up @@ -833,4 +851,4 @@ def strptimeKodi(date_string,format):
return datetime.strptime(date_string, format)
except TypeError:
return datetime(*(time.strptime(date_string, format)[0:6]))
return None
return None
4 changes: 2 additions & 2 deletions resources/src/XNEWAGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@

# Script doc constants
__scriptname__ = "knewc"
__version__ = '2.8.0'
__version__ = '2.9.1'
__author__ = 'emveepee'
__original_author__ = 'Ton van der Poel'
__date__ = '2020-01-19'
__date__ = '2020-12-03'

XBMC_DIALOG_BUSY_OPEN = "ActivateWindow(busydialognocancel)"
XBMC_DIALOG_BUSY_CLOSE = "Dialog.Close(busydialognocancel)"
Expand Down
68 changes: 52 additions & 16 deletions resources/src/XNEWA_Connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
from XNEWAGlobals import *
import http.client

if sys.version_info[0] >= 3:
pseudovfs = xbmcvfs
else:
pseudovfs = xbmc

if sys.version_info >= (2, 7):
import json as _json
else:
Expand All @@ -65,8 +70,8 @@


__language__ = xbmcaddon.Addon().getLocalizedString
DATAROOT = xbmc.translatePath( 'special://profile/addon_data/%s' % xbmcaddon.Addon().getAddonInfo('id') )
CACHEROOT = os.path.join(xbmc.translatePath('special://temp'), 'knew5')
DATAROOT = pseudovfs.translatePath( 'special://profile/addon_data/%s' % xbmcaddon.Addon().getAddonInfo('id') )
CACHEROOT = os.path.join(pseudovfs.translatePath('special://temp'), 'knew5')

class XNEWA_Connect(object):

Expand Down Expand Up @@ -121,6 +126,8 @@ def __init__(self, *args, **kwargs):
self.channels = None
self.update_time = 9223372036854775807
self.isdst = time.localtime(time.time()).tm_isdst
self.PVRRecordings = {}

if self.isdst == 1:
xbmc.log ('atz ' + str(time.altzone))
self.my_offset = timedelta(seconds=time.altzone)
Expand Down Expand Up @@ -153,6 +160,7 @@ def __init__(self, *args, **kwargs):
self.sid = None
self.client = None
self.strClient = None
self.mycache = CACHEROOT

######################################################################################################
# checking to see if NEWA is responding
Expand All @@ -164,8 +172,6 @@ def __init__(self, *args, **kwargs):
if self.sid == None:
self.offline = True

self.mycache = CACHEROOT

######################################################################################################
# Setting up fanart defaults
######################################################################################################
Expand Down Expand Up @@ -263,6 +269,30 @@ def getPVRChannels(self):
channels = None
return channels

#################################################################################################################
def GetPVRRecordings(self):
self.PVRRecordings = {}
from nextpvr.XBMCJSON import XBMCJSON
myJSON = XBMCJSON()
param = {}
param['properties'] = [ 'file' ]
param['limits'] = {'start': 0}
response = myJSON.PVR.GetRecordings(param)
if 'result' in response:
for recording in response['result']['recordings']:
m = re.search('.+ (.+?).pvr', recording['file'])
if m != None:
self.PVRRecordings[m.group(1)] = recording['file']
xbmc.log('Number of recordings: {}'.format(len(self.PVRRecordings)))

#################################################################################################################
def GetPVRRecording(self, recid):
pvr = self.PVRRecordings.get(recid)
if pvr == None:
self.GetPVRRecordings()
pvr = self.PVRRecordings.get(recid)
return pvr

######################################################################################################
# Starting streaming by vlc schedule oid
######################################################################################################
Expand Down Expand Up @@ -398,7 +428,7 @@ def sendTranscodeHeartbeat(self):
xml_file = urlopen(request, timeout=4)
xml_return = xml_file.read()
if 'stat="ok"' not in xml_return:
xbmc.player.stop()
xbmc.Player.stop()
xbmc.log(xml_return)
except Exception as err:
xbmc.log(str(err))
Expand Down Expand Up @@ -471,6 +501,9 @@ def GetNextPVRInfo(self, userid, password,channels=True):
dic['log'] = dict
else:
dic = GetNextPVRInfo_v5 (self)
else:
self.channels = self.getChannelList()

if channels == True:
# We also get, and cache, the channel data
self.channels = self.getChannelList()
Expand Down Expand Up @@ -500,21 +533,24 @@ def getRecordingUpdate(self):
if err.attrib['code'] == '8':
xbmc.log(err.attrib['msg'])
self.sid = None
self.sidLogin()
except Exception as err:
xbmc.log(str(err))
return self.update_time

def checkCache(self,cached):
if os.path.isfile(os.path.join(self.mycache,cached)) == True:
if self.offline == True:
return True
if self.update_time != 9223372036854775807:
update_time = self.update_time
self.getRecordingUpdate()
if update_time == self.update_time:
if self.update_time <= int(os.path.getmtime(os.path.join(self.mycache,cached))):
return True
return False
if not cached.endswith('sid.p'):
if self.offline == True:
return True
if self.update_time != 9223372036854775807:
update_time = self.update_time
self.getRecordingUpdate()
if update_time == self.update_time:
if self.update_time <= int(os.path.getmtime(os.path.join(self.mycache,cached))):
return True
return False

ft = datetime.fromtimestamp(os.path.getmtime(os.path.join(self.mycache,cached)))
if ft + timedelta(hours=2) > datetime.now():
return True
Expand Down Expand Up @@ -683,7 +719,7 @@ def getChannelList_json(self):
chan = channel['channel']
if chan['channelIcon'] != '':
cnt= cnt+1
if cnt > 0:
if cnt > 0 and self.settings.NextPVR_STREAM != 'PVR':
icons = glob.glob(os.path.join(self.cached_channelPath,'*.*'))
if cnt > len(icons) + 20:
myDlg = xbmcgui.DialogProgress()
Expand Down Expand Up @@ -2328,7 +2364,7 @@ def _detail2array_json(self, detailsService,fetchArt=False):
else:
dict['subtitle'] = ""

if detail['OID'] is not 0:
if detail['OID'] != 0:
dict['channel_oid'] = detail['ChannelOid']
else:
dict['channel_oid'] = rec.OID
Expand Down
1 change: 1 addition & 0 deletions resources/src/XNEWA_Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def loadFromSettingsXML(self):
self.XNEWA_SORT_RECORDING = int(addon.getSetting("recordingSort"))
self.XNEWA_SORT_EPISODE = int(addon.getSetting("episodeSort"))
self.NextPVR_STREAM = addon.getSetting("stream")
xbmc.log('Streaming mode: ' + self.NextPVR_STREAM)

self.XNEWA_PREBUFFER = int(addon.getSetting("prebuffer")) // 4
self.XNEWA_POSTBUFFER = int(addon.getSetting("postbuffer")) // 4
Expand Down
Loading

0 comments on commit 829c1b5

Please sign in to comment.