2021-11-01, 00:19
maybe i can take a look on original tvgf
here for settings
<setting id="channel.filter.sort" label="Sort Order for Channels in Categories" type="enum" default="0" values="Default|Sorted|categories.ini"/>
and it should be like this in source.py (from tvgf)
here for settings
<setting id="channel.filter.sort" label="Sort Order for Channels in Categories" type="enum" default="0" values="Default|Sorted|categories.ini"/>
and it should be like this in source.py (from tvgf)
python:def _getChannelList(self, onlyVisible, all=False):
c = self.conn.cursor()
channelList = list()
if onlyVisible:
c.execute('SELECT * FROM channels WHERE source=? AND visible=? ORDER BY weight', [self.source.KEY, 1])
else:
c.execute('SELECT * FROM channels WHERE source=? ORDER BY weight', [self.source.KEY])
for row in c:
channel = Channel(row['id'], row['title'], row['lineup'], row['logo'], row['stream_url'], row['visible'], row['weight'])
channelList.append(channel)
if all == False and self.category and self.category != "Any":
f = xbmcvfs.File('special://profile/addon_data/script.kc.guide/categories.ini','rb')
lines = f.read().splitlines()
f.close()
filter = []
seen = set()
for line in lines:
if "=" not in line:
continue
name,cat = line.split('=')
if cat == self.category:
if name not in seen:
filter.append(name)
seen.add(name)
NONE = "0"
SORT = "1"
CATEGORIES = "2"
new_channels = []
if ADDON.getSetting('channel.filter.sort') == CATEGORIES:
for filter_name in filter:
for channel in channelList:
if channel.title == filter_name:
new_channels.append(channel)
if new_channels:
channelList = new_channels
else:
for channel in channelList:
if channel.title in filter:
new_channels.append(channel)
if new_channels:
if ADDON.getSetting('channel.filter.sort') == SORT:
channelList = sorted(new_channels, key=lambda channel: channel.title.lower())
else:
channelList = new_channels
elif ADDON.getSetting('channel.filter.sort.all') == 'true':
channelList = sorted(channelList, key=lambda channel: channel.title.lower())
c.close()
return channelList