Skip to content

Commit

Permalink
v.0.5.8g
Browse files Browse the repository at this point in the history
  • Loading branch information
Lunatixz committed Jan 22, 2025
1 parent 9b78628 commit eff7cfe
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 554 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.8f" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.8g" 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 @@
c061b9ceef62e471c0bc10fbecd10699
a63904bfb41ab73dc27a6f65b0aefe7a
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.8f" name="PseudoTV Live" provider-name="Lunatixz">
<addon id="plugin.video.pseudotv.live" version="0.5.8g" 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
808 changes: 277 additions & 531 deletions plugin.video.pseudotv.live/changelog.txt

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions plugin.video.pseudotv.live/resources/lib/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,13 @@ def __clrChannel(citem):
self.pCount = int(idx*100//len(channels))
self.runActions(RULES_ACTION_CHANNEL_START, citem, inherited=self)

if not preview and citem['id'] in clrIDS: __clrChannel({'id':clrIDS.pop(clrIDS.index(citem['id']))})
stopTimes = dict(self.xmltv.loadStopTimes([citem], fallback=datetime.datetime.fromtimestamp(start).strftime(DTFORMAT)))
if (stopTimes.get(citem['id']) or start) > (now + ((MAX_GUIDEDAYS * 86400) - 43200)): self.pMSG = '%s %s'%(LANGUAGE(32028),LANGUAGE(32023)) #Checking
elif stopTimes.get(citem['id']): self.pMSG = '%s %s'%(LANGUAGE(32022),LANGUAGE(32023)) #Updating
else: self.pMSG = '%s %s'%(LANGUAGE(30014),LANGUAGE(32023)) #Building
if not preview and citem['id'] in clrIDS: __clrChannel({'id':clrIDS.pop(clrIDS.index(citem['id']))}) #clear channel m3u/xmltv
stopTimes = dict(self.xmltv.loadStopTimes([citem], fallback=datetime.datetime.fromtimestamp(start).strftime(DTFORMAT))) #check last stop times

if preview: self.pMSG = LANGUAGE(32236) #Building Preview
elif (stopTimes.get(citem['id']) or start) > (now + ((MAX_GUIDEDAYS * 86400) - 43200)): self.pMSG = '%s %s'%(LANGUAGE(32028),LANGUAGE(32023)) #Checking
elif stopTimes.get(citem['id']): self.pMSG = '%s %s'%(LANGUAGE(32022),LANGUAGE(32023)) #Updating
else: self.pMSG = '%s %s'%(LANGUAGE(30014),LANGUAGE(32023)) #Building

cacheResponse = self.getFileList(citem, now, (stopTimes.get(citem['id']) or start))# {False:'In-Valid Channel', True:'Valid Channel w/o programmes', list:'Valid Channel w/ programmes}
if preview:
Expand Down
137 changes: 137 additions & 0 deletions plugin.video.pseudotv.live/resources/lib/data/channels_dataclass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
from dataclasses import asdict
from typing import List, Dict
import random
from operator import itemgetter
from globals import getJSON, setJSON, SETTINGS, PROPERTIES, LANGUAGE, xbmc, log

@dataclass
class Channel:
id: str
type: str
number: int
name: str
logo: str
path: List[str] = field(default_factory=list)
group: List[str] = field(default_factory=list)
rules: Dict = field(default_factory=dict)
catchup: str = "vod"
radio: bool = False
favorite: bool = False

class Channels:
def __init__(self):
self.channelDATA: Dict[str, List[Channel]] = getJSON(CHANNELFLE_DEFAULT)
self.channelTEMP: Dict = getJSON(CHANNEL_ITEM)
self.channelDATA.update(self._load())

def log(self, msg, level=xbmc.LOGDEBUG):
return log('%s: %s' % (self.__class__.__name__, msg), level)

def _load(self, file=CHANNELFLEPATH) -> Dict[str, List[Channel]]:
channelDATA = getJSON(file)
self.log('_load, channels = %s' % (len(channelDATA.get('channels', []))))
return channelDATA

def _verify(self, channels: List[Channel] = []):
for idx, citem in enumerate(self.channelDATA.get('channels', [])):
if not citem.name or not citem.id or len(citem.path) == 0:
self.log('_verify, in-valid citem [%s]\n%s' % (citem.id, citem))
continue
else:
yield citem

def _save(self, file=CHANNELFLEPATH) -> bool:
self.channelDATA['uuid'] = SETTINGS.getMYUUID()
self.channelDATA['channels'] = self.sortChannels(self.channelDATA['channels'])
self.log('_save, channels = %s' % (len(self.channelDATA['channels'])))
return setJSON(file, self.channelDATA)

def getTemplate(self) -> Dict:
return self.channelTEMP.copy()

def getChannels(self) -> List[Channel]:
return sorted(self.channelDATA['channels'], key=itemgetter('number'))

def popChannels(self, type: str, channels: List[Channel] = []) -> List[Channel]:
return [self.channelDATA['channels'].pop(self.channelDATA['channels'].index(citem)) for citem in list([c for c in channels if c.type == type])]

def getCustom(self) -> List[Channel]:
channels = self.getChannels()
return list([citem for citem in channels if citem.number <= CHANNEL_LIMIT])

def getAutotuned(self) -> List[Channel]:
channels = self.getChannels()
return list([citem for citem in channels if citem.number > CHANNEL_LIMIT])

def getChannelbyID(self, id: str) -> List[Channel]:
channels = self.getChannels()
return list([c for c in channels if c.id == id])

def getType(self, type: str) -> List[Channel]:
channels = self.getChannels()
return list([citem for citem in channels if citem.type == type])

def sortChannels(self, channels: List[Channel]) -> List[Channel]:
try:
return sorted(channels, key=itemgetter('number'))
except:
return channels

def setChannels(self, channels: List[Channel] = []) -> bool:
if len(channels) == 0:
channels = self.channelDATA['channels']
self.channelDATA['channels'] = channels
SETTINGS.setSetting('Select_Channels', '[B]%s[/B] Channels' % (len(channels)))
PROPERTIES.setChannels(len(channels) > 0)
return self._save()

def getImports(self) -> List:
return self.channelDATA.get('imports', [])

def setImports(self, data: List = []) -> bool:
self.channelDATA['imports'] = data
return self.setChannels()

def clearChannels(self):
self.channelDATA['channels'] = []

def delChannel(self, citem: Channel) -> bool:
self.log('delChannel,[%s]' % (citem.id), xbmc.LOGINFO)
idx, channel = self.findChannel(citem)
if idx is not None:
self.channelDATA['channels'].pop(idx)
return True

def addChannel(self, citem: Channel) -> bool:
idx, channel = self.findChannel(citem)
if idx is not None:
for key in ['id', 'rules', 'number', 'favorite', 'logo']:
if getattr(channel, key):
setattr(citem, key, getattr(channel, key)) # existing id found, reuse channel meta.

if citem.favorite:
citem.group.append(LANGUAGE(32019))
citem.group = sorted(set(citem.group))

self.log('addChannel, [%s] updating channel %s' % (citem.id, citem.name), xbmc.LOGINFO)
self.channelDATA['channels'][idx] = citem
else:
self.log('addChannel, [%s] adding channel %s' % (citem.id, citem.name), xbmc.LOGINFO)
self.channelDATA.setdefault('channels', []).append(citem)
return True

def findChannel(self, citem: Channel, channels: List[Channel] = []) -> tuple:
if len(channels) == 0:
channels = self.getChannels()
for idx, eitem in enumerate(channels):
if citem.id == eitem.id:
return idx, eitem
return None, {}

def findAutotuned(self, citem: Channel, channels: List[Channel] = []) -> tuple:
if len(channels) == 0:
channels = self.getAutotuned()
for idx, eitem in enumerate(channels):
if citem.id == eitem.id or (citem.type == eitem.type and citem.name.lower() == eitem.name.lower()):
return idx, eitem
return None, {}
32 changes: 19 additions & 13 deletions plugin.video.pseudotv.live/resources/lib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,25 @@ def qrBonjourDL(self):
def showChangelog(self):
try:
def __addColor(text):
text = text.replace('-Added' ,'[COLOR=green][B]-Added:[/B][/COLOR]')
text = text.replace('-New!' ,'[COLOR=yellow][B]-New!:[/B][/COLOR]')
text = text.replace('-Optimized' ,'[COLOR=yellow][B]-Optimized:[/B][/COLOR]')
text = text.replace('-Improved' ,'[COLOR=yellow][B]-Improved:[/B][/COLOR]')
text = text.replace('-Refactored' ,'[COLOR=yellow][B]-Refactored:[/B][/COLOR]')
text = text.replace('-Tweaked' ,'[COLOR=yellow][B]-Tweaked:[/B][/COLOR]')
text = text.replace('-Updated' ,'[COLOR=yellow][B]-Updated:[/B][/COLOR]')
text = text.replace('-Changed' ,'[COLOR=yellow][B]-Changed:[/B][/COLOR]')
text = text.replace('-Notice' ,'[COLOR=orange][B]-Notice:[/B][/COLOR]')
text = text.replace('-Fixed' ,'[COLOR=orange][B]-Fixed:[/B][/COLOR]')
text = text.replace('-Removed' ,'[COLOR=red][B]-Removed:[/B][/COLOR]')
text = text.replace('-Important' ,'[COLOR=red][B]-Important:[/B][/COLOR]')
text = text.replace('-Warning' ,'[COLOR=red][B]-Warning:[/B][/COLOR]')
text = text.replace('- Added' ,'[COLOR=green][B]- Added:[/B][/COLOR]')
text = text.replace('- Introduced' ,'[COLOR=green][B]- Introduced:[/B][/COLOR]')
text = text.replace('- New!' ,'[COLOR=yellow][B]- New!:[/B][/COLOR]')
text = text.replace('- Optimized' ,'[COLOR=yellow][B]- Optimized:[/B][/COLOR]')
text = text.replace('- Improved' ,'[COLOR=yellow][B]- Improved:[/B][/COLOR]')
text = text.replace('- Modified' ,'[COLOR=yellow][B]- Modified:[/B][/COLOR]')
text = text.replace('- Enhanced' ,'[COLOR=yellow][B]- Enhanced:[/B][/COLOR]')
text = text.replace('- Refactored' ,'[COLOR=yellow][B]- Refactored:[/B][/COLOR]')
text = text.replace('- Tweaked' ,'[COLOR=yellow][B]- Tweaked:[/B][/COLOR]')
text = text.replace('- Updated' ,'[COLOR=yellow][B]- Updated:[/B][/COLOR]')
text = text.replace('- Changed' ,'[COLOR=yellow][B]- Changed:[/B][/COLOR]')
text = text.replace('- Notice' ,'[COLOR=orange][B]- Notice:[/B][/COLOR]')
text = text.replace('- Fixed' ,'[COLOR=orange][B]- Fixed:[/B][/COLOR]')
text = text.replace('- Resolved' ,'[COLOR=orange][B]- Resolved:[/B][/COLOR]')
text = text.replace('- Removed' ,'[COLOR=red][B]- Removed:[/B][/COLOR]')
text = text.replace('- Excluded' ,'[COLOR=red][B]- Excluded:[/B][/COLOR]')
text = text.replace('- Deprecated' ,'[COLOR=red][B]- Deprecated:[/B][/COLOR]')
text = text.replace('- Important' ,'[COLOR=red][B]- Important:[/B][/COLOR]')
text = text.replace('- Warning' ,'[COLOR=red][B]- Warning:[/B][/COLOR]')
return text

with BUILTIN.busy_dialog():
Expand Down
3 changes: 1 addition & 2 deletions plugin.video.pseudotv.live/resources/lib/xmltvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ def cleanProgrammes(self, programmes: list) -> list:

def __filterProgrammes(program):
citem = decodePlot(program.get('desc',([{}],''))[0][0]).get('citem',{})
if citem.get('id') in clrIDS: return None
elif citem.get('holiday') and citem.get('holiday',{}).get('name',str(random.random())) != holiday.get('name',str(random.random())): return None
if citem.get('holiday') and citem.get('holiday',{}).get('name',str(random.random())) != holiday.get('name',str(random.random())): return None
elif (strpTime(program.get('stop',now).rstrip(),DTFORMAT) < now): return None # remove expired content, ignore "recordings" ie. media=True
return program

Expand Down
Binary file not shown.

0 comments on commit eff7cfe

Please sign in to comment.