Skip to content

Commit

Permalink
v.0.5.1r
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Aug 5, 2024
1 parent 10ec53a commit 34da0bd
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 40 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.1p" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.1r" 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 @@
3ec6b95c03d7270a5121160e26de6314
d246ae1f32845236388e4ec13c3256c5
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.1p" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.1r" 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
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 @@ -102,7 +102,7 @@ def verify(self, channels: list=[]):

def build(self) -> bool:
with legacy():
channels = sorted(self.verify(self.channels.getChannels()), key=lambda k: k['number'])
channels = sorted(self.verify(self.channels.getChannels()), key=itemgetter('number'))
if not channels:
self.log('build, no verified channels found!')
return False
Expand Down Expand Up @@ -166,7 +166,7 @@ def getFileList(self, citem: dict, now: time, start: time) -> bool and list:
if self.fillBCTs and not radio:
cacheResponse = Fillers(self).injectBCTs(citem, cacheResponse)
cacheResponse = self.addScheduling(citem, cacheResponse, start)
return sorted(cacheResponse, key=lambda k: k['start'])
return sorted(cacheResponse, key=itemgetter('start'))
return cacheResponse
except Exception as e: self.log("getFileList, failed! %s"%(e), xbmc.LOGERROR)
return False
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 @@ -41,7 +41,7 @@ def _load(self, file=CHANNELFLEPATH) -> dict:


def _save(self, file=CHANNELFLEPATH) -> bool:
self.channelDATA['channels'] = sorted(self.channelDATA['channels'], key=lambda k: k['number'])
self.channelDATA['channels'] = sorted(self.channelDATA['channels'], key=itemgetter('number'))
self.log('_save, channels = %s'%(len(self.channelDATA['channels'])))
return setJSON(file,self.channelDATA)

Expand Down
8 changes: 5 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from itertools import cycle, chain, zip_longest, islice
from xml.sax.saxutils import escape, unescape
from ast import literal_eval
from operator import itemgetter


from logger import *
from cache import Cache, cacheit
Expand Down Expand Up @@ -359,7 +361,7 @@ def distribute(seq):
yield i/(len(seq) + 1), x
distributions = list(map(distribute, seqs))
#['a', 'A', 1, 'b', 'B', 2, 'c', 'C', 3, 'd', 'D', 4, 'e', 'E']
for _, x in sorted(chain(*distributions), key=operator.itemgetter(0)):
for _, x in sorted(chain(*distributions), key=itemgetter(0)):
yield x

def distribute(*seq):
Expand Down Expand Up @@ -601,6 +603,6 @@ def mergeDictLST(dict1,dict2):
return dict1

def compareDict(dict1,dict2,sortKey):
a = sorted(dict1, key=lambda k: k[sortKey])
b = sorted(dict2, key=lambda k: k[sortKey])
a = sorted(dict1, key=itemgetter(sortKey))
b = sorted(dict2, key=itemgetter(sortKey))
return a == b
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def setPVRInstance(self, id):

def getCurrentSettings(self):
self.log('getCurrentSettings')
settings = ['User_Folder','Network_Folder','UDP_PORT','TCP_PORT','Client_Mode','Remote_URL','Disable_Cache']
settings = ['User_Folder','Network_Folder','UDP_PORT','TCP_PORT','Client_Mode','Remote_URL','Disable_Cache','Disable_Trakt','Rollback_Watched']
for setting in settings:
yield (setting,self.getSetting(setting))

Expand Down
14 changes: 7 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def getMixedGenres(self):
if self.enableEvenTV: rules.update({"1000":{"values":{"0":SETTINGS.getSettingInt('Enable_Even'),"1":SETTINGS.getSettingInt('Page_Limit'),"2":True}}})
MixedGenreList.append({'name':tv.get('name'),'type':"Mixed Genres",'path':self.predefined.createGenreMixedPlaylist(tv.get('name')),'logo':tv.get('logo'),'rules':rules})
self.log('getMixedGenres, genres = %s' % (len(MixedGenreList)))
return sorted(MixedGenreList,key=lambda x:x['name'])
return sorted(MixedGenreList,key=itemgetter('name'))


@cacheit(json_data=True)
Expand All @@ -233,7 +233,7 @@ def hasRecordings():
MixedList.append({'name':LANGUAGE(32003), 'type':"Mixed",'path':self.predefined.createPVRRecordings(),'logo':self.resources.getLogo(LANGUAGE(32003),"Mixed")}) #"PVR Recordings"

self.log('getMixed, mixed = %s' % (len(MixedList)))
return sorted(MixedList,key=lambda x:x['name'])
return sorted(MixedList,key=itemgetter('name'))


@cacheit(expiration=datetime.timedelta(minutes=MAX_GUIDEDAYS),json_data=True)
Expand All @@ -251,8 +251,8 @@ def getPlaylists(self):
if not logo: logo = self.resources.getLogo(result.get('label'),"Custom")
PlayList.append({'name':result.get('label'),'type':"%s Playlist"%(type.title()),'path':[result.get('file')],'logo':logo})
self.log('getPlaylists, PlayList = %s' % (len(PlayList)))
PlayList = sorted(PlayList,key=lambda x:x['name'])
PlayList = sorted(PlayList,key=lambda x:x['type'])
PlayList = sorted(PlayList,key=itemgetter('name'))
PlayList = sorted(PlayList,key=itemgetter('type'))
return PlayList


