Skip to content

Commit

Permalink
v.0.5.7b
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Jan 2, 2025
1 parent 45c7b10 commit e4913b2
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 131 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.7a" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.7b" 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 @@
56ec0c3f60fe16dd084b0788864f4517
87ba2ca47a599184788fd2399d910d57
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.7a" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.7b" 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
15 changes: 8 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ def _runTune(self, samples: bool=False, rebuild: bool=False, dia=None):
if samples:
opt = ''
msg = (LANGUAGE(32042)%ADDON_NAME)
hasBackup = PROPERTIES.hasBackup()
hasServers = PROPERTIES.hasServers()
hasBackup = PROPERTIES.hasBackup()
hasServers = PROPERTIES.hasServers()
hasChannels = PROPERTIES.hasChannels()
if hasBackup:
opt = LANGUAGE(32112)
msg = '%s\n%s'%((LANGUAGE(32042)%ADDON_NAME),LANGUAGE(32111))
Expand All @@ -83,9 +84,9 @@ def _runTune(self, samples: bool=False, rebuild: bool=False, dia=None):
retval = DIALOG.yesnoDialog(message=msg,customlabel=opt)
if retval == 1: dia = DIALOG.progressBGDialog(header='%s, %s'%(ADDON_NAME,'%s %s'%(LANGUAGE(32021),LANGUAGE(30038))))
elif retval == 2:
if hasBackup: return Backup().recoverChannels()
elif hasServers: return BUILTIN.executebuiltin('RunScript(special://home/addons/%s/resources/lib/multiroom.py, Select_Server)'%(ADDON_ID))
elif not PROPERTIES.hasFirstrun(): return openAddonSettings()
if hasBackup: return Backup().recoverChannels()
elif hasServers: return BUILTIN.executebuiltin('RunScript(special://home/addons/%s/resources/lib/multiroom.py, Select_Server)'%(ADDON_ID))
elif not hasChannels: return openAddonSettings()
else:
if SETTINGS.getSettingBool('Debug_Enable'): DIALOG.notificationDialog(LANGUAGE(32058))
return
Expand Down Expand Up @@ -177,8 +178,8 @@ def buildAvailableRange(existing):
citem['logo'] = eitem.get('logo',citem.get('logo',LOGO))
citem['favorite'] = eitem.get('favorite',False)
self.channels.addChannel(citem)
if self.channels.setChannels():
PROPERTIES.forceUpdateTime('chkChannels')
PROPERTIES.setUpdateChannels(citem['id'])
return self.channels.setChannels()


def clearLibrary(self):
Expand Down
14 changes: 7 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, service=None):
self.filters = {} #{"and": [{"operator": "contains", "field": "title", "value": "Star Wars"},{"operator": "contains", "field": "tag", "value": "Good"}],"or":[]}
self.sort = {"ignorearticle":True,"method":"%s"%(SETTINGS.getSetting('Sort_Method').lower()),"order":"ascending","useartistsortname":True}
self.limits = {"end":-1,"start":0,"total":0}
self.completeBuild = False
self.completedBuild = False

