Skip to content

Commit e90134c

Browse files
authored
Merge pull request #19 from anxdpanic/dev
add audio only
2 parents a99ca1c + e7655a2 commit e90134c

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

addon.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta2" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~beta3" provider-name="A Talented Community">
33
<requires>
44
<import addon="xbmc.python" version="2.1.0"/>
55
<import addon="script.module.six" version="1.9.0"/>

resources/lib/twitch/api/usher.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def _live(channel, token):
4242
q.add_param(keys.TOKEN, token[keys.TOKEN])
4343
q.add_param(keys.ALLOW_SOURCE, Boolean.TRUE)
4444
q.add_param(keys.ALLOW_SPECTRE, Boolean.TRUE)
45+
q.add_param(keys.ALLOW_AUDIO_ONLY, Boolean.TRUE)
4546
return q
4647

4748

@@ -62,6 +63,7 @@ def _vod(video_id, token):
6263
q.add_param(keys.NAUTHSIG, token[keys.SIG])
6364
q.add_param(keys.NAUTH, token[keys.TOKEN])
6465
q.add_param(keys.ALLOW_SOURCE, Boolean.TRUE)
66+
q.add_param(keys.ALLOW_AUDIO_ONLY, Boolean.TRUE)
6567
return q
6668

6769

resources/lib/twitch/keys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
string constants
66
"""
77

8+
ALLOW_AUDIO_ONLY = 'allow_audio_only'
89
ALLOW_SOURCE = 'allow_source'
910
ALLOW_SPECTRE = 'allow_spectre'
1011
AVATAR_IMAGE = 'avatar_image'

resources/lib/twitch/parser.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,14 @@ def m3u8_to_dict(string):
4343
d = dict()
4444
matches = re.finditer(_m3u_pattern, string)
4545
for m in matches:
46-
if m.group('group_id') == 'chunked':
47-
d[m.group('group_id')] = {
48-
'id': m.group('group_id'),
49-
'name': 'Source',
50-
'url': m.group('url'),
51-
'bandwidth': int(m.group('bandwidth'))
52-
}
53-
else:
54-
d[m.group('group_id')] = {
55-
'id': m.group('group_id'),
56-
'name': m.group('group_name'),
57-
'url': m.group('url'),
58-
'bandwidth': int(m.group('bandwidth'))
59-
}
46+
name = 'Audio Only' if m.group('group_name') == 'audio_only' else m.group('group_name')
47+
name = 'Source' if m.group('group_id') == 'chunked' else name
48+
d[m.group('group_id')] = {
49+
'id': m.group('group_id'),
50+
'name': name,
51+
'url': m.group('url'),
52+
'bandwidth': int(m.group('bandwidth'))
53+
}
6054
log.debug('m3u8_to_dict result:\n{}'.format(d))
6155
return d
6256

@@ -66,20 +60,14 @@ def m3u8_to_list(string):
6660
l = list()
6761
matches = re.finditer(_m3u_pattern, string)
6862
for m in matches:
69-
if m.group('group_id') == 'chunked':
70-
l.insert(0, {
71-
'id': m.group('group_id'),
72-
'name': 'Source',
73-
'url': m.group('url'),
74-
'bandwidth': int(m.group('bandwidth'))
75-
})
76-
else:
77-
l.append({
78-
'id': m.group('group_id'),
79-
'name': m.group('group_name'),
80-
'url': m.group('url'),
81-
'bandwidth': int(m.group('bandwidth'))
82-
})
63+
name = 'Audio Only' if m.group('group_name') == 'audio_only' else m.group('group_name')
64+
name = 'Source' if m.group('group_id') == 'chunked' else name
65+
l.append({
66+
'id': m.group('group_id'),
67+
'name': name,
68+
'url': m.group('url'),
69+
'bandwidth': int(m.group('bandwidth'))
70+
})
8371

8472
log.debug('m3u8_to_list result:\n{}'.format(l))
8573
return l

0 commit comments

Comments
 (0)