Expand All @@ -279,7 +279,7 @@ def getTVInfo(self, sortbycount=True):
NetworkList = [x[0] for x in sorted(NetworkList.most_common(50))]
ShowGenreList = [x[0] for x in sorted(ShowGenreList.most_common(25))]
else:
TVShows = (sorted(map(json.loads, list(TVShows.keys())), key=lambda k: k['name']))
TVShows = (sorted(map(json.loads, list(TVShows.keys())), key=itemgetter('name')))
del TVShows[250:]
NetworkList = (sorted(set(list(NetworkList.keys()))))
del NetworkList[250:]
Expand Down Expand Up @@ -379,8 +379,8 @@ def getRecommend(self):
if not isinstance(path,list): path = [path]
PluginList.append({'id':item['meta'].get('name'), 'name':vod.get('name'), 'type':"Recommended", 'path': path, 'logo':vod.get('icon',item['meta'].get('thumbnail'))})
self.log('getRecommend, found (%s) vod items.' % (len(PluginList)))
PluginList = sorted(PluginList,key=lambda x:x['name'])
PluginList = sorted(PluginList,key=lambda x:x['id'])
PluginList = sorted(PluginList,key=itemgetter('name'))
PluginList = sorted(PluginList,key=itemgetter('id'))
return PluginList


Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/m3u.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def cleanSelf(self, items, key='id', slug='@%s'%(slugify(ADDON_NAME))): # remove


def sortStations(self, stations, key='number'):
return sorted(stations, key=lambda k: k.get(key))
return sorted(stations, key=itemgetter(key))


def getMitem(self):
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, *args, **kwargs):
self.xmltv = XMLTVS()

self.newChannel = self.channels.getTemplate()
self.channelList = sorted(self.createChannelList(self.buildArray(), self.eChannels), key=lambda k: k['number'])
self.channelList = sorted(self.createChannelList(self.buildArray(), self.eChannels), key=itemgetter('number'))
self.channelList.extend(self.channels.getAutotuned())
self.newChannels = self.channelList.copy()

Expand Down Expand Up @@ -632,7 +632,7 @@ def _validate(citem):
if citem['number'] <= CHANNEL_LIMIT: citem['type'] = "Custom"
return self.setID(citem)

channelList = sorted([_f for _f in [_validate(channel) for channel in channelList] if _f], key=lambda k: k['number'])
channelList = sorted([_f for _f in [_validate(channel) for channel in channelList] if _f], key=itemgetter('number'))
self.log('validateChannels, channelList = %s'%(len(channelList)))
return channelList

Expand Down
4 changes: 2 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/seasonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def getHoliday(self, nearest=SETTINGS.getSettingBool('Nearest_Holiday')):
self.log('getHoliday, nearest = %s'%(nearest))
if nearest: return self.getNearestHoliday()
else: return self.getCurrentHoliday()


def getCurrentHoliday(self):
return SEASONS.get(self.getMonth(),{}).get(self.getWeek(),{})




def getNearestHoliday(self, fallback=True):
holiday = {}
month = self.getMonth()
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.pseudotv.live/resources/lib/seasons.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# You should have received a copy of the GNU General Public License
# along with PseudoTV Live. If not, see <http://www.gnu.org/licenses/>.

