Skip to content

Commit

Permalink
v.0.4.8c
Browse files Browse the repository at this point in the history
v.0.4.8b
  • Loading branch information
Lunatixz committed Apr 2, 2024
1 parent 42b3ab2 commit 3d8531b
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 123 deletions.
3 changes: 2 additions & 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.4.8a" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.4.8c" name="PseudoTV Live" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="pvr.iptvsimple" version="21.8.0"/>
Expand All @@ -17,6 +17,7 @@
<import addon="resource.videos.adverts.pseudotv" optional="true" version="0.0.1"/>
<import addon="resource.videos.trailers.pseudotv" optional="true" version="0.0.1"/>
<import addon="resource.videos.ratings.mpaa.classic" optional="true" version="0.0.4"/>
<import addon="plugin.video.youtube" optional="true" version="0.0.1"/>
<import addon="script.module.pil" optional="true" version="5.1.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="resources/lib/default.py">
Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2d2ab01ded0241af255c62771249bf0a
110e17d5396279c111dc4d6c81908d1d
3 changes: 2 additions & 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.4.8a" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.4.8c" name="PseudoTV Live" provider-name="Lunatixz">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="pvr.iptvsimple" version="21.8.0"/>
Expand All @@ -16,6 +16,7 @@
<import addon="resource.videos.adverts.pseudotv" optional="true" version="0.0.1"/>
<import addon="resource.videos.trailers.pseudotv" optional="true" version="0.0.1"/>
<import addon="resource.videos.ratings.mpaa.classic" optional="true" version="0.0.4"/>
<import addon="plugin.video.youtube" optional="true" version="0.0.1"/>
<import addon="script.module.pil" optional="true" version="5.1.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="resources/lib/default.py">
Expand Down
3 changes: 3 additions & 0 deletions plugin.video.pseudotv.live/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v.0.4.9
-Fixed seasons returning incorrect holiday for the first week of April.

v.0.4.8
-Notice The following steps are required!.
- Open PseudoTV Live settings, under Miscellaneous; Click "Utility Menu" and select "Delete M3U/XMLTV".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ msgid "Pagination Limit, How many entries are requested and parsed per call. [25
msgstr ""

msgctxt "#33016"
msgid "[COLOR=red][B]Currently Unavailable (Coming Soon)![/B][/COLOR]\nGlobal Filler rules apply to all channels, Advanced channel manager rules apply per channel. *see readme for details."
msgid "Global Filler rules apply to all channels, Advanced channel manager rules apply per channel. *see readme for details.\nChanges will propagate slowly over time and are not instantaneous."
msgstr ""

