Skip to content

Commit

Permalink
Zeroconf
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Oct 31, 2024
1 parent 70cd981 commit 5012f81
Show file tree
Hide file tree
Showing 23 changed files with 1,956 additions and 409 deletions.
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.5i" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.5j" 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
7 changes: 7 additions & 0 deletions plugin.video.pseudotv.live/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
v.0.5.6
-Added Zeroconf Multi-Room configuration replacing the previous pairing method.
- No pairing procedures required; ignore past methods.
-Added New welcome dialog.
-Added Multi-Room option to auto-tuning.
-Added Global sort method to settings.
- Set the default method for all channels with exceptions below.
- Per channel sort method is overridden by Smartplaylists, Dynamicplaylists and Advanced channel rules containing an existing sort method.
-Moved "Remove Server" to "Select Server" list.
-Tweaked Multiprocessing and cache.
-Improved filling guidedata for channels with limited or short duration media.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ msgid "Centralized Folder"
msgstr ""

msgctxt "#30103"
msgid "Bonjour Information"
msgid "ZeroConf Information"
msgstr ""

msgctxt "#30104"
Expand Down Expand Up @@ -646,7 +646,7 @@ msgid "Enable Automatic PVR Refresh"
msgstr ""

msgctxt "#30156"
msgid "Silence Bonjour announcement"
msgid "Enable ZeroConf"
msgstr ""

msgctxt "#30157"
Expand Down Expand Up @@ -1428,7 +1428,7 @@ msgid "Run Autotune"
msgstr ""

msgctxt "#32182"
msgid "Bonjour Announcement:"
msgid "ZeroConf Status:"
msgstr ""

msgctxt "#32183"
Expand Down Expand Up @@ -1547,6 +1547,18 @@ msgctxt "#32213"
msgid "Stopping"
msgstr ""

msgctxt "#32214"
msgid "Sort Method"
msgstr ""

msgctxt "#32215"
msgid "Enable Multi-Room Instances?"
msgstr ""

msgctxt "#32216"
msgid "Welcome to %s, If you're new please visit our project wiki for help & guides. Thank you for your support, enjoy!"
msgstr ""


# Help - strings 33000 thru 33999 reserved for common strings used in add-ons

Expand Down Expand Up @@ -1882,8 +1894,12 @@ msgctxt "#33181"
msgid "Force Autotune to run."
msgstr ""

msgctxt "#33214"
msgid "Default Sort Method for all channels, overridden per channel by SmartPlaylist, DynamicPlaylist and Adv. Channel rules."
msgstr ""

msgctxt "#33182"
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."
msgid "Enabled in discovered servers in the list below."
msgstr ""

msgctxt "#33308"
Expand Down
11 changes: 9 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/autotune.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ def _runTune(self, samples: bool=False, rebuild: bool=False, dia=None):
if samples:
opt = ''
msg = (LANGUAGE(32042)%ADDON_NAME)
if Backup().hasBackup():
hasBackup = PROPERTIES.hasBackup()
hasServers = PROPERTIES.hasServers()
if hasBackup:
opt = LANGUAGE(32112)
msg = '%s\n%s'%((LANGUAGE(32042)%ADDON_NAME),LANGUAGE(32111))
elif hasServers:
opt = LANGUAGE(30092)
msg = '%s\n%s'%((LANGUAGE(32042)%ADDON_NAME),LANGUAGE(32215))
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: return Backup().recoverChannels()
elif retval == 2:
if hasBackup: return Backup().recoverChannels()
elif hasServers: return BUILTIN.executebuiltin('RunScript(special://home/addons/plugin.video.pseudotv.live/resources/lib/multiroom.py, Select_Server)')
else: return True
else:
if SETTINGS.getSettingBool('Debug_Enable'): DIALOG.notificationDialog(LANGUAGE(32058))
Expand Down
27 changes: 12 additions & 15 deletions plugin.video.pseudotv.live/resources/lib/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ def getFileDate(self, file: str) -> str:


def hasBackup(self, file: str=CHANNELFLE_BACKUP) -> bool:
with BUILTIN.busy_dialog():
self.log('hasBackup')
if FileAccess.exists(file):
if file == CHANNELFLE_BACKUP:#main backup file, set meta.
PROPERTIES.setEXTProperty('%s.has.Backup'%(ADDON_ID),"true")
if (SETTINGS.getSetting('Backup_Channels') or 'Last Backup: Unknown') == 'Last Backup: Unknown':
SETTINGS.setSetting('Backup_Channels' ,'%s: %s'%(LANGUAGE(32106),self.getFileDate(file)))
if not SETTINGS.getSetting('Recover_Channels'):
SETTINGS.setSetting('Recover_Channels','%s [B]%s[/B] Channels?'%(LANGUAGE(32107),len(self.getChannels())))
return True
PROPERTIES.setEXTProperty('%s.has.Backup'%(ADDON_ID),"false")
SETTINGS.setSetting('Backup_Channels' ,'')
SETTINGS.setSetting('Recover_Channels','')
return False
self.log('hasBackup')
if PROPERTIES.setBackup(FileAccess.exists(file)):
if file == CHANNELFLE_BACKUP:#main backup file, set meta.
if (SETTINGS.getSetting('Backup_Channels') or 'Last Backup: Unknown') == 'Last Backup: Unknown':
SETTINGS.setSetting('Backup_Channels' ,'%s: %s'%(LANGUAGE(32106),self.getFileDate(file)))
if not SETTINGS.getSetting('Recover_Channels'):
SETTINGS.setSetting('Recover_Channels','%s [B]%s[/B] Channels?'%(LANGUAGE(32107),len(self.getChannels())))
return True
SETTINGS.setSetting('Backup_Channels' ,'')
SETTINGS.setSetting('Recover_Channels','')
return False


def getChannels(self, file: str=CHANNELFLE_BACKUP) -> list:
Expand All @@ -72,7 +69,7 @@ def backupChannels(self, file: str=CHANNELFLE_BACKUP) -> bool:
with BUILTIN.busy_dialog():
if FileAccess.copy(CHANNELFLEPATH,file):
if file == CHANNELFLE_BACKUP: #main backup file, set meta.
PROPERTIES.setEXTProperty('%s.has.Backup'%(ADDON_ID),"true")
PROPERTIES.setBackup(True)
SETTINGS.setSetting('Backup_Channels' ,'%s: %s'%(LANGUAGE(32106),datetime.datetime.now().strftime(BACKUP_TIME_FORMAT)))
SETTINGS.setSetting('Recover_Channels','%s [B]%s[/B] Channels?'%(LANGUAGE(32107),len(self.getChannels())))
return DIALOG.notificationDialog('%s %s'%(LANGUAGE(32110),LANGUAGE(32025)))
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, service=None):
self.limit = SETTINGS.getSettingInt('Page_Limit')

self.filters = {} #{"and": [{"operator": "contains", "field": "title", "value": "Star Wars"},{"operator": "contains", "field": "tag", "value": "Good"}],"or":[]}
self.sort = {"ignorearticle":True,"method":"random","order":"ascending","useartistsortname":True}
self.sort = {"ignorearticle":True,"method":"%s"%(SETTINGS.getSetting('Sort_Method').lower()),"order":"ascending","useartistsortname":True}
self.limits = {"end":-1,"start":0,"total":0}
self.maxDays = MAX_GUIDEDAYS
self.minEPG = EPG_DURATION
Expand Down Expand Up @@ -121,7 +121,7 @@ def build(self):
self.pName = citem['name']
self.pCount = int(idx*100//len(channels))

while not self.service.monitor.abortRequested() and self.service._suspend():
while self.service._suspend():
if self.service._interrupt(OVERLAY_DELAY):
self.completeBuild = False
break
Expand Down
9 changes: 5 additions & 4 deletions plugin.video.pseudotv.live/resources/lib/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def set(self, name, value, checksum=ADDON_VERSION, expiration=datetime.timedelta
# with self.lock:
if value and not self.disable_cache and not self.cacheLocked():
with self.cacheLocker():
self.log('set, name = %s'%self.getname(name))
self.log('set, name = %s, value = %s'%(self.getname(name),'%s...'%(str(value)[:128])))
self.cache.set(self.getname(name),value,checksum,expiration,json_data)
return value

Expand All @@ -94,9 +94,10 @@ def get(self, name, checksum=ADDON_VERSION, json_data=False):
# with self.lock:
if not self.disable_cache and not self.cacheLocked():
with self.cacheLocker():
self.log('get, name = %s'%self.getname(name))
return self.cache.get(self.getname(name),checksum,json_data)

value = self.cache.get(self.getname(name),checksum,json_data)
self.log('get, name = %s, value = %s'%(self.getname(name),'%s...'%(str(value)[:128])))
return value


def clear(self, name, wait=15):
import sqlite3
Expand Down
8 changes: 7 additions & 1 deletion plugin.video.pseudotv.live/resources/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
OVERLAY_DELAY = 5 #secs
DISCOVERY_TIMER = 60 #secs
EPOCH_TIMER = 15 #secs
DISCOVER_INTERVAL = 30
EPG_DURATION = 10800 #secs
DTFORMAT = '%Y%m%d%H%M%S'
DTZFORMAT = '%Y%m%d%H%M%S +%z'
Expand Down Expand Up @@ -132,7 +133,6 @@

#docs
README_FLE = os.path.join(ADDON_PATH,'README.md')
WELCOME_FLE = os.path.join(ADDON_PATH,'welcome.txt')
CHANGELOG_FLE = os.path.join(ADDON_PATH,'changelog.txt')
LICENSE_FLE = os.path.join(ADDON_PATH,'LICENSE')

Expand Down Expand Up @@ -198,6 +198,12 @@
COLOR_RADIO_CHANNEL = 'cyan'
COLOR_FAVORITE_CHANNEL = 'yellow'

#urls
URL_WIKI = 'https://github.com/PseudoTV/PseudoTV_Live/wiki'
URL_SUPPORT = 'https://forum.kodi.tv/showthread.php?tid=346803'



# https://github.com/xbmc/xbmc/blob/master/system/colors.xml

#images
Expand Down
17 changes: 9 additions & 8 deletions plugin.video.pseudotv.live/resources/lib/cqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def __exists(self, package):

def _push(self, package: tuple, priority: int=0, delay: int=0):
node = LlNode(package, priority, delay)
if self.__exists((1,priority,package)):
self.log("_push, func = %s exists; ignoring package"%(package[0].__name__))
return
if self.__exists((1,priority,package)): self.log("_push, func = %s exists; ignoring package"%(package[0].__name__))
elif self.priority:
self.qsize += 1
item = (priority, package)
Expand All @@ -109,13 +107,16 @@ def _push(self, package: tuple, priority: int=0, delay: int=0):
def __pop(self):
self.isRunning = True
while not self.service.monitor.abortRequested():
if self.service._interrupt():
self.log("__pop, _interrupt == True")
if self.service.monitor.waitForAbort(.0001):
self.log("__pop, waitForAbort")
break
elif self.service._suspend():
self.log("__pop, _suspend == True")
if self.service._interrupt(OVERLAY_DELAY): break
else: continue
if self.service._interrupt(OVERLAY_DELAY):
self.log("__pop, _interrupt")
break
else:
self.log("__pop, _suspend")
continue
else:
if not self.head and not self.priority:
self.log("__pop, The queue is empty!")
Expand Down
22 changes: 22 additions & 0 deletions plugin.video.pseudotv.live/resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,25 @@ def percentDiff(org, new):
def pagination(list, end):
for start in range(0, len(list), end):
yield seq[start:start+end]

def findItemsInLST(items, values, item_key='getLabel', val_key='', index=True):
if not values: return [-1]
matches = []
def _match(fkey,fvalue):
if str(fkey).lower() == str(fvalue).lower():
matches.append(idx if index else item)

for value in values:
if isinstance(value,dict):
value = value.get(val_key,'')

for idx, item in enumerate(items):
if isinstance(item,xbmcgui.ListItem):
if item_key == 'getLabel':
_match(item.getLabel() ,value)
elif item_key == 'getLabel2':
_match(item.getLabel2(),value)
elif isinstance(item,dict):
_match(item.get(item_key,''),value)
else: _match(item,value)
return matches
Loading

0 comments on commit 5012f81

Please sign in to comment.