self.bctTypes = {"ratings" :{"min":-1, "max":SETTINGS.getSettingInt('Enable_Preroll'), "auto":SETTINGS.getSettingInt('Enable_Preroll') == -1, "enabled":bool(SETTINGS.getSettingInt('Enable_Preroll')), "chance":SETTINGS.getSettingInt('Random_Pre_Chance'),
"sources" :{"ids":SETTINGS.getSetting('Resource_Ratings').split('|'),"paths":[os.path.join(FILLER_LOC,'Ratings' ,'')]},"items":{}},
Expand Down Expand Up @@ -119,14 +119,14 @@ def __hasProgrammes(cacheResponse):
start = roundTimeDown(getUTCstamp(),offset=60)#offset time to start bottom of the hour
stopTimes = dict(self.xmltv.loadStopTimes(fallback=datetime.datetime.fromtimestamp(start).strftime(DTFORMAT)))
self.pDialog = DIALOG.progressBGDialog()
self.completeBuild = True
self.completedBuild = True

updated = set()
for idx, citem in enumerate(self.sortChannels(self.verify(channels))):
citem = self.runActions(RULES_ACTION_CHANNEL_TEMP_CITEM, citem, citem, inherited=self)
self.log('build, id = %s, rules = %s'%(citem['id'],citem.get('rules',{})))
if self.service._interrupt():
self.completeBuild = False
self.completedBuild = False
self.pErrors = [LANGUAGE(32160)]
self.pDialog = DIALOG.progressBGDialog(self.pCount, self.pDialog, message='%s: %s'%(LANGUAGE(32144),LANGUAGE(32213)), header=ADDON_NAME)
break
Expand All @@ -149,16 +149,16 @@ def __hasProgrammes(cacheResponse):
if self.addChannelStation(citem) and __hasProgrammes(cacheResponse):
updated.add(self.addChannelProgrammes(citem, cacheResponse)) #added xmltv lineup entries.
else:
if self.completeBuild: self.pErrors.append(LANGUAGE(32026))
if self.completedBuild: self.pErrors.append(LANGUAGE(32026))
chanErrors = ' | '.join(list(sorted(set(self.pErrors))))
self.log('build, [%s] In-Valid Channel (%s) %s'%(citem['id'],self.pName,chanErrors))
self.pDialog = DIALOG.progressBGDialog(self.pCount, self.pDialog, message='%s: %s'%(self.pName,chanErrors),header='%s, %s'%(ADDON_NAME,'%s %s'%(LANGUAGE(32027),LANGUAGE(32023))))
if not __hasGuideData(citem): self.delChannelStation(citem) #only remove m3u references when no valid programmes found.
self.runActions(RULES_ACTION_CHANNEL_STOP, citem, inherited=self)

self.pDialog = DIALOG.progressBGDialog(100, self.pDialog, message='%s %s'%(self.pMSG,LANGUAGE(32025) if self.completeBuild else LANGUAGE(32135)))
self.log('build, completeBuild = %s, updated = %s, saved = %s'%(self.completeBuild,bool(updated),self.saveChannelLineups()))
return self.completeBuild, bool(updated)
self.pDialog = DIALOG.progressBGDialog(100, self.pDialog, message='%s %s'%(self.pMSG,LANGUAGE(32025) if self.completedBuild else LANGUAGE(32135)))
self.log('build, completed = %s, updated = %s, saved = %s'%(self.completedBuild,bool(updated),self.saveChannelLineups()))
return self.completedBuild, bool(updated)


def sortChannels(self, channels: list) -> list:
Expand Down
1 change: 0 additions & 1 deletion plugin.video.pseudotv.live/resources/lib/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def run(sysARG, fitem: dict={}, nitem: dict={}):
elif mode == 'resume': threadit(Plugin(sysARG, sysInfo=params).playResume)(params["name"],params["chid"])
elif mode == 'broadcast': threadit(Plugin(sysARG, sysInfo=params).playBroadcast)(params["name"],params["chid"],params["vid"])
elif mode == 'radio': threadit(Plugin(sysARG, sysInfo=params).playRadio)(params["name"],params["chid"],params["vid"])
elif mode == 'guide' and hasAddon(PVR_CLIENT_ID,install=True,enable=True) and not PROPERTIES.hasChannels() and PROPERTIES.hasFirstrun(): openAddonSettings()
elif mode == 'guide' and hasAddon(PVR_CLIENT_ID,install=True,enable=True): SETTINGS.openGuide()
elif mode == 'settings' and hasAddon(PVR_CLIENT_ID,install=True,enable=True): openAddonSettings()
else: DIALOG.notificationDialog(LANGUAGE(32000))
Expand Down
6 changes: 3 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/fillers.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def getSingle(self, type, keys=['resources'], chance=False):
items = []
for key in keys:
tmpLST = self.builder.bctTypes.get(type,{}).get('items',{}).get(key.lower(),[])
if len(tmpLST) > 0: items.append(random.choice(tmpLST))
elif chance: items.extend(self.getSingle(type))
if len(tmpLST) > 0: items.append(random.choice(tmpLST))
elif len(items) == 0 and chance: items.extend(self.getSingle(type))
self.log('getSingle, type = %s, keys = %s, chance = %s, returning = %s'%(type,keys,chance,len(items)))
return setDictLST(items)

Expand Down Expand Up @@ -153,7 +153,7 @@ def injectBCTs(self, citem, fileList):
if self.builder.bctTypes[ftype].get('enabled',False) and dbtype.startswith(tuple(preIncludeTypes)) and chtype not in IGNORE_CHTYPE:
preFileList.extend(self.getSingle(ftype, preKeys, chanceBool(self.builder.bctTypes[ftype].get('chance',0))))

for item in setDictLSTLST(preFileList):
for item in setDictLST(preFileList):
if (item.get('duration') or 0) == 0: continue
else:
runtime += item.get('duration')
Expand Down
18 changes: 8 additions & 10 deletions plugin.video.pseudotv.live/resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,14 @@ def slugify(s, lowercase=False):
return s

def validString(s):
return "".join(x for x in s if (x.isalnum() or x not in '\/:*?"<>|'))
return "".join(x for x in s if (x.isalnum() or x not in '\\/:*?"<>|'))

def stripNumber(s):
return re.sub(r'\d+','',s)

def stripRegion(s):
try:
match = re.compile('(.*) \((.*)\)', re.IGNORECASE).search(s)
if match.group(1): return match.group(1)
except: return s
match = re.compile(r'(.*) \((.*)\)', re.IGNORECASE).search(s)
if match: return match.group(1)

def chanceBool(percent=25):
return random.randrange(100) <= percent
Expand Down Expand Up @@ -139,10 +137,10 @@ def __setCache(key,data,json_data,cache,checksum,life):
if results and cache: return __setCache(cacheKey,results,json_data,cache,checksum,life)
else: return results
except requests.exceptions.ConnectionError as e:
log("Globals: requestURL, failed! Error connecting to the server: %s"%('Returning cache' if cache else ''))
log("Globals: requestURL, failed! Error connecting to the server: %s"%('Returning cache' if cache else 'No Response'))
return __getCache(cacheKey,json_data,cache,checksum) if cache else __error(json_data)
except requests.exceptions.HTTPError as e:
log("Globals: requestURL, failed! HTTP error occurred: %s\n%s"%('Returning cache' if cache else ''))
log("Globals: requestURL, failed! HTTP error occurred: %s\n%s"%('Returning cache' if cache else 'No Response'))
return __getCache(cacheKey,json_data,cache,checksum) if cache else __error(json_data)
except requests.exceptions.RequestException as e:
log("Globals: requestURL, failed! An error occurred: %s"%(e), xbmc.LOGERROR)
Expand Down Expand Up @@ -175,7 +173,7 @@ def getRecordID(name, path, number):

def splitYear(label):
try:
match = re.compile('(.*) \((.*)\)', re.IGNORECASE).search(label)
match = re.compile(r'(.*) \((.*)\)', re.IGNORECASE).search(label)
if match and match.group(2):
label, year = match.groups()
if year.isdigit():
Expand Down Expand Up @@ -334,8 +332,8 @@ def playSFX(filename, cached=False):
xbmc.playSFX(filename, useCached=cached)

def cleanLabel(text):
text = re.sub('\[COLOR=(.+?)\]', '', text)
text = re.sub('\[/COLOR\]', '', text)
text = re.sub(r'\[COLOR=(.+?)\]', '', text)
text = re.sub(r'\[/COLOR\]', '', text)
text = text.replace("[B]",'').replace("[/B]",'')
text = text.replace("[I]",'').replace("[/I]",'')
return text.replace(":",'')
Expand Down
10 changes: 4 additions & 6 deletions plugin.video.pseudotv.live/resources/lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ def playerOpen(self, params={}):
return self.sendJSON(param).get('result') == 'OK'


def getSetting(self, category, section, cache=True):
def getSetting(self, category, section, cache=False):
param = {"method":"Settings.GetSettings","params":{"filter":{"category":category,"section":section}}}
if cache: return self.cacheJSON(param).get('result',{}).get('settings',[])
else: return self.sendJSON(param).get('result', {}).get('settings',[])


def getSettingValue(self, key, default='', cache=True):
def getSettingValue(self, key, default='', cache=False):
param = {"method":"Settings.GetSettingValue","params":{"setting":key}}
if cache: return (self.cacheJSON(param).get('result',{}).get('value') or default)
else: return (self.sendJSON(param).get('result',{}).get('value') or default)
Expand Down Expand Up @@ -246,7 +246,6 @@ def getMusicGenres(self, cache=True):
def getDirectory(self, param={}, cache=True, checksum=ADDON_VERSION, expiration=datetime.timedelta(minutes=15)):
param["properties"] = self.getEnums("List.Fields.Files", type='items')
param = {"method":"Files.GetDirectory","params":param}
#todo carry over "error" to requestlist for user message.
if cache: return self.cacheJSON(param, expiration, checksum).get('result', {})
else: return self.sendJSON(param).get('result', {})

Expand All @@ -268,8 +267,8 @@ def getFileDetails(self, file, media='video', properties=["duration","runtime"])


def getViewMode(self):
default = {"nonlinearstretch":False,"pixelratio":1,"verticalshift":0,"viewmode":"custom","zoom": 1.0}
response = self.cacheJSON({"method":"Player.GetViewMode","params":{}}).get('result',default)
default = {"nonlinearstretch":False,"pixelratio":1,"verticalshift":0,"viewmode":"custom","zoom": 1.0}
response = self.sendJSON({"method":"Player.GetViewMode","params":{}}).get('result',default)
self.log('getViewMode, response = %s'%(response))
return response

Expand Down Expand Up @@ -540,7 +539,6 @@ def padItems(self, files, page=SETTINGS.getSettingInt('Page_Limit')):
return files


@cacheit(expiration=datetime.timedelta(seconds=FIFTEEN),json_data=False)
def inputFriendlyName(self):
with PROPERTIES.interruptActivity():
friendly = self.getSettingValue("services.devicename")
Expand Down
33 changes: 10 additions & 23 deletions plugin.video.pseudotv.live/resources/lib/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,10 @@ def chkPVRInstance(self, instance=ADDON_NAME):
self.log('chkPVRInstance, path = %s, failed to open file = %s\n%s'%(PVR_CLIENT_LOC,file,e))
continue

match = re.compile('<setting id=\"kodi_addon_instance_name\" default=\"true\">(.*?)\</setting>', re.IGNORECASE).search(txt)
match = re.compile(r'<setting id=\"kodi_addon_instance_name\" default=\"true\">(.*?)\</setting>', re.IGNORECASE).search(txt)
try: name = match.group(1)
except:
match = re.compile('<setting id=\"kodi_addon_instance_name\">(.*?)\</setting>', re.IGNORECASE).search(txt)
match = re.compile(r'<setting id=\"kodi_addon_instance_name\">(.*?)\</setting>', re.IGNORECASE).search(txt)
try: name = match.group(1)
except: name = None

Expand All @@ -535,13 +535,13 @@ def getPVRInstanceSettings(self, instance):
fle = FileAccess.open(instancePath,'r')
for line in fle.readlines():
if not 'id=' in line: continue
match = re.compile('<setting id=\"(.*)\" default=\"(.*)\">(.*?)\</setting>', re.IGNORECASE).search(line)
match = re.compile(r'<setting id=\"(.*)\" default=\"(.*)\">(.*?)\</setting>', re.IGNORECASE).search(line)
try: instanceConf.update({match.group(1):(match.group(2),match.group(3))})
except:
match = re.compile('<setting id=\"(.*)\">(.*?)\</setting>', re.IGNORECASE).search(line)
match = re.compile(r'<setting id=\"(.*)\">(.*?)\</setting>', re.IGNORECASE).search(line)
try: instanceConf.update({match.group(1):('',match.group(2))})
except:
match = re.compile('<setting id=\"(.*)\" default=\"(.*?)\" />', re.IGNORECASE).search(line)
match = re.compile(r'<setting id=\"(.*)\" default=\"(.*?)\" />', re.IGNORECASE).search(line)
try: instanceConf.update({match.group(1):(match.group(2),None)})
except: pass
fle.close()
Expand Down Expand Up @@ -633,14 +633,6 @@ def setRemoteHost(self, value):
return self.setProperty('%s.Remote_Host'%(ADDON_ID),value)


def hasFirstrun(self):
return self.getEXTProperty('%s.has.Firstrun'%(ADDON_ID))


def setFirstrun(self, state=True):
return self.setEXTPropertyBool('%s.has.Firstrun'%(ADDON_ID),state)


def isRunning(self, key):
return self.getEXTPropertyBool('%s.Running.%s'%(ADDON_ID,key))

Expand All @@ -653,22 +645,17 @@ def forceUpdateTime(self, key):
return self.setPropertyInt(key,0)


def getUpdateChannelID(self):
def getUpdateChannels(self):
ids = self.getPropertyList('updateChannels')
id = ids.pop(0)
self.setPropertyList('updateChannels',list(set(ids)))
self.log('getUpdateChannelID, id = %s, remaining = %s'%(id,len(ids)))
return id
self.clearProperty('updateChannels')
return ids


def setUpdateChannels(self, id):
ids = self.getPropertyList('updateChannels')
ids.append(id)
return self.setPropertyList('updateChannels',list(set(ids)))


def clearUpdateChannels(self):
self.clearProperty('updateChannels')
self.setPropertyList('updateChannels',list(set(ids)))
return self.setEpochTimer('chkChannels')


def setEpochTimer(self, key, state=True):
Expand Down
Loading

0 comments on commit e4913b2

Please sign in to comment.