msgctxt "#33023"
Expand Down
3 changes: 1 addition & 2 deletions plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def buildFileList(self, citem, path, media='video', limit=SETTINGS.getSettingInt
def buildList(self, citem, path, media='video', page=SETTINGS.getSettingInt('Page_Limit'), sort={}, limits={}, dirItem={}, query={}):
self.log("buildList, id: %s, media = %s, path = %s\npage = %s, sort = %s, query = %s, limits = %s\ndirItem = %s"%(citem['id'],media,path,page,sort,query,limits,dirItem))
dirList, fileList, seasoneplist = [], [], []
items, limits, errors = self.jsonRPC.requestList(citem, path, media, page, sort, limits, query)
items, olimits, errors = self.jsonRPC.requestList(citem, path, media, page, sort, limits, query)
if items == self.loopback:# malformed jsonrpc queries will return root response, catch a re-parse and return.
self.pErrors.append(LANGUAGE(32030))
self.log("buildList, id: %s, loopback detected using path = %s\nreturning: fileList (%s), dirList (%s)"%(citem['id'],path,len(fileList),len(dirList)))
Expand All @@ -309,7 +309,6 @@ def buildList(self, citem, path, media='video', page=SETTINGS.getSettingInt('Pag
if self.service._interrupt() or self.service._suspend():
self.pErrors = [LANGUAGE(32160)]
self.completeBuild = False
limits["end"] = limits.get('end', 0) - page
self.jsonRPC.autoPagination(citem['id'], '|'.join([path,dumpJSON(query)]), limits) #rollback pagination limits
return [], []
else:
Expand Down
1 change: 0 additions & 1 deletion plugin.video.pseudotv.live/resources/lib/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
class Channels:

def __init__(self):
self.cache = Cache()
self.channelDATA = getJSON(CHANNELFLE_DEFAULT)
self.channelTEMP = getJSON(CHANNEL_ITEM)
self.channelDATA.update(self._load())
Expand Down
122 changes: 20 additions & 102 deletions plugin.video.pseudotv.live/resources/lib/fillers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def fillSources(self):
# values['items'].update(self.getfilelist(ftype,id))


@cacheit(expiration=datetime.timedelta(minutes=15),json_data=True)
# @cacheit(expiration=datetime.timedelta(minutes=15),json_data=True)
def buildResource(self, ftype, addonid):
self.log('buildResource, type = %s, addonid = %s'%(ftype, addonid))
def _parse(addonid):
Expand Down Expand Up @@ -125,63 +125,60 @@ def convertMPAA(self, ompaa):


def getRating(self, keys=[]):
def _parse(key):
tmpLST.extend(self.bctTypes['ratings'].get('items',{}).get(key,[]))
try:
tmpLST = []
poolit(_parse)(keys)
for key in keys: tmpLST.extend(self.bctTypes['ratings'].get('items',{}).get(key,[]))
return random.choice(tmpLST)
except: return None, 0


def getBumper(self, keys=['resources']):
def _parse(key):
tmpLST.extend(self.bctTypes['bumpers'].get('items',{}).get(key.lower(),[]))
try:
tmpLST = []
poolit(_parse)(keys)
for key in keys: tmpLST.extend(self.bctTypes['bumpers'].get('items',{}).get(key.lower(),[]))
random.shuffle(tmpLST)
return random.choice(tmpLST)
except: return None, 0


def getAdverts(self, keys=['resources'], count=1):
def _parse(key):
return self.bctTypes['adverts'].get('items',{}).get(key.lower(),[])
try:
tmpLST = poolit(_parse)(keys)
tmpLST = []
for key in keys: tmpLST.extend(self.bctTypes['adverts'].get('items',{}).get(key.lower(),[]))
random.shuffle(tmpLST)
removeDUPDICT(random.choices(tmpLST,k=count))
except: return [(None, 0)]


def getTrailers(self, keys=['resources'], count=1):
def _parse(key):
return self.bctTypes['trailers'].get('items',{}).get(key.lower(),[])
try:
tmpLST = poolit(_parse)(keys)
tmpLST = []
for key in keys: tmpLST.extend(self.bctTypes['trailers'].get('items',{}).get(key.lower(),[]))
random.shuffle(tmpLST)
removeDUPDICT(random.choices(tmpLST,k=count))
except: return [(None, 0)]


def buildKodiTrailers(self, fileList):
def _parse(fileItem):
if fileItem.get('trailer') and not fileItem.get('trailer','').startswith(tuple(VFS_TYPES)):
if fileItem.get('trailer') and not fileItem.get('trailer','').startswith(('http','upnp','ftp')):
dur = self.jsonRPC.getDuration(fileItem.get('trailer'), accurate=True)
if dur > 0: tmpLST.append((fileItem.get('trailer'), dur))
tmpLST = []
poolit(_parse)(fileList)
if dur > 0: (fileItem.get('trailer'), dur)
tmpLST = poolit(_parse)(fileList)
if len(tmpLST) > 0:
resLST = self.bctTypes['trailers']['items'].get('resources',[])
tmpLST.reverse()
self.bctTypes['trailers']['items'].setdefault("resources",[]).extend(tmpLST)
self.bctTypes['trailers']['items']['resources'] = [t for t in (set(tuple(i) for i in self.bctTypes['trailers']['items']['resources']))]
print('buildKodiTrailers',self.bctTypes['trailers']['items']['resources'])


resLST.extend(tmpLST)
resLST = [t for t in (set(tuple(i) for i in resLST))]
resLST.shuffle()
self.bctTypes['trailers']['items']['resources'] = resLST


def injectBCTs(self, citem, fileList):
nfileList = []
if self.bctTypes['trailers']['enabled'] and SETTINGS.getSettingInt('Include_Trailers') < 2:
if self.builder.pDialog: self.builder.pDialog = DIALOG.progressBGDialog(self.builder.pCount, self.builder.pDialog, message='%s - Parsing Kodi for Trailers...'%(self.builder.pName),header='%s, %s'%(ADDON_NAME,self.builder.pMSG))
self.buildKodiTrailers(fileList)

for idx, fileItem in enumerate(fileList):
Expand Down Expand Up @@ -261,83 +258,4 @@ def injectBCTs(self, citem, fileList):
if len(pfileList) > 0:
pfileList.shuffle()
nfileList.extend(pfileList)
return nfileList

# getSettingInt('Include_Trailers')
# HasAddon(plugin.video.imdb.trailers)
# HasContent(Movies)
# return fileList
# if not fileList: return fileList
# self.log("injectBCTs, channel = %s, fileList = %s"%(citem.get('id'),len(fileList)))
# ratings = self.buildResourceByType('ratings')
# bumpers = self.buildResourceByType('bumpers')

# lstop = 0
# nFileList = list()
# chname = citem.get('name','')
# chcats = citem.get('groups',[])

# for idx,fileItem in enumerate(fileList):
# fileItem['originalfile'] = fileItem.get('file','')
# fileItem['start'] = fileItem['start'] if lstop == 0 else lstop
# fileItem['stop'] = fileItem['start'] + fileItem['duration']

# paths = [file]
# oPaths = paths.copy()
# stop = fileItem['stop']
# end = abs(roundTimeUp(stop) - stop) #auto mode

# # print('duration',fileItem['duration'])
# # print('start',datetime.datetime.fromtimestamp(fileItem['start']))
# # print('stop',datetime.datetime.fromtimestamp(stop))
# # print('end',end)

# if ratings and self.bctTypes['ratings'].get('enabled',True):
# mpaa = cleanMPAA(fileItem.get('mpaa',''))
# if self.builder.is3D(fileItem): mpaa += ' (3DSBS)'
# rating = ratings.get(mpaa.lower(), {})
# if rating:
# paths.insert(0,rating.get('file'))
# end -= rating.get('duration')
# # print('end ratings', end)
# # print('mpaa',mpaa)
# # print('rating',rating)

# if bumpers and self.bctTypes['bumpers'].get('enabled',True):
# bumper = random.choice(bumpers)
# paths.insert(0,bumper.get('file'))
# end -= bumper.get('duration')
# # print('end bumper', end)
# # print('chname',chname)
# # print('bumper',bumper)





# return fileList















#settings
# Fillers_Ratings #0=disabled,1=auto,2=1 insert,3=2 insert, 4=3 insert, 5=4 insert.
# Fillers_Bumpers
# Fillers_Commercials
# Fillers_Trailers

# Resource_Ratings #ex resource.videos.trailers.sample
# Resource_Bumpers #ex resource.videos.bumpers.pseudotv|resource.videos.bumpers.sample
# Resource_Commericals
# Resource_Trailers
return nfileList
25 changes: 18 additions & 7 deletions plugin.video.pseudotv.live/resources/lib/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"premiered", "playcount", "studio"]

class JSONRPC:
def __init__(self):
self.cache = Cache()
def __init__(self, cache=None):
if cache is None: self.cache = Cache()
else: self.cache = cache
self.videoParser = VideoParser()


Expand Down Expand Up @@ -268,12 +269,22 @@ def getPVRBroadcastDetails(self, id):
return self.sendJSON(param).get('result', {}).get('broadcastdetails', [])


# @cacheit(expiration=datetime.timedelta(days=28))
def parseYoutubeRuntime(self, id):
runtime = 0
#todo user api keys.
# from youtube_requests import get_videos
# https://github.com/anxdpanic/plugin.video.youtube/blob/master/resources/lib/youtube_requests.py#L62
self.log("parseYoutubeRuntime, id = %s, runtime = %s" % (id, runtime))
return runtime


def getDuration(self, path, item={}, accurate=bool(SETTINGS.getSettingInt('Duration_Type'))):
self.log("getDuration, accurate = %s, path = %s" % (accurate, path))
for runtime in [float(item.get('runtime' , '0') or '0'),
float(item.get('duration', '0') or '0'),
float((item.get('streamdetails', {}).get('video',[]) or [{}])[0].get('duration','') or '0')]:
if runtime > 0: break
runtime = float((item.get('runtime') or item.get('duration') or (item.get('streamdetails', {}).get('video') or [{}])[0].get('duration','0')))
if not runtime and not item and path.startswith('plugin://plugin.video.youtube/play/?video_id='):
try: runtime = self.parseYoutubeRuntime(path.split('?video_id=')[1])
except: runtime = 0

if (runtime == 0 or accurate):
if not path.startswith(tuple(VFS_TYPES)):# no additional parsing needed item[runtime] has only meta available.
Expand Down Expand Up @@ -410,7 +421,7 @@ def requestList(self, citem, path, media='video', page=SETTINGS.getSettingInt('P
else: key = 'files'
else:
results = self.getLibrary(query['method'],param)
key = query.get('key',list(results.keys())[0])
key = query.get('key',list(results.keys())[0])

limits = results.get('limits', param["limits"])
if (limits.get('end',0) >= limits.get('total',0) or limits.get('start',0) >= limits.get('total',0)):
Expand Down
8 changes: 5 additions & 3 deletions plugin.video.pseudotv.live/resources/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def playBroadcast(self, name, chid, vid):
def playRadio(self, name, chid, vid):
self.log('playRadio, id = %s'%(chid))
with self.preparingPlayback():
jsonRPC = JSONRPC()
jsonRPC = JSONRPC(self.cache)
fileList = interleave([jsonRPC.requestList({'id':chid}, path, 'music', page=RADIO_ITEM_LIMIT, sort={"method":"random"})[0] for path in vid.split('|')])#todo replace RADIO_ITEM_LIMIT with cacluated runtime to EPG_HRS
if len(fileList) > 0:
channelPlaylist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
Expand Down Expand Up @@ -136,7 +136,8 @@ def buildfItem(item={}, media='video'):
found = False
listitems = [xbmcgui.ListItem()]
fitem = self.sysInfo.get('fitem')
pvritem = self.matchChannel(name,chid,radio=False,isPlaylist=True)
with busy_dialog(), suspendActivity():
pvritem = self.matchChannel(name,chid,radio=False,isPlaylist=True)
if pvritem.get('citem'): self.sysInfo['citem'].update(pvritem.pop('citem'))

if pvritem:
Expand Down Expand Up @@ -193,6 +194,7 @@ def buildfItem(item={}, media='video'):


@timeit
@cacheit(expiration=datetime.timedelta(seconds=15),json_data=True)
def matchChannel(self, chname, id, radio=False, isPlaylist=False):
self.log('matchChannel, id = %s, chname = %s, radio = %s, isPlaylist = %s'%(id,chname,radio,isPlaylist))
def getCallback(chname, id, radio=False, isPlaylist=False):
Expand Down Expand Up @@ -261,7 +263,7 @@ def _parseBroadcast(broadcast={}):
self.log('extendProgrammes, extend broadcastnext to %s entries'%(len(pvritem['broadcastnext'])))
return pvritem

jsonRPC = JSONRPC()
jsonRPC = JSONRPC(self.cache)
cacheName = 'matchChannel.%s'%(getMD5('%s.%s.%s.%s'%(chname,id,radio,isPlaylist)))
cacheResponse = self.cache.get(cacheName, checksum=getInstanceID(), json_data=True, default={})
if not cacheResponse:
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 @@ -123,8 +123,8 @@ def getWeek(self):
dt = datetime.datetime.now()
adjusted_dom = dt.day + dt.replace(day=1).weekday()
week = (adjusted_dom/7.0)
if week > 4.0: return int(ceil(week))
else: return int(floor(week))
if week < 1 or week > 4: return int(ceil(week))
else: return int(floor(week))


def getCurrentHoliday(self):
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 @@ -23,7 +23,7 @@

class XSP:
def __init__(self):
self.cache = Cache()
...


def log(self, msg, level=xbmc.LOGDEBUG):
Expand Down
5 changes: 4 additions & 1 deletion plugin.video.pseudotv.live/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@
<addontype>kodi.resource.images</addontype>
</constraints>
<dependencies>
<dependency type="visible">
<condition on="property" name="InfoBool">String.Contains(Window(10000).Property(plugin.video.pseudotv.live.isClient),false)</condition>
</dependency>
</dependencies>
<control type="button" format="addon">
<heading>30067</heading>
Expand Down Expand Up @@ -775,7 +778,7 @@
</setting>
<setting id="Enable_Fillers" type="boolean" label="30056" help="33056">
<level>1</level>
<default>true</default>
<default>false</default>
<dependencies>
<dependency type="visible">
<and>
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 3d8531b

Please sign in to comment.