From f7e81d7678a0c130e718cd351cc4b6d69b987231 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Tue, 2 Feb 2021 23:52:22 +0100 Subject: [PATCH] Make JSON-STREAMS group a list Just as the M3U8 standard allows multiple group names, JSON-STREAMS should accept a list of groups. --- resources/lib/modules/addon.py | 16 ++++++++++++++-- resources/lib/modules/iptvsimple.py | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/resources/lib/modules/addon.py b/resources/lib/modules/addon.py index 3d8e188..fb72dad 100644 --- a/resources/lib/modules/addon.py +++ b/resources/lib/modules/addon.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, division, unicode_literals +import sys import json import logging import os @@ -164,9 +165,20 @@ def get_channels(self): elif not channel.get('logo').startswith(('http://', 'https://', 'special://', 'resource://', '/')): channel['logo'] = os.path.join(self.addon_path, channel.get('logo')) - # Add add-on name as group + # Ensure group is a set if not channel.get('group'): - channel['group'] = kodiutils.addon_name(self.addon_obj) + channel['group'] = set() + # Accept string values (backward compatible) + # noqa: F821; pylint: disable=undefined-variable + elif isinstance(channel.get('group'), (str, bytes)) or (sys.version_info.major == 2 and isinstance(channel.get('group'), unicode)): + channel['group'] = set(channel.get('group').split(';')) + elif isinstance(channel.get('group'), list): + channel['group'] = set(list(channel.get('group'))) + else: + _LOGGER.warning('Channel group is not a list: %s', channel) + channel['group'] = set() + # Add add-on name as group, if not already + channel['group'].add(kodiutils.addon_name(self.addon_obj)) channels.append(channel) diff --git a/resources/lib/modules/iptvsimple.py b/resources/lib/modules/iptvsimple.py index 83af90a..23cf481 100644 --- a/resources/lib/modules/iptvsimple.py +++ b/resources/lib/modules/iptvsimple.py @@ -125,7 +125,7 @@ def write_playlist(channels): if channel.get('preset'): m3u8_data += ' tvg-chno="{preset}"'.format(**channel) if channel.get('group'): - m3u8_data += ' group-title="{group}"'.format(**channel) + m3u8_data += ' group-title="{groups}"'.format(groups=';'.join(channel.get('group'))) if channel.get('radio'): m3u8_data += ' radio="true"' m3u8_data += ' catchup="vod",{name}\n'.format(**channel)