Skip to content

Commit

Permalink
Support sort by group title and fixed bug (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhijun <[email protected]>
  • Loading branch information
yszc and Zhijun authored Jan 16, 2022
1 parent 507b6cd commit c13578c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion iptvtools/constants/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion iptvtools/constants/helps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand Down
2 changes: 2 additions & 0 deletions iptvtools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions iptvtools/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit c13578c

Please sign in to comment.