2023-04-30, 22:08
I got it to work, but not everything is working in the add-on itself. I'm importing the channels/guide using IPTVMerge and using IPTV Simple to watch TV through Kodi so my desire was to just get it working in that respect.
I've updated the lib/menus/channels.py to use a different URL to get the channels and then changed the way it loops through them. Also, updated the lib/classes/channel.py so that it doesn't error out on the images.
Here is what I did to get it working.
Copy and paste the below to replace everything in the def getChannels():
And then in lib/classes/channel.py replace def processJSON() with the following:
I have both Sling Blue and Orange and I'm not sure if this will pull in a lot more channels than you are subscribed to but let me know and I'll see what I can do.
I've updated the lib/menus/channels.py to use a different URL to get the channels and then changed the way it loops through them. Also, updated the lib/classes/channel.py so that it doesn't error out on the images.
Here is what I did to get it working.
Copy and paste the below to replace everything in the def getChannels():
Code:
def getChannels(self):
success, region = self.auth.getRegionInfo()
if not success:
notificationDialog(LANGUAGE(30016))
return
USER_DMA = region['USER_DMA']
USER_OFFSET = region['USER_OFFSET']
subs = binascii.b2a_base64(str.encode(LEGACY_SUBS.replace('+', ','))).decode().strip()
channels_url = '%s/cms/publish3/domain/channels/v4/%s/%s/%s/1.json' % \
(self.endPoints['cms_url'], USER_OFFSET, USER_DMA, subs)
channels_url = self.endPoints['channels_url']
log('\r%s' % channels_url)
response = requests.get(channels_url, headers=HEADERS, verify=VERIFY)
if response is not None and response.status_code == 200:
response = response.json()
if 'channels' in response:
channel_names = ''
for channel in response['channels']:
if channel['network_affiliate_name'] is not None:
if 'Sling' not in channel['network_affiliate_name']:
if channel['channel_guid'] != '' and '"%s"' % channel['network_affiliate_name'] not in channel_names:
if channel['network_affiliate_name'] not in ('FOX', 'ABC', 'NBC', 'CBS'):
channel_names = '%s,"%s"' % (channel_names, channel['network_affiliate_name']) if channel_names != '' else '"%s"' %channel['network_affiliate_name']
temp_channel = Channel(channel['channel_guid'], self.endPoints, self.DB)
if temp_channel.GUID != '':
self.Channels[channel['channel_guid']] = temp_channel
query = "SELECT GUID FROM Channels WHERE Protected = 1"
try:
cursor = self.DB.cursor()
cursor.execute(query)
protected = cursor.fetchall()
for record in protected:
if record[0] not in self.Channels:
self.Channels[record[0]] = Channel(record[0], self.endPoints, self.DB)
except sqlite3.Error as err:
log('setSetting(): Failed retrieve protected records from DB, error => %s' % err)
except Exception as exc:
log('setSetting(): Failed retrieve protected records from DB, exception => %s' % exc)
And then in lib/classes/channel.py replace def processJSON() with the following:
Code:
def processJSON(self, channel_json):
log('Processing channel json')
self.Name = channel_json['network_affiliate_name'] if 'network_affiliate_name' in channel_json else ''
self.Call_Sign = channel_json['title'] if 'title' in channel_json else ''
self.ID = int(channel_json['id']) if 'id' in channel_json else -1
self.GUID = channel_json['channel_guid'] if 'channel_guid' in channel_json else ''
if len(self.GUID) == 0:
self.GUID = channel_json['guid'] if 'guid' in channel_json else ''
if 'thumbnail' in channel_json:
self.Thumbnail = channel_json['thumbnail']['url'] if 'url' in channel_json['thumbnail'] else ICON
self.Qvt_Url = channel_json['qvt_url'] if 'qvt_url' in channel_json else ''
if len(self.Qvt_Url) == 0:
self.Qvt_Url = channel_json['qvt'] if 'qvt' in channel_json else ''
self.Offered = bool(channel_json['offered']) if 'offered' in channel_json else True
self.Call_Sign = channel_json['call_sign'] if 'call_sign' in channel_json else ''
if 'metadata' in channel_json:
metadata = channel_json['metadata']
self.Name = metadata['channel_name'] if 'channel_name' in metadata else self.Name
self.Call_Sign = metadata['call_sign'] if 'call_sign' in metadata else self.Call_Sign
if 'genre' in metadata:
genres = ''
for genre in metadata['genre']:
genres = '%s, %s' % (genres, genre) if len(genres) > 0 else genre
self.Genre = genres
self.Poster = metadata['default_schedule_image'] if 'default_schedule_image' in metadata else self.Poster
self.Language = metadata['language'] if 'language' in metadata else ''
if self.Poster == FANART and 'default_schedule_image' in channel_json:
self.Poster = channel_json['default_schedule_image'] if channel_json['default_schedule_image'] is not None else self.Poster
if len(self.Language) == 0:
self.Language = channel_json['language'] if 'language' in channel_json else ''
self.Name = self.Name.strip()
self.Genre = self.Genre.strip()
self.Language = self.Language.strip()
self.On_Demand = self.onDemand()
self.saveChannel()
return
I have both Sling Blue and Orange and I'm not sure if this will pull in a lot more channels than you are subscribed to but let me know and I'll see what I can do.