Skip to content

Commit

Permalink
0.5.3q
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Sep 12, 2024
1 parent da5d935 commit 737646b
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 102 deletions.
3 changes: 3 additions & 0 deletions plugin.video.pseudotv.live/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.3p" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.3q" 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
1 change: 1 addition & 0 deletions plugin.video.pseudotv.live/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
v.0.5.4
-Added Provider meta to recordings.
-Refactored Playback:
-Improved Playlist/Broadcast/VOD callbacks and handling.
-New! EPG (Guide) behavior: Play media as VOD from any position regardless of playback type.
Expand Down
7 changes: 4 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/context_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def open(self):


if __name__ == '__main__':
param = sys.argv[1]
log('Create: __main__, param = %s'%(param))
if param == 'manage': Create(sys.argv,listitem=sys.listitem,fitem=decodePlot(BUILTIN.getInfoLabel('Plot'))).open()
log('Create: __main__, param = %s'%(sys.argv))
try: mode = sys.argv[1]
except: mode = ''
if mode == 'manage': Create(sys.argv,listitem=sys.listitem,fitem=decodePlot(BUILTIN.getInfoLabel('Plot'))).open()
else: Create(sys.argv,listitem=sys.listitem,fitem=decodePlot(BUILTIN.getInfoLabel('Plot'))).add()
3 changes: 1 addition & 2 deletions plugin.video.pseudotv.live/resources/lib/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ def run(sysARG, fitem: dict={}, nitem: dict={}):
BUILTIN.executebuiltin("Dialog.Close(all)")
BUILTIN.executebuiltin("ReplaceWindow(TVGuide,pvr://channels/tv/%s)"%(quoteString(ADDON_NAME)))
elif mode == 'settings' and hasAddon(PVR_CLIENT_ID,install=True,enable=True): SETTINGS.openSettings()
elif not params["chid"]: return DIALOG.notificationDialog(LANGUAGE(32000))
elif not params["chid"]: DIALOG.notificationDialog(LANGUAGE(32000))
elif mode in ['vod','dvr']: threadit(Plugin(sysARG, sysInfo=params).playVOD)(params["title"],params["vid"])
elif mode == 'live':
if params['isPlaylist']: threadit(Plugin(sysARG, sysInfo=params).playPlaylist)(params["name"],params["chid"])
elif params['vid'] : threadit(Plugin(sysARG, sysInfo=params).playLive)(params["name"],params["chid"],params["vid"])
else: threadit(Plugin(sysARG, sysInfo=params).playTV)(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 not isPlaylist and chid and not vid: return DIALOG.notificationDialog(LANGUAGE(32166)%(PVR_CLIENT_NAME,SETTINGS.IPTV_SIMPLE_SETTINGS().get('m3uRefreshIntervalMins')))
if __name__ == '__main__': run(sys.argv,fitem=decodePlot(BUILTIN.getInfoLabel('Plot')),nitem=decodePlot(BUILTIN.getInfoLabel('NextPlot')))
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def getPVRBroadcastDetails(self, id):
return self.sendJSON(param).get('result', {}).get('broadcastdetails', [])


def setDuration(self, path, item={}, runtime=0, save=SETTINGS.getSettingBool('Store_Duration')):
def setDuration(self, path='', item={}, runtime=0, save=SETTINGS.getSettingBool('Store_Duration')):
self.log("setDuration, path = %s, runtime = %s, save = %s" % (path,runtime,save))
self.cache.set('getPlayerLength.%s'%(getMD5(path)), runtime, checksum=getMD5(path), expiration=datetime.timedelta(days=28), json_data=False)
if save and not path.startswith(tuple(VFS_TYPES)): self.queDuration(item, runtime)
Expand Down
23 changes: 13 additions & 10 deletions plugin.video.pseudotv.live/resources/lib/m3u.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,19 @@ def getRecordItem(self, fitem, seek=0):
if seek <= 0: group = LANGUAGE(30119)
else: group = LANGUAGE(30152)
ritem = self.getMitem()
ritem['label'] = (fitem.get('showlabel') or '%s%s'%(fitem.get('label',''),' - %s'%(fitem.get('episodelabel','')) if fitem.get('episodelabel','') else ''))
ritem['name'] = ritem['label']
ritem['number'] = random.Random(ritem['name']).random()
ritem['logo'] = cleanImage(getThumb(fitem,opt=EPG_ARTWORK))
ritem['media'] = True
ritem['media-size'] = str(fitem.get('size',0))
ritem['media-dir'] = ''#todo optional add parent directory via user prompt?
ritem['group'] = ['%s (%s)'%(group,ADDON_NAME)]
ritem['id'] = getRecordID(ritem['name'], ritem['url'], ritem['number'])
ritem['url'] = DVR_URL.format(addon=ADDON_ID,title=quoteString(ritem['label']),chid=quoteString(ritem['id']),vid=quoteString(encodeString((fitem.get('originalfile') or fitem.get('file','')))),seek=seek,duration=fitem.get('duration',0))#fitem.get('catchup-id','')
ritem['provider'] = '%s (%s)'%(ADDON_NAME,SETTINGS.getCacheSetting('Friendly_Name'))
ritem['provider-type'] = 'addon'
ritem['provider-logo'] = HOST_LOGO
ritem['label'] = (fitem.get('showlabel') or '%s%s'%(fitem.get('label',''),' - %s'%(fitem.get('episodelabel','')) if fitem.get('episodelabel','') else ''))
ritem['name'] = ritem['label']
ritem['number'] = random.Random(ritem['name']).random()
ritem['logo'] = cleanImage(getThumb(fitem,opt=EPG_ARTWORK))
ritem['media'] = True
ritem['media-size'] = str(fitem.get('size',0))
ritem['media-dir'] = ''#todo optional add parent directory via user prompt?
ritem['group'] = ['%s (%s)'%(group,ADDON_NAME)]
ritem['id'] = getRecordID(ritem['name'], ritem['url'], ritem['number'])
ritem['url'] = DVR_URL.format(addon=ADDON_ID,title=quoteString(ritem['label']),chid=quoteString(ritem['id']),vid=quoteString(encodeString((fitem.get('originalfile') or fitem.get('file','')))),seek=seek,duration=fitem.get('duration',0))#fitem.get('catchup-id','')
return ritem


Expand Down
43 changes: 16 additions & 27 deletions plugin.video.pseudotv.live/resources/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ class Plugin:
def preparingPlayback(self):
if self.playCheck(loadJSON(decodeString(PROPERTIES.getEXTProperty('%s.lastPlayed.sysInfo'%(ADDON_ID))))):
try: yield
finally:
PROPERTIES.setEXTProperty('%s.lastPlayed.sysInfo'%(ADDON_ID),encodeString(dumpJSON(self.sysInfo)))
else:
yield self.playError()
finally: PROPERTIES.setEXTProperty('%s.lastPlayed.sysInfo'%(ADDON_ID),encodeString(dumpJSON(self.sysInfo)))
else: yield self.playError()


def __init__(self, sysARG=sys.argv, sysInfo={}):
Expand Down Expand Up @@ -234,6 +232,7 @@ def playLive(self, name: str, chid: str, vid: str):
else: #-> VOD called by non-current EPG cell.
url = self.sysInfo['fitem'].get('catchup-id')
self.log('playLive, id = %s, VOD = %s'%(chid, url))
self.sysInfo['vid'] = self.sysInfo['fitem'].get('file',url)
DIALOG.notificationDialog(LANGUAGE(32185)%(self.sysInfo['fitem'].get('label',self.sysInfo.get('title',''))))
timerit(BUILTIN.executebuiltin)(0.1,['PlayMedia(%s)'%(url)])
self.resolveURL(False, xbmcgui.ListItem())
Expand Down Expand Up @@ -321,22 +320,13 @@ def playCheck(self, oldInfo: dict={}) -> bool:
self.log('playCheck, sysInfo=%s\noldInfo = %s'%(self.sysInfo,oldInfo))
def _chkPath():
if not self.sysInfo.get('vid'): return True
elif self.sysInfo.get('vid','').startswith(tuple(WEB_TYPES)): return True
elif self.sysInfo.get('vid','').startswith(tuple(VFS_TYPES)):
if hasAddon(self.sysInfo.get('vid','')): return True
elif FileAccess.exists(self.sysInfo.get('vid','')): return True
elif self.sysInfo.get('vid','').startswith(tuple(WEB_TYPES)): return True
elif self.sysInfo.get('vid','').startswith(tuple(VFS_TYPES)): return hasAddon(self.sysInfo.get('vid',''))
elif FileAccess.exists(self.sysInfo.get('vid','')): return True
self.log('playCheck _chkPath, failed! path (%s) not found.'%(self.sysInfo.get('vid','')))
if DEBUG_ENABLED: DIALOG.notificationDialog(LANGUAGE(32167))
return False

def _chkGuide():
if self.sysInfo.get('chid') == self.sysInfo.get('citem',{}).get('id',random.random()):
if self.sysInfo.get('title') != self.sysInfo.get('fitem',{}).get('label',self.sysInfo.get('title')):
self.log('playCheck _chkGuide, failed! Current EPG cell (%s) does not match PVR backend (%s).'%(self.sysInfo.get('fitem',{}).get('label',self.sysInfo.get('title')),self.sysInfo.get('title')))
if DEBUG_ENABLED: DIALOG.notificationDialog(LANGUAGE(32129)%(PVR_CLIENT_NAME))
return False
return True

def _chkLoop():
if self.sysInfo.get('chid') == oldInfo.get('chid',random.random()):
if self.sysInfo.get('start') == oldInfo.get('start',random.random()):
Expand All @@ -361,24 +351,23 @@ def _chkLoop():
return False
return True

# _chkPath()
# _chkGuide()
# _chkLoop()
_chkPath()
_chkLoop()
#todo take action on fail. for now log events and strategize actions.
return True


def playError(self):
self.log('playError, id = %s, attempt = %s\n%s'%(self.sysInfo.get('chid','-1'),self.sysInfo.get('playcount'),self.sysInfo))
PROPERTIES.setEXTProperty('%s.lastPlayed.sysInfo'%(ADDON_ID),encodeString(dumpJSON(self.sysInfo)))
# if self.sysInfo.get('playcount') in [1,2,3]:
# with BUILTIN.busy_dialog():
# DIALOG.notificationWait(LANGUAGE(32038)%(self.sysInfo.get('playcount',0)))
# self.resolveURL(False, xbmcgui.ListItem()) #release pending playback.
# MONITOR.waitForAbort(1.0) #allow a full second to pass beyond any msecs differential.
# return BUILTIN.executebuiltin('PlayMedia(%s%s)'%(self.sysARG[0],self.sysARG[2])) #retry channel
# elif self.sysInfo.get('playcount') == 4: DIALOG.okDialog(LANGUAGE(32134)%(ADDON_NAME))
# else: DIALOG.notificationWait(LANGUAGE(32000))
if self.sysInfo.get('playcount') in [1,2,3]:
with BUILTIN.busy_dialog():
DIALOG.notificationWait(LANGUAGE(32038)%(self.sysInfo.get('playcount',0)))
self.resolveURL(False, xbmcgui.ListItem()) #release pending playback.
MONITOR.waitForAbort(1.0) #allow a full second to pass beyond any msecs differential.
return BUILTIN.executebuiltin('PlayMedia(%s%s)'%(self.sysARG[0],self.sysARG[2])) #retry channel
elif self.sysInfo.get('playcount') == 4: DIALOG.okDialog(LANGUAGE(32134)%(ADDON_NAME))
else: DIALOG.notificationWait(LANGUAGE(32000))
self.resolveURL(False, xbmcgui.ListItem()) #release pending playback.


Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def setPlaycount(self, state: bool=SETTINGS.getSettingBool('Rollback_Watched'),

def setPlayruntime(self, state: bool=SETTINGS.getSettingBool('Store_Duration'), fitem: dict={}, runtime=0):
self.log('setPlayruntime, state = %s, file = %s, runtime = %s'%(state,fitem.get('file'),runtime))
self.jsonRPC.setDuration(fitem.get('file'), fitem, runtime, state)
self.jsonRPC.setDuration(fitem.get('file',''), fitem, runtime, state)


def _onPlay(self):
Expand Down
6 changes: 2 additions & 4 deletions plugin.video.pseudotv.live/resources/lib/xmltvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,8 @@ def addChannel(self, citem: dict) -> bool:

self.log('addChannel, mitem = %s'%(mitem))
idx, channel = self.findChannel(mitem)
if idx is None:
self.XMLTVDATA['channels'].append(mitem)
else:
self.XMLTVDATA['channels'][idx] = mitem # replace existing channel meta
if idx is None: self.XMLTVDATA['channels'].append(mitem)
else: self.XMLTVDATA['channels'][idx] = mitem # replace existing channel meta
return True


Expand Down
53 changes: 0 additions & 53 deletions plugin.video.pseudotv.live/welcome.txt

This file was deleted.

0 comments on commit 737646b

Please sign in to comment.