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
5 changes: 2 additions & 3 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="2.0.16" provider-name="anxdpanic, A Talented Community">
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="2.0.17" provider-name="anxdpanic, A Talented Community">
<requires>
<import addon="xbmc.python" version="2.20.0"/>
<import addon="script.module.six" version="1.11.0"/>
Expand All @@ -9,8 +9,7 @@
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<news>
[fix] playback, change access token to use gql endpoints
[chg] change followed, following, and unfollowing games to use gql endpoints
[fix] playback of clips
</news>
<assets>
<icon>icon.png</icon>
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.0.17
[fix] playback of clips

2.0.16
[fix] playback, change access token to use gql endpoints
[chg] change followed, following, and unfollowing games to use gql endpoints
Expand Down
39 changes: 13 additions & 26 deletions resources/lib/twitch/api/usher.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,31 +216,18 @@ def video(video_id, platform=keys.WEB, headers={}):
@clip_embed
@query
def clip(slug, headers={}):
data = json.dumps({
'query': '''{
clip(slug: "%s") {
broadcaster {
displayName
}
createdAt
curator {
displayName
id
}
durationSeconds
id
tiny: thumbnailURL(width: 86, height: 45)
small: thumbnailURL(width: 260, height: 147)
medium: thumbnailURL(width: 480, height: 272)
title
videoQualities {
frameRate
quality
sourceURL
qry = {
"operationName": "VideoAccessToken_Clip",
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "36b89d2507fce29e5ca551df756d27c1cfe079e2609642b4390aa4c35796eb11"
}
},
"variables": {
"slug": slug
}
viewCount
}
}''' % slug,
})
q = ClipsQuery(headers=headers, data=data)
}

q = ClipsQuery(headers=headers, data=json.dumps(qry))
return q
23 changes: 20 additions & 3 deletions resources/lib/twitch/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import re

from six.moves.urllib_parse import urlencode

from . import keys
from .log import log

Expand Down Expand Up @@ -58,7 +60,11 @@ def m3u8_wrapper(*args, **kwargs):
else:
error = re.search(_error_pattern, results)
if error:
return {'error': 'Error', 'message': error.group('message'), 'status': 404}
return {
'error': 'Error',
'message': error.group('message'),
'status': 404
}
return m3u8_to_list(results)

return m3u8_wrapper
Expand Down Expand Up @@ -132,7 +138,18 @@ def m3u8_to_list(string):

def clip_embed_to_list(response):
log.debug('clip_embed_to_list called for:\n{0}'.format(response))
qualities = list()

clip_json = response.get('data', {}).get('clip', {})
access_token = clip_json.get('playbackAccessToken', {})
token = access_token.get('value', '')
signature = access_token.get('signature', '')
qualities = clip_json.get('videoQualities', [])

params = urlencode({
'sig': signature,
'token': token
})

l = list()

if isinstance(response, dict):
Expand All @@ -143,7 +160,7 @@ def clip_embed_to_list(response):
l = [{
'id': item['quality'],
'name': item['quality'],
'url': item['sourceURL'],
'url': item['sourceURL'] + '?' + params,
'bandwidth': -1
} for item in qualities]
if l:
Expand Down