Skip to content

Commit 0239dc6

Browse files
authored
Merge pull request #89 from anxdpanic/pr_isengard
2.0.17
2 parents 3e7fae8 + 144f526 commit 0239dc6

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

Diff for: addon.xml

+2-3
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="2.0.16" provider-name="anxdpanic, A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.17" provider-name="anxdpanic, A Talented Community">
33
<requires>
44
<import addon="xbmc.python" version="2.20.0"/>
55
<import addon="script.module.six" version="1.11.0"/>
@@ -9,8 +9,7 @@
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
1111
<news>
12-
[fix] playback, change access token to use gql endpoints
13-
[chg] change followed, following, and unfollowing games to use gql endpoints
12+
[fix] playback of clips
1413
</news>
1514
<assets>
1615
<icon>icon.png</icon>

Diff for: changelog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.0.17
2+
[fix] playback of clips
3+
14
2.0.16
25
[fix] playback, change access token to use gql endpoints
36
[chg] change followed, following, and unfollowing games to use gql endpoints

Diff for: resources/lib/twitch/api/usher.py

+13-26
Original file line numberDiff line numberDiff line change
@@ -216,31 +216,18 @@ def video(video_id, platform=keys.WEB, headers={}):
216216
@clip_embed
217217
@query
218218
def clip(slug, headers={}):
219-
data = json.dumps({
220-
'query': '''{
221-
clip(slug: "%s") {
222-
broadcaster {
223-
displayName
224-
}
225-
createdAt
226-
curator {
227-
displayName
228-
id
229-
}
230-
durationSeconds
231-
id
232-
tiny: thumbnailURL(width: 86, height: 45)
233-
small: thumbnailURL(width: 260, height: 147)
234-
medium: thumbnailURL(width: 480, height: 272)
235-
title
236-
videoQualities {
237-
frameRate
238-
quality
239-
sourceURL
219+
qry = {
220+
"operationName": "VideoAccessToken_Clip",
221+
"extensions": {
222+
"persistedQuery": {
223+
"version": 1,
224+
"sha256Hash": "36b89d2507fce29e5ca551df756d27c1cfe079e2609642b4390aa4c35796eb11"
225+
}
226+
},
227+
"variables": {
228+
"slug": slug
240229
}
241-
viewCount
242-
}
243-
}''' % slug,
244-
})
245-
q = ClipsQuery(headers=headers, data=data)
230+
}
231+
232+
q = ClipsQuery(headers=headers, data=json.dumps(qry))
246233
return q

Diff for: resources/lib/twitch/parser.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
import re
1414

15+
from six.moves.urllib_parse import urlencode
16+
1517
from . import keys
1618
from .log import log
1719

@@ -58,7 +60,11 @@ def m3u8_wrapper(*args, **kwargs):
5860
else:
5961
error = re.search(_error_pattern, results)
6062
if error:
61-
return {'error': 'Error', 'message': error.group('message'), 'status': 404}
63+
return {
64+
'error': 'Error',
65+
'message': error.group('message'),
66+
'status': 404
67+
}
6268
return m3u8_to_list(results)
6369

6470
return m3u8_wrapper
@@ -132,7 +138,18 @@ def m3u8_to_list(string):
132138

133139
def clip_embed_to_list(response):
134140
log.debug('clip_embed_to_list called for:\n{0}'.format(response))
135-
qualities = list()
141+
142+
clip_json = response.get('data', {}).get('clip', {})
143+
access_token = clip_json.get('playbackAccessToken', {})
144+
token = access_token.get('value', '')
145+
signature = access_token.get('signature', '')
146+
qualities = clip_json.get('videoQualities', [])
147+
148+
params = urlencode({
149+
'sig': signature,
150+
'token': token
151+
})
152+
136153
l = list()
137154

138155
if isinstance(response, dict):
@@ -143,7 +160,7 @@ def clip_embed_to_list(response):
143160
l = [{
144161
'id': item['quality'],
145162
'name': item['quality'],
146-
'url': item['sourceURL'],
163+
'url': item['sourceURL'] + '?' + params,
147164
'bandwidth': -1
148165
} for item in qualities]
149166
if l:

0 commit comments

Comments
 (0)