Skip to content

Commit

Permalink
v.0.5.5a
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Oct 13, 2024
1 parent 656a746 commit 9f5b968
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 52 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.5" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.5a" 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 @@
c96490572b16d3f6738f3bbb407e8f1c
dbb27ab5565e28dea30198d829d519b0
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.5" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.5a" 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
16 changes: 8 additions & 8 deletions plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ def getFileList(self, citem: dict, now: time, start: time) -> bool and list:

def buildCells(self, citem: dict={}, duration: int=10800, type: str='video', entries: int=3, info: dict={}) -> list:
self.log("buildCells; id: %s"%(citem.get('id')))
tmpItem = {'label' : (info.get('title','') or citem['name']),
'episodetitle': (info.get('episodetitle','') or '|'.join(citem['group'])),
'plot' : (info.get('plot' ,'') or LANGUAGE(30161)),
'genre' : (info.get('genre','') or ['Undefined']),
'file' : (info.get('path','') or '|'.join(citem.get('path'))),
'art' : (info.get('art','') or {"thumb":COLOR_LOGO,"fanart":FANART,"logo":LOGO,"icon":LOGO}),
tmpItem = {'label' : (info.get('title') or citem['name']),
'episodetitle': (info.get('episodetitle') or '|'.join(citem['group'])),
'plot' : (info.get('plot') or LANGUAGE(30161)),
'genre' : (info.get('genre') or ['Undefined']),
'file' : (info.get('path') or '|'.join(citem.get('path'))),
'art' : (info.get('art') or {"thumb":COLOR_LOGO,"fanart":FANART,"logo":LOGO,"icon":LOGO}),
'type' : type,
'duration' : duration,
'start' : 0,
Expand Down Expand Up @@ -346,8 +346,8 @@ def buildList(self, citem: dict, path: str, media: str='video', page: int=SETTIN
if self.pDialog:
self.pDialog = DIALOG.progressBGDialog(self.pCount, self.pDialog, message='%s: %s'%(self.pName,int(idx*100)//page)+'%',header='%s, %s'%(ADDON_NAME,self.pMSG))

title = (item.get("title",'') or item.get("label",'') or dirItem.get('label',''))
tvtitle = (item.get("showtitle",'') or item.get("label",'') or dirItem.get('label',''))
title = (item.get("title") or item.get("label") or dirItem.get('label') or '')
tvtitle = (item.get("showtitle") or item.get("label") or dirItem.get('label') or '')

if (item['type'].startswith(tuple(TV_TYPES)) or item.get("showtitle")):# This is a TV show
season = int(item.get("season","0"))
Expand Down
3 changes: 1 addition & 2 deletions plugin.video.pseudotv.live/resources/lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def clear(self, name, wait=15):
connection.execute('DELETE FROM simplecache WHERE id LIKE ?', (self.getname(name) + '%',))
connection.commit()
connection.close()
except sqlite3.Error as e:
self.log('clear, failed! %s'%(e), xbmc.LOGERROR)
except sqlite3.Error as e: self.log('clear, failed! %s'%(e), xbmc.LOGERROR)
finally:
del connection
del sqlite3
4 changes: 2 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/cqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __start(self):

def __run(self, func, args=None, kwargs=None):
self.log("__run, func = %s"%(func.__name__))
try: return self.pool.executor(func, (EPOCH_TIMER*60), *args, *kwargs) # if self.service.player.isPlaying(): return func(*args, **kwargs)
try: return self.pool.executor(func, (EPOCH_TIMER*60), *args, *kwargs) # if self.service.player.isPlaying(): return func(*args, **kwargs)
except Exception as e: self.log("__run, func = %s failed! %s\nargs = %s, kwargs = %s"%(func.__name__,e,args,kwargs), xbmc.LOGERROR)


Expand All @@ -75,7 +75,7 @@ def __exists(self, package):
if epriority <= package[1]: return True
else:
self.log("__exists, pop func = %s"%(epackage[0].__name__))
try: self.min_heap.pop(idx)
try: self.min_heap.pop(idx)
except: pass
return False
return False
Expand Down
20 changes: 10 additions & 10 deletions plugin.video.pseudotv.live/resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ def unescapeString(text, table=HTML_ESCAPE):
return unescape(text,{v:k for k, v in list(table.items())})

def getJSON(file):
fle = (FileAccess.open(file, 'r') or '')
data = {}
try: data = loadJSON(fle.read())
except Exception as e: log('Globals: getJSON failed! %s'%(e), xbmc.LOGERROR)
try:
fle = FileAccess.open(file,'r')
data = loadJSON(fle.read())
except Exception as e: log('Globals: getJSON failed! %s\nfile = %s'%(e,file), xbmc.LOGERROR)
fle.close()
return data

Expand All @@ -115,15 +116,15 @@ def getURL(url, data={}, header=HEADER, json_data=False):
log("Globals: getURL, status = %s"%(r.status_code))
if json_data: return r.json()
else: return r.text
except Exception as e: pass
except Exception as e: log('Globals: getURL failed! %s\nurl = %s'%(e,url), xbmc.LOGERROR)

def postURL(url, params={}, header=HEADER, json_data=False):
try:
r = requests.post(url, data=params ,headers=HEADER.update(header))
log("Globals: postURL, url = %s, status = %s"%(r.url,r.status_code))
if json_data: return r.json()
else: return r.text
except Exception as e: pass
except Exception as e: log('Globals: postURL failed! %s\nurl = %s'%(e,url), xbmc.LOGERROR)

def setURL(url, file):
try:
Expand All @@ -132,8 +133,7 @@ def setURL(url, file):
fle.write(contents)
fle.close()
return FileAccess.exists(file)
except Exception as e:
log("Globals: saveURL, failed! %s"%e, xbmc.LOGERROR)
except Exception as e: log('Globals: setURL failed! %s\nurl = %s'%(e,url), xbmc.LOGERROR)

def diffLSTDICT(old, new):
sOLD = set([dumpJSON(e) for e in old])
Expand Down Expand Up @@ -188,10 +188,10 @@ def cleanChannelSuffix(name, type):
return name

def getLabel(item, addYear=False):
label = (item.get('name','') or item.get('label','') or item.get('showtitle','') or item.get('title',''))
label = (item.get('name') or item.get('label') or item.get('showtitle') or item.get('title'))
if not label: return ''
label, year = splitYear(label)
year = (item.get('year','') or year)
year = (item.get('year') or year)
if year and addYear: return '%s (%s)'%(label, year)
return label

Expand Down Expand Up @@ -301,7 +301,7 @@ def togglePVR(state=True, reverse=False, wait=EPOCH_TIMER):
else: DIALOG.notificationWait(LANGUAGE(30023)%(PVR_CLIENT_NAME))

def isRadio(item):
if item.get('radio',False) or item.get('type','') == "Music Genres": return True
if item.get('radio',False) or item.get('type') == "Music Genres": return True
for path in item.get('path',[item.get('file','')]):
if path.lower().startswith(('musicdb://','special://profile/playlists/music/','special://musicplaylists/')): return True
return False
Expand Down
3 changes: 2 additions & 1 deletion plugin.video.pseudotv.live/resources/lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def getListDirectory(self, path, checksum=ADDON_VERSION, expiration=datetime.tim
results = FileAccess.listdir(path)
self.cache.set(cacheName, results, checksum, expiration)
self.log('getListDirectory path = %s, checksum = %s'%(path, checksum))
except:
except Exception as e:
self.log("getListDirectory, failed! %s\npath = %s"%(e,path), xbmc.LOGERROR)
results = [],[]
self.log('getListDirectory return dirs = %s, files = %s\n%s'%(len(results[0]), len(results[1]),path))
return results
Expand Down
14 changes: 7 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def getThumb(item={},opt=0): #unify thumbnail artwork
keys = {0:['landscape','fanart','thumb','thumbnail','poster','clearlogo','logo','logos','clearart','keyart,icon'],
1:['poster','clearlogo','logo','logos','clearart','keyart','landscape','fanart','thumb','thumbnail','icon']}[opt]
for key in keys:
art = (item.get('art',{}).get('album.%s'%(key),'') or
item.get('art',{}).get('albumartist.%s'%(key),'') or
item.get('art',{}).get('artist.%s'%(key),'') or
item.get('art',{}).get('season.%s'%(key),'') or
item.get('art',{}).get('tvshow.%s'%(key),'') or
item.get('art',{}).get(key,'') or
item.get(key,''))
art = (item.get('art',{}).get('album.%s'%(key)) or
item.get('art',{}).get('albumartist.%s'%(key)) or
item.get('art',{}).get('artist.%s'%(key)) or
item.get('art',{}).get('season.%s'%(key)) or
item.get('art',{}).get('tvshow.%s'%(key)) or
item.get('art',{}).get(key) or
item.get(key) or '')
if art: return art
return {0:FANART,1:COLOR_LOGO}[opt]

Expand Down
14 changes: 7 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/m3u.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ def _load(self, file=M3UFLEPATH):
nline = lines[nidx].rstrip()
if nline.startswith('#EXTINF:'): break
elif nline.startswith('#EXTGRP'):
prop = re.compile('^#EXTGRP:(.*)$', re.IGNORECASE).search(nline)
if prop is not None:
mitem['group'].append(prop.group(1).split(';'))
grop = re.compile('^#EXTGRP:(.*)$', re.IGNORECASE).search(nline)
if grop is not None:
mitem['group'].append(grop.group(1).split(';'))
mitem['group'] = sorted(set(mitem['group']))
elif nline.startswith('#KODIPROP:'):
prop = re.compile('^#KODIPROP:(.*)$', re.IGNORECASE).search(nline)
Expand All @@ -179,16 +179,16 @@ def _load(self, file=M3UFLEPATH):
except Exception as e: self.log('_load, error parsing m3u! %s'%(e))

#Fill missing with similar parameters.
mitem['name'] = (mitem.get('name','') or mitem.get('label',''))
mitem['label'] = (mitem.get('label','') or mitem.get('name',''))
mitem['favorite'] = (mitem.get('favorite','') or False)
mitem['name'] = (mitem.get('name') or mitem.get('label') or '')
mitem['label'] = (mitem.get('label') or mitem.get('name') or '')
mitem['favorite'] = (mitem.get('favorite') or False)

#Set Fav. based on group value.
if LANGUAGE(32019) in mitem['group'] and not mitem['favorite']:
mitem['favorite'] = True

#Core m3u parameters missing, ignore entry.
if not mitem.get('id','') or not mitem.get('name','') or not mitem.get('number',''):
if not mitem.get('id') or not mitem.get('name') or not mitem.get('number'):
self.log('_load, SKIPPED MISSING META m3u item = %s'%mitem)
continue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def determineLength(self, filename: str) -> int and float:
log('YTParser: Duration is %s'%(dur))
return dur
except Exception as e:
# log("YTParser: failed!", xbmc.LOGERROR)
log("YTParser: failed! %s\nfile = %s"%(e,filename), xbmc.LOGERROR)
return 0
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ def isMono(self, file: str) -> bool:
mono = reduce(lambda x, y: x and y < 0.005, ImageStat.Stat(Image.open(FileAccess.open(file,'rb'))).var, True)
self.log('isMono, mono = %s, file = %s'%(mono,file))
return mono
except Exception as e: self.log("isMono, failed! %s"%(e), xbmc.LOGWARNING)
except Exception as e: self.log("isMono, failed! %s\nfile = %s"%(e,file), xbmc.LOGWARNING)
return False
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def openFile(fle):
#todo generate qrcode to server file location.
#todo change xmltv to display statistics not raw file.
try: DIALOG.textviewer(openFile(file), heading=('%s - %s')%(ADDON_NAME,os.path.basename(file)),usemono=True)
except Exception as e: self.log('showFile failed! %s'%(e), xbmc.LOGERROR)
except Exception as e: self.log('showFile failed! %s\nfile = %s'%(e,file), xbmc.LOGERROR)


def openChannelManager(self, chnum: int=1):
Expand Down
6 changes: 2 additions & 4 deletions plugin.video.pseudotv.live/resources/lib/xmltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ def read_channels(fp=None, tree=None):
tree = parse(fp, parser=XMLParser(encoding=locale))
for elem in tree.findall('channel'):
channel = elem_to_channel(elem)
try:
channel['icon'] = [{'src':elem.findall('icon')[0].get('src')}]
except:
channel['icon'] = '' #temp fix
try: channel['icon'] = [{'src':elem.findall('icon')[0].get('src')}]
except: channel['icon'] = '' #temp fix
channels.append(channel)
return channels

Expand Down
10 changes: 5 additions & 5 deletions plugin.video.pseudotv.live/resources/lib/xmltvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _load(self, file: str=XMLTVFLEPATH) -> dict:


def _save(self, file: str=XMLTVFLEPATH, reset: bool=True) -> bool:
self.log('_save')
self.log('_save, file = %s'%(file))
if reset: data = self.resetData()
else: data = self.XMLTVDATA['data']

Expand Down Expand Up @@ -264,8 +264,8 @@ def getProgramItem(self, citem: dict, fItem: dict) -> dict:
item['title'] = fItem['label']
item['desc'] = fItem['plot']
item['length'] = fItem['duration']
item['sub-title'] = (fItem.get('episodetitle','') or '')
item['categories'] = (fItem.get('genre','') or ['Undefined'])[:5]
item['sub-title'] = (fItem.get('episodetitle') or '')
item['categories'] = (fItem.get('genre') or ['Undefined'])[:5]#trim list to five
item['type'] = fItem.get('type','video')
item['new'] = int(fItem.get('playcount','1')) == 0
item['thumb'] = cleanImage(getThumb(fItem,EPG_ARTWORK)) #unify thumbnail by user preference
Expand All @@ -278,8 +278,8 @@ def getProgramItem(self, citem: dict, fItem: dict) -> dict:
item['episode-num'] = {'xmltv_ns':'%s.%s'%(fItem.get("season",1)-1,fItem.get("episode",1)-1), # todo support totaleps <episode-num system="xmltv_ns">..44/47</episode-num>https://github.com/kodi-pvr/pvr.iptvsimple/pull/884
'onscreen':'S%sE%s'%(str(fItem.get("season",0)).zfill(2),str(fItem.get("episode",0)).zfill(2))}

item['rating'] = cleanMPAA(fItem.get('mpaa','') or 'NA')
item['stars'] = (fItem.get('rating','') or '0')
item['rating'] = cleanMPAA(fItem.get('mpaa') or 'NA')
item['stars'] = (fItem.get('rating') or '0')
item['writer'] = fItem.get('writer',[])[:5] #trim list to five
item['director'] = fItem.get('director',[])[:5] #trim list to five
item['actor'] = ['%s - %s'%(actor.get('name'),actor.get('role',LANGUAGE(32020))) for actor in fItem.get('cast',[])[:5] if actor.get('name')]
Expand Down
Binary file not shown.

0 comments on commit 9f5b968

Please sign in to comment.