TV_QUERY = {"path":"videodb://tvshows/titles/" ,"limit":"","sort":{},"filter":{},
TV_QUERY = {"path":"videodb://tvshows/titles/" ,"limits":{},"sort":{},"filter":{},
"method":"VideoLibrary.GetEpisodes","enum":"Video.Fields.Episode","key":"episodes"}

MOVIE_QUERY = {"path":"videodb://movies/titles/" ,"limit":"","sort":{},"filter":{},
MOVIE_QUERY = {"path":"videodb://movies/titles/" ,"limits":{},"sort":{},"filter":{},
"method":"VideoLibrary.GetMovies" ,"enum":"Video.Fields.Movie" ,"key":"movies"}

SEASONS = {"January" : {'1':{'name':"New Years Anthologies" , 'tagline':"“You're traveling through another dimension...“" , 'keyword':'newyear' , 'query':[TV_QUERY,MOVIE_QUERY], 'logo':'https://assets.stickpng.com/images/580b57fcd9996e24bc43c410.png'},
Expand Down
7 changes: 3 additions & 4 deletions plugin.video.pseudotv.live/resources/lib/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,19 @@ def setSubtitles(self, state: bool=True):


def setPlaycount(self, state: bool=SETTINGS.getSettingBool('Rollback_Watched'), fitem: dict={}):
if state and fitem.get('file'):
self.log('setPlaycount, file = %s, playcount = %s'%(fitem.get('file'),fitem.get('playcount',0)))
self.myService.tasks._que(self.jsonRPC.quePlaycount,2,fitem)
self.log('setPlaycount, state = %s, file = %s, playcount = %s'%(state,fitem.get('file'),fitem.get('playcount',0)))
if state and fitem.get('file'): self.myService.tasks._que(self.jsonRPC.quePlaycount,2,fitem)


def _onPlay(self):
self.log('_onPlay')
self.setPlaycount(self.rollbackPlaycount,self.sysInfo.get('fitem',{}))
self.sysInfo = self.getPlayerSysInfo() #get current sysInfo
self.toggleBackground(False)
if self.sysInfo.get('citem',{}).get('id') != self.sysInfo.get('citem',{}).get('id',random.random()): #playing new channel
self.runActions(RULES_ACTION_PLAYER_START, self.sysInfo.get('citem,{}'), inherited=self)
self.setTrakt(self.disableTrakt)
self.setSubtitles(self.lastSubState) #todo allow rules to set sub preference per channel.
self.toggleBackground(False)


def _onChange(self):
Expand Down
16 changes: 9 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,15 @@ def chkSettingsChange(self, settings=[]):
# with sudo_dialog(msg='%s %s'%(LANGUAGE(32028),LANGUAGE(32053))):
nSettings = dict(SETTINGS.getCurrentSettings())
for setting, value in list(settings.items()):
actions = {'User_Folder' :{'func':self.setUserPath ,'kwargs':{'userFolders':nSettings.get(setting)}},
'Network_Folder' :{'func':self.setPVRPath ,'kwargs':{'userFolder':nSettings.get(setting)}},
'Remote_URL' :{'func':self.setPVRRemote ,'kwargs':{'userURL':nSettings.get(setting)}},
'UDP_PORT' :{'func':setPendingRestart},
'TCP_PORT' :{'func':setPendingRestart},
'Client_Mode' :{'func':setPendingRestart},
'Disable_Cache' :{'func':setPendingRestart}}
actions = {'User_Folder' :{'func':self.setUserPath ,'kwargs':{'userFolders':nSettings.get(setting)}},
'Network_Folder' :{'func':self.setPVRPath ,'kwargs':{'userFolder':nSettings.get(setting)}},
'Remote_URL' :{'func':self.setPVRRemote ,'kwargs':{'userURL':nSettings.get(setting)}},
'UDP_PORT' :{'func':setPendingRestart},
'TCP_PORT' :{'func':setPendingRestart},
'Client_Mode' :{'func':setPendingRestart},
'Disable_Cache' :{'func':setPendingRestart},
'Disable_Trakt' :{'func':setPendingRestart},
'Rollback_Watched':{'func':setPendingRestart}}

if nSettings.get(setting) != value and actions.get(setting):
# with sudo_dialog(LANGUAGE(32157)):
Expand Down
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 @@ -158,7 +158,7 @@ def buildMenu(self, select=None):

with busy_dialog():
client = isClient()
listItems = [LISTITEMS.buildMenuListItem(item.get('label'),item.get('label2'),item.get('icon')) for item in sorted(items,key=lambda x:x['label']) if not (item.get('hide') & client)]
listItems = [LISTITEMS.buildMenuListItem(item.get('label'),item.get('label2'),item.get('icon')) for item in sorted(items,key=itemgetter('label')) if not (item.get('hide') & client)]
if select is None:
select = DIALOG.selectDialog(listItems, '%s - %s'%(ADDON_NAME,LANGUAGE(32126)),multi=False)

Expand Down
6 changes: 3 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/xmltvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ def filterHoliday(program):


def sortChannels(self, channels: list) -> list:
return sorted(channels, key=lambda k:k.get('display-name'))
return sorted(channels, key=itemgetter('display-name'))


def sortProgrammes(self, programmes: list) -> list:
programmes.sort(key=lambda k:k.get('start'))
programmes.sort(key=lambda k:k.get('channel'))
programmes.sort(key=itemgetter('start'))
programmes.sort(key=itemgetter('channel'))
self.log('sortProgrammes, programmes = %s'%(len(programmes)))
return programmes

Expand Down
2 changes: 1 addition & 1 deletion plugin.video.pseudotv.live/resources/lib/xsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def parseXSP(self, path: str, media: str='video', sort: dict={}, filter: dict={}
try: media = 'music' if dom.getElementsByTagName('smartplaylist')[0].attributes['type'].value.lower() in MUSIC_TYPES else 'video'
except Exception as e: self.log("parseXSP, parsing media failed! %s"%(e), xbmc.LOGDEBUG)

try: limit = dom.getElementsByTagName('limit')[0].childNodes[0].nodeValue
try: limit = (int(dom.getElementsByTagName('limit')[0].childNodes[0].nodeValue) or limit)
except Exception as e: self.log("parseXSP, parsing limit failed! %s"%(e), xbmc.LOGDEBUG)

try: sort.update({"method":dom.getElementsByTagName('order')[0].childNodes[0].nodeValue.lower()}) #todo pop rules to filter var.
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 34da0bd

Please sign in to comment.