Skip to content

Commit

Permalink
v.0.5.4p
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Oct 9, 2024
1 parent d46862d commit 3bef232
Show file tree
Hide file tree
Showing 30 changed files with 261 additions and 208 deletions.
2 changes: 1 addition & 1 deletion 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="plugin.video.pseudotv.live" version="0.5.4o" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.4p" name="PseudoTV Live" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="pvr.iptvsimple" version="21.8.0"/>
Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7ba6383b3801a48849929f7a94b16ac2
836fbdc58ebbb216068953a36651d863
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.pseudotv.live" version="0.5.4o" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.4p" name="PseudoTV Live" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="pvr.iptvsimple" version="21.8.0"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ msgid "Logo Resource"
msgstr ""

msgctxt "#30028"
msgid "Ratings"
msgid "Ratings Resource"
msgstr ""

msgctxt "#30029"
msgid "Bumpers"
msgid "Bumpers Resource"
msgstr ""

msgctxt "#30030"
msgid "Adverts"
msgid "Adverts Resource"
msgstr ""

msgctxt "#30031"
msgid "Trailers"
msgid "Trailers Resource"
msgstr ""

msgctxt "#30032"
Expand Down Expand Up @@ -1287,7 +1287,7 @@ msgid "Please wait for announcements to finish, Try again later..."
msgstr ""

msgctxt "#32149"
msgid "[COLOR=orange]Idle[/COLOR]"
msgid "[COLOR=orange][B]Idle[/B][/COLOR]"
msgstr ""

msgctxt "#32150"
Expand Down Expand Up @@ -1323,7 +1323,7 @@ msgid "Pending Changes..."
msgstr ""

msgctxt "#32158"
msgid "[COLOR=yellow]Waiting for pairing (%s)[/COLOR]"
msgid "[COLOR=yellow]Waiting for pairing ([B]%s[/B])[/COLOR]"
msgstr ""

msgctxt "#32159"
Expand Down Expand Up @@ -1762,5 +1762,5 @@ msgid "Force Autotune to run."
msgstr ""

msgctxt "#33182"
msgid "When [COLOR=orange]Idle[/COLOR] click to begin beacon; Within 15mins start another Kodi instance w/PseudoTV Live installed\nThe two instances will pair, enabled in Select Server list."
msgid "When [COLOR=orange][B]Idle[/B][/COLOR] click to begin beacon; Within 15mins start another Kodi instance w/PseudoTV Live installed\nThe two instances will pair, enabled in Select Server list."
msgstr ""
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def log(self, msg, level=xbmc.LOGDEBUG):


def getFileDate(self, file: str) -> str:
try: return datetime.datetime.fromtimestamp(pathlib.Path(xbmcvfs.translatePath(file)).stat().st_mtime).strftime(BACKUP_TIME_FORMAT)
try: return datetime.datetime.fromtimestamp(pathlib.Path(FileAccess.translatePath(file)).stat().st_mtime).strftime(BACKUP_TIME_FORMAT)
except: return LANGUAGE(32105) #Unknown


Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def buildList(self, citem: dict, path: str, media: str='video', page: int=SETTIN
item['art'] = (item.get('art',{}) or dirItem.get('art',{}))
item.get('art',{})['icon'] = citem['logo']

if item.get('trailer') and self.bctTypes['trailers'].get('enabled',False) and self.bctTypes['trailers'].get('incKODI',False):
if item.get('trailer') and self.bctTypes['trailers'].get('enabled',False):
titem = item.copy()
tdur = self.jsonRPC.getDuration(titem.get('trailer'), accurate=True, save=False)
if tdur > 0:
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get(self, name, checksum=ADDON_VERSION, json_data=False):
def clear(self, name, wait=15):
import sqlite3
self.log('clear, name = %s'%self.getname(name))
sc = xbmcvfs.translatePath(xbmcaddon.Addon(id='script.module.simplecache').getAddonInfo('profile'))
sc = FileAccess.translatePath(xbmcaddon.Addon(id='script.module.simplecache').getAddonInfo('profile'))
dbpath = os.path.join(sc, 'simplecache.db')
connection = sqlite3.connect(dbpath, timeout=wait, isolation_level=None)
try:
Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def delChannel(self, citem: dict={}) -> bool:


def addChannel(self, citem: dict={}) -> bool:
idx, channel = self.findChannel(citem)
idx, channel = self.findChannel(citem)
if idx is not None:
for key in ['id','rules','number','favorite','logo']:
if channel.get(key): citem[key] = channel[key] # existing id found, reuse channel meta.
Expand Down
12 changes: 6 additions & 6 deletions plugin.video.pseudotv.live/resources/lib/cqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def __start(self):

def __run(self, func, args=(), kwargs=None):
self.log("__run, func = %s"%(func.__name__))
try: return func(*args, **kwargs)
try: return executeit(func)(*args, **kwargs)
#return func(*args, **kwargs)
except Exception as e: self.log("__run, func = %s failed! %s"%(func.__name__,e), xbmc.LOGERROR)


Expand All @@ -72,6 +73,7 @@ def __exists(self, package):
if epackage == package[2]:
if epriority <= package[1]: return True
else:
self.log("__exists, pop func = %s"%(epackage[0].__name__))
self.min_heap.pop(idx)
return False
return False
Expand All @@ -81,7 +83,7 @@ def _push(self, package: tuple, priority: int=0, delay: int=0):
self.log("_push, func = %s"%(package[0].__name__))
node = LlNode(package, priority, delay)
if self.__exists((1,priority,package)):
self.log("_push, exists... ignoring package")
self.log("_push, %s exists; ignoring package"%(package[2]))
return
elif self.priority:
self.qsize += 1
Expand Down Expand Up @@ -114,11 +116,10 @@ def __pop(self):
self.log("__pop, The queue is empty!")
break

if self.priority:
elif self.priority:
if not self.min_heap:
self.log("__pop, The priority queue is empty!")
break

min_num, _, package = heapq.heappop(self.min_heap)
self.qsize -= 1
self.__run(*package)
Expand All @@ -135,8 +136,7 @@ def __pop(self):
if self.fifo: self.head = next_node
else: self.tail = next_node

if not self.delay:
package, self.__run(*package)
if not self.delay: package, self.__run(*package)
else:
popTimer = Timer(curr_node.wait, *package)
if popTimer.is_alive(): popTimer.join()
Expand Down
1 change: 1 addition & 0 deletions plugin.video.pseudotv.live/resources/lib/fileaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def listdir(path):

@staticmethod
def translatePath(path):
if '@' in path: path = path.split('@')[1]
return xbmcvfs.translatePath(path)


Expand Down
36 changes: 19 additions & 17 deletions plugin.video.pseudotv.live/resources/lib/fillers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _parseLocal(path):
if FileAccess.exists(path): return self.jsonRPC.walkListDirectory(path,exts=VIDEO_EXTS,depth=CHANNEL_LIMIT,chkDuration=True)

def _parseVFS(path):
if hasAddon(id, install=True): return self.jsonRPC.walkFileDirectory(path,depth=CHANNEL_LIMIT,chkDuration=True,retItem=True)
if hasAddon(path, install=True): return self.jsonRPC.walkFileDirectory(path,depth=CHANNEL_LIMIT,chkDuration=True,retItem=True)

def _parseResource(id):
if hasAddon(id, install=True): return self.jsonRPC.walkListDirectory(os.path.join('special://home/addons/%s'%id,'resources'),exts=VIDEO_EXTS,depth=CHANNEL_LIMIT,checksum=self.jsonRPC.getAddonDetails(id).get('version',ADDON_VERSION),expiration=datetime.timedelta(days=MAX_GUIDEDAYS))
Expand All @@ -78,11 +78,11 @@ def __sortItems(data, stype='folder'):
for path, files in list(data.items()):
key = (os.path.basename(os.path.normpath(path)).replace('\\','/').strip('/').split('/')[-1:][0]).lower()
for file in files:
if stype == 'plugin': [tmpDCT.setdefault(key,[]).append(file) for key in (file.get('genre',[]) or ['resources'])]
if stype == 'plugin': [tmpDCT.setdefault(key.lower(),[]).append(file) for key in (file.get('genre',[]) or ['resources'])]
else:
if stype == 'file': key = file.split('.')[0].lower()
dur = self.jsonRPC.getDuration(os.path.join(path,file), accurate=True)
if dur > 0: tmpDCT.setdefault(key,[]).append({'file':os.path.join(path,file),'duration':dur,'label':'%s - %s'%(path.strip('/').split('/')[-1:][0],file.split('.')[0])})
if dur > 0: tmpDCT.setdefault(key.lower(),[]).append({'file':os.path.join(path,file),'duration':dur,'label':'%s - %s'%(path.strip('/').split('/')[-1:][0],file.split('.')[0])})
return tmpDCT

try:
Expand Down Expand Up @@ -179,19 +179,21 @@ def injectBCTs(self, citem, fileList):
# post roll - adverts/trailers
if len(postFileList) > 0:
self.log('injectBCTs, post-roll current runtime %s, available runtime %s, available content %s'%(runtime, postFillRuntime,len(postFileList)))
while not self.builder.service.monitor.abortRequested() and postFillRuntime > 0 and len(postFileList) > 0 and postFillCount > 0:
while not self.builder.service.monitor.abortRequested() and postFillRuntime > 0 and postFillCount > 0:
if self.builder.service._interrupt(): break
item = postFileList.pop(0)
if (item.get('duration') or 0) == 0: continue
elif postFillRuntime <= 0: break
elif postFillRuntime >= item.get('duration'):
postFillRuntime -= item.get('duration')
self.log('injectBCTs, adding post-roll %s - %s'%(item.get('duration'),item.get('file')))
if self.builder.pDialog: self.builder.pDialog = DIALOG.progressBGDialog(self.builder.pCount, self.builder.pDialog, message='Filling Post-Rolls',header='%s, %s'%(ADDON_NAME,self.builder.pMSG))
item.update({'title':'Post-Roll','episodetitle':item.get('label'),'genre':['Post-Roll'],'plot':item.get('plot',item.get('file')),'path':item.get('file')})
nfileList.append(self.builder.buildCells(citem,item.get('duration'),entries=1,info=item)[0])
elif postFillRuntime < item.get('duration'):
postFillCount -= 1
postFileList.append(item)
self.log('injectBCTs, unused post roll runtime %s'%(postFillRuntime))
elif len(postFileList) == 0: break
else:
item = postFileList.pop(0)
if (item.get('duration') or 0) == 0: continue
elif postFillRuntime <= 0: break
elif postFillRuntime >= item.get('duration'):
postFillRuntime -= item.get('duration')
self.log('injectBCTs, adding post-roll %s - %s'%(item.get('duration'),item.get('file')))
if self.builder.pDialog: self.builder.pDialog = DIALOG.progressBGDialog(self.builder.pCount, self.builder.pDialog, message='Filling Post-Rolls',header='%s, %s'%(ADDON_NAME,self.builder.pMSG))
item.update({'title':'Post-Roll','episodetitle':item.get('label'),'genre':['Post-Roll'],'plot':item.get('plot',item.get('file')),'path':item.get('file')})
nfileList.append(self.builder.buildCells(citem,item.get('duration'),entries=1,info=item)[0])
elif postFillRuntime < item.get('duration'):
postFillCount -= 1
postFileList.append(item)
if (self.builder.bctTypes['adverts']['auto'] and self.builder.bctTypes['trailers']['auto']): self.log('injectBCTs, unused post roll runtime %s'%(postFillRuntime))
return nfileList
6 changes: 3 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def hasFile(file):
else: return FileAccess.exists(file)

def hasAddon(id, install=False, enable=False, force=False, notify=False):
id = getIDbyPath(id)
if '://' in id: id = getIDbyPath(id)
if BUILTIN.getInfoBool('HasAddon(%s)'%(id),'System'):
if BUILTIN.getInfoBool('AddonIsEnabled(%s)'%(id),'System'): return True
elif enable:
Expand Down Expand Up @@ -328,7 +328,7 @@ def cleanLabel(text):
def cleanImage(image=LOGO):
if not image: image = LOGO
if not image.startswith(('image://','resource://','special://','smb://','nfs://','https://','http://')):
realPath = xbmcvfs.translatePath('special://home/addons/')
realPath = FileAccess.translatePath('special://home/addons/')
if image.startswith(realPath):# convert real path. to vfs
image = image.replace(realPath,'special://home/addons/').replace('\\','/')
elif image.startswith(realPath.replace('\\','/')):
Expand Down Expand Up @@ -366,7 +366,7 @@ def getIDbyPath(url):
try:
if url.startswith('special://'): return re.compile('special://home/addons/(.*?)/resources', re.IGNORECASE).search(url).group(1)
elif url.startswith('plugin://'): return re.compile('plugin://(.*?)/', re.IGNORECASE).search(url).group(1)
except Exception as e: log('Globals: getIDbyPath failed! %s'%(e), xbmc.LOGERROR)
except Exception as e: log('Globals: getIDbyPath failed! url = %s, %s'%(url,e), xbmc.LOGERROR)
return url

def combineDicts(dict1={}, dict2={}):
Expand Down
12 changes: 6 additions & 6 deletions plugin.video.pseudotv.live/resources/lib/json2table.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def convert(self, json_input):
"""
html_output = self._table_opening_tag
if self._build_top_to_bottom:
html_output += self._markup_header_row(json_input.keys())
html_output += self._markup_header_row(list(json_input.keys()))
html_output += "<tr>"
for value in json_input.values():
for value in list(json_input.values()):
if isinstance(value, list):
# check if all keys in the list are identical
# and group all values under a common column
Expand All @@ -98,7 +98,7 @@ def convert(self, json_input):
html_output += self._markup_table_cell(value)
html_output += "</tr>"
else:
for key, value in iter(json_input.items()):
for key, value in iter(list(json_input.items())):
html_output += "<tr><th>{:s}</th>".format(self._markup(key))
if isinstance(value, list):
html_output += self._maybe_club(value)
Expand Down Expand Up @@ -161,7 +161,7 @@ def _dict_to_html_attributes(d):
if d is None:
return ""

return "".join(" {}=\"{}\"".format(key, value) for key, value in iter(d.items()))
return "".join(" {}=\"{}\"".format(key, value) for key, value in iter(list(d.items())))

@staticmethod
def _list_of_dicts_to_column_headers(list_of_dicts):
Expand All @@ -183,9 +183,9 @@ def _list_of_dicts_to_column_headers(list_of_dicts):
if len(list_of_dicts) < 2 or not all(isinstance(item, dict) for item in list_of_dicts):
return None

column_headers = list_of_dicts[0].keys()
column_headers = list(list_of_dicts[0].keys())
for d in list_of_dicts[1:]:
if len(d.keys()) != len(column_headers) or not all(header in d for header in column_headers):
if len(list(d.keys())) != len(column_headers) or not all(header in d for header in column_headers):
return None
return column_headers

Expand Down
29 changes: 13 additions & 16 deletions plugin.video.pseudotv.live/resources/lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,13 @@ def queDuration(self, item={}, duration=0, runtime=0):
'song' : {"method":"AudioLibrary.SetSongDetails" ,"params":{"songid" :item.get('id',-1) ,"runtime": runtime,"resume": {"position": item.get('position',0.0),"total": duration}}},
'songs' : {"method":"AudioLibrary.SetSongDetails" ,"params":{"songid" :item.get('songid',-1) ,"runtime": runtime,"resume": {"position": item.get('position',0.0),"total": duration}}}}
try:
if 'type' in item:
params = param[item['type']]
if -1 in params: raise Exception('no dbid found')
elif params:
if duration == 0: param['params'].pop('resume')
elif runtime == 0: param['params'].pop('runtime')
id = (item.get('id') or item.get('movieid') or item.get('episodeid') or item.get('musicvideoid') or item.get('songid'))
self.log('queDuration, id = %s, media = %s, duration = %s, runtime = %s'%(id,item['type'],duration,runtime))
self.queueJSON(params)
params = param.get(item.get('type'))
if params:
if duration == 0: param['params'].pop('resume')
elif runtime == 0: param['params'].pop('runtime')
id = (item.get('id') or item.get('movieid') or item.get('episodeid') or item.get('musicvideoid') or item.get('songid'))
self.log('queDuration, id = %s, media = %s, duration = %s, runtime = %s'%(id,item['type'],duration,runtime))
self.queueJSON(params)
except Exception as e: self.log("queDuration, failed! %s\nitem = %s"%(e,item), xbmc.LOGERROR)


Expand All @@ -377,9 +375,8 @@ def quePlaycount(self, item):
'songs' : {"method":"AudioLibrary.SetSongDetails" ,"params":{"songid" :item.get('songid',-1) ,"playcount": item.get('playcount',0),"resume": {"position": item.get('position',0.0),"total": item.get('total',0.0)}}}}
try:
if not item.get('file','').startswith(tuple(VFS_TYPES)):
params = param[item['type']]
if -1 in params: raise Exception('no dbid found')
elif params:
params = param.get(item.get('type'))
if params:
id = (item.get('id') or item.get('movieid') or item.get('episodeid') or item.get('musicvideoid') or item.get('songid'))
self.log('quePlaycount, id = %s, media = %s, playcount = %s, resume = %s'%(id,item['type'],item.get('playcount',0),item.get('resume',{})))
self.queueJSON(params)
Expand Down Expand Up @@ -522,18 +519,18 @@ def padItems(self, files, page=SETTINGS.getSettingInt('Page_Limit')):


@cacheit(expiration=datetime.timedelta(seconds=EPOCH_TIMER),json_data=False)
def getFriendlyName(self):
def InputFriendlyName(self):
with PROPERTIES.suspendActivity():
fn = self.getSettingValue("services.devicename")
self.log("getFriendlyName, name = %s"%(fn))
self.log("InputFriendlyName, name = %s"%(fn))
if not fn or fn.lower() == 'kodi':
if DIALOG.okDialog(LANGUAGE(32132)%(fn)):
input = DIALOG.inputDialog(LANGUAGE(30122), fn)
if not input or input.lower() == 'kodi':
return self.getFriendlyName()
return self.InputFriendlyName()
else:
self.setSettingValue("services.devicename",input)
self.log('getFriendlyName, setting device name = %s'%(input))
self.log('InputFriendlyName, setting device name = %s'%(input))
return input
return fn

Expand Down
Loading

0 comments on commit 3bef232

Please sign in to comment.