Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta1" provider-name="A Talented Community">
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta2" provider-name="A Talented Community">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.six" version="1.9.0"/>
Expand All @@ -13,7 +13,6 @@
</news>
<assets>
<icon>icon.png</icon>
<fanart>fanart.jpg</fanart>
</assets>
<platform>all</platform>
<summary lang="en">Module for interaction with the Twitch.tv API</summary>
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 39 additions & 10 deletions resources/lib/twitch/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ def m3u8_to_dict(string):
d = dict()
matches = re.finditer(_m3u_pattern, string)
for m in matches:
d[m.group('group_name')] = m.group('url')
if m.group('group_id') == 'chunked':
d.update({'Source': m.group('url')}) # ensure Source stream identified for consistency

d[m.group('group_id')] = {
'id': m.group('group_id'),
'name': 'Source',
'url': m.group('url'),
'bandwidth': int(m.group('bandwidth'))
}
else:
d[m.group('group_id')] = {
'id': m.group('group_id'),
'name': m.group('group_name'),
'url': m.group('url'),
'bandwidth': int(m.group('bandwidth'))
}
log.debug('m3u8_to_dict result:\n{}'.format(d))
return d

Expand All @@ -55,13 +65,21 @@ def m3u8_to_list(string):
log.debug('m3u8_to_list called for:\n{}'.format(string))
l = list()
matches = re.finditer(_m3u_pattern, string)
chunked = None
for m in matches:
l.append((m.group('group_name'), m.group('url'), m.group('bandwidth')))
if m.group('group_id') == 'chunked':
chunked = ('Source', m.group('url'), int(m.group('bandwidth')))
if (chunked) and (not any(re.match('[Ss]ource', name) for name, url, bandwidth in l)):
l.insert(0, chunked)
l.insert(0, {
'id': m.group('group_id'),
'name': 'Source',
'url': m.group('url'),
'bandwidth': int(m.group('bandwidth'))
})
else:
l.append({
'id': m.group('group_id'),
'name': m.group('group_name'),
'url': m.group('url'),
'bandwidth': int(m.group('bandwidth'))
})

log.debug('m3u8_to_list result:\n{}'.format(l))
return l
Expand All @@ -73,8 +91,19 @@ def clip_embed_to_list(string):
l = list()
if match:
match = eval(match.group('qualities'))
l = [(item['quality'], item['source'], -1) for item in match]
l.insert(0, ('Source', l[0][1], -1))
l = [{
'id': item['quality'],
'name': item['quality'],
'url': item['source'],
'bandwidth': -1
} for item in match]
if l:
l.insert(0, {
'id': 'Source',
'name': 'Source',
'url': l[0]['url'],
'bandwidth': -1
})

log.debug('clip_embed_to_list result:\n{}'.format(l))
return l