Skip to content

Commit efc8c20

Browse files
committed
fix clips usher
1 parent 3ca0d7c commit efc8c20

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

addon.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<news>
12+
[fix] clips usher
1213
[chg] to relative imports
1314
[upd] deprecation/removal dates
1415
</news>

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
2.0.1
2+
[fix] clips usher
23
[chg] to relative imports
34
[upd] deprecation/removal dates
45

resources/lib/twitch/api/usher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ def video(video_id):
129129
@clip_embed
130130
@query
131131
def clip(slug):
132-
q = ClipsQuery('embed')
133-
q.add_param(keys.CLIP, slug)
132+
q = ClipsQuery('api/v2/clips/{clip}/status')
133+
q.add_urlkw(keys.CLIP, slug)
134134
return q

resources/lib/twitch/parser.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- encoding: utf-8 -*-
22
import re
3+
from ast import literal_eval
34
from . import keys
45
from .log import log
56

@@ -11,8 +12,6 @@
1112
r'BANDWIDTH=(?P<bandwidth>[0-9]+).*\n('
1213
r'?P<url>http.*)')
1314

14-
_clip_embed_pattern = re.compile(r'quality_options:\s*(?P<qualities>\[[^\]]+?\])')
15-
1615
_error_pattern = re.compile(r'.*<tr><td><b>error</b></td><td>(?P<message>.+?)</td></tr>.*', re.IGNORECASE)
1716

1817

@@ -73,18 +72,23 @@ def m3u8_to_list(string):
7372
return l
7473

7574

76-
def clip_embed_to_list(string):
77-
log.debug('clip_embed_to_list called for:\n{0}'.format(string))
78-
match = re.search(_clip_embed_pattern, string)
75+
def clip_embed_to_list(response):
76+
log.debug('clip_embed_to_list called for:\n{0}'.format(response))
77+
78+
response = literal_eval(response)
79+
qualities = list()
7980
l = list()
80-
if match:
81-
match = eval(match.group('qualities'))
81+
82+
if isinstance(response, dict):
83+
qualities = response.get('quality_options', list())
84+
85+
if qualities:
8286
l = [{
8387
'id': item['quality'],
8488
'name': item['quality'],
8589
'url': item['source'],
8690
'bandwidth': -1
87-
} for item in match]
91+
} for item in qualities]
8892
if l:
8993
l.insert(0, {
9094
'id': 'Source',

0 commit comments

Comments
 (0)