diff --git a/iptvtools/constants/defaults.py b/iptvtools/constants/defaults.py index a818853..6558935 100644 --- a/iptvtools/constants/defaults.py +++ b/iptvtools/constants/defaults.py @@ -13,7 +13,7 @@ LOG_LEVEL = 'INFO' MIN_HEIGHT = 0 OUTPUT = 'iptvtools.m3u' -SORT_KEYS = ['tvg-id', 'height', 'title'] +SORT_KEYS = ['group-title', 'tvg-id', 'height', 'title'] TEMPLATES = [] TIMEOUT = 10 UDPXY = None diff --git a/iptvtools/constants/helps.py b/iptvtools/constants/helps.py index 74e769f..17ea900 100644 --- a/iptvtools/constants/helps.py +++ b/iptvtools/constants/helps.py @@ -46,7 +46,7 @@ ) SORT_KEYS = ( 'List of keys to sort the channels. Valid options currently supported ' - 'are `tvg-id`, `height` and `title`.' + 'are `group-title`, `tvg-id`, `height` and `title`.' ) TEMPLATES = ( 'Template m3u files/urls with well-maintained channel information to ' diff --git a/iptvtools/models.py b/iptvtools/models.py index aef212f..27cabcb 100644 --- a/iptvtools/models.py +++ b/iptvtools/models.py @@ -168,4 +168,6 @@ def __custom_sort(self, url): res.append(entry.get(key, '')) elif key == 'tvg-id': res.append(int(entry['params'].get(key) or sys.maxsize)) + elif key == 'group-title': + res.append(entry['params'].get(key) or '') return res diff --git a/iptvtools/parsers.py b/iptvtools/parsers.py index 8a032f4..85bdab7 100644 --- a/iptvtools/parsers.py +++ b/iptvtools/parsers.py @@ -21,8 +21,8 @@ def parse_content_to_lines(content): if os.path.isfile(content): fp = open(content, encoding='utf-8') else: - fp = tempfile.TemporaryFile() - fp.write(requests.get(content)) + fp = tempfile.TemporaryFile(mode='w+t') + fp.write(requests.get(content).text) fp.seek(0) for line in fp: yield re.sub(r'[^\S ]+', '', line.strip())