Skip to content

Commit 9a2e2b2

Browse files
authored
Merge pull request #8 from anxdpanic/dev
remove v2, v3, refactor and updates v5
2 parents dcfd921 + 76ecc4d commit 9a2e2b2

37 files changed

Lines changed: 228 additions & 628 deletions

addon.xml

Lines changed: 1 addition & 14 deletions
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~alpha3" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~alpha4" 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"/>
@@ -10,19 +10,6 @@
1010
<platform>all</platform>
1111
<news>
1212
- initial release
13-
- use script.module.requests
14-
- remove default client_id
15-
- add oauth token support
16-
- add authorization, client id headers to all api calls
17-
- update api.twitch to use https
18-
- update usher to allow_source
19-
- videos.by_channel from broadcasts bool to broadcast_type: 'archive', 'highlight', 'upload'
20-
- update m3u_pattern
21-
- add initial v5 (wip)
22-
- add support for additional methods in queries (PUT/DELETE/POST)
23-
- v5 add communities, update follow/unfollow/blocks
24-
- add basics for implicit oauth2
25-
- update usher base url
2613
</news>
2714
<assets>
2815
<icon>icon.png</icon>

changelog.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
11
1.0.0
22
- initial release
3-
- use script.module.requests
4-
- remove default client_id
5-
- add oauth token support
6-
- add authorization, client id headers to all api calls
7-
- update api.twitch to use https
8-
- update usher to allow_source
9-
- videos.by_channel from broadcasts bool to broadcast_type: 'archive', 'highlight', 'upload'
10-
- update m3u_pattern
11-
- add initial v5 (wip)
12-
- add support for additional methods in queries (PUT/DELETE/POST)
13-
- v5 add communities, update follow/unfollow/blocks
14-
- add basics for implicit oauth2
15-
- update usher base url

resources/lib/twitch/api/parameters.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ class SortBy(_Parameter):
3838
LOGIN = 'login'
3939

4040
_valid = [CREATED_AT, LAST_BROADCAST, LOGIN]
41+
42+
43+
class BroadcastType(_Parameter):
44+
ARCHIVE = 'archive'
45+
HIGHLIGHT = 'highlight'
46+
UPLOAD = 'upload'
47+
48+
_valid = [ARCHIVE, HIGHLIGHT, UPLOAD]
49+
50+
51+
class StreamType(_Parameter):
52+
LIVE = 'live'
53+
PLAYLIST = 'playlist'
54+
ALL = 'all'
55+
56+
_valid = [LIVE, PLAYLIST, ALL]

resources/lib/twitch/api/usher.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@
1414
def channel_token(channel):
1515
q = HiddenApiQuery('channels/{channel}/access_token')
1616
q.add_urlkw(keys.CHANNEL, channel)
17+
q.add_param(keys.NEED_HTTPS, Boolean.TRUE)
1718
return q
1819

1920

2021
@query
21-
def vod_token(id):
22+
def vod_token(video_id):
2223
q = HiddenApiQuery('vods/{vod}/access_token')
23-
q.add_urlkw(keys.VOD, id)
24+
q.add_urlkw(keys.VOD, video_id)
25+
q.add_param(keys.NEED_HTTPS, Boolean.TRUE)
2426
return q
2527

2628

2729
@query
28-
def _legacy_video(id):
30+
def _legacy_video(video_id):
2931
q = HiddenApiQuery('videos/{id}')
30-
q.add_urlkw(keys.ID, id)
32+
q.add_urlkw(keys.ID, video_id)
3133
return q
3234

3335

@@ -41,28 +43,32 @@ def live(channel):
4143
q.add_param(keys.SIG, token[keys.SIG])
4244
q.add_param(keys.TOKEN, token[keys.TOKEN])
4345
q.add_param(keys.ALLOW_SOURCE, Boolean.TRUE)
46+
q.add_param(keys.ALLOW_SPECTRE, Boolean.TRUE)
4447
return q
4548

4649

4750
@m3u8
4851
@query
49-
def _vod(id):
50-
id = id[1:]
52+
def _vod(video_id):
53+
video_id = video_id[1:]
5154

52-
token = vod_token(id)
55+
token = vod_token(video_id)
5356

5457
q = UsherQuery('vod/{id}')
55-
q.add_urlkw(keys.ID, id)
58+
q.add_urlkw(keys.ID, video_id)
5659
q.add_param(keys.NAUTHSIG, token[keys.SIG])
5760
q.add_param(keys.NAUTH, token[keys.TOKEN])
5861
q.add_param(keys.ALLOW_SOURCE, Boolean.TRUE)
5962
return q
6063

6164

62-
def video(id):
63-
if id.startswith('v'):
64-
return _vod(id)
65-
elif id.startswith(('a', 'c')):
66-
return _legacy_video(id)
65+
def video(video_id):
66+
if video_id.startswith('videos'):
67+
video_id = 'v' + video_id[6:]
68+
return _vod(video_id)
69+
elif video_id.startswith('v'):
70+
return _vod(video_id)
71+
elif video_id.startswith(('a', 'c')):
72+
return _legacy_video(video_id)
6773
else:
6874
raise NotImplementedError('Unknown Video Type')

resources/lib/twitch/api/v2/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

resources/lib/twitch/api/v3/__init__.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

resources/lib/twitch/api/v3/blocks.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

resources/lib/twitch/api/v3/channels.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

resources/lib/twitch/api/v3/follows.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

resources/lib/twitch/api/v3/games.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)