Skip to content

Commit 03a734d

Browse files
authored
Merge pull request #4 from anxdpanic/dev-v5
update v5, implicit auth basics, follow/unfollow, communities, m3u_pattern
2 parents 8cf9040 + acf835e commit 03a734d

25 files changed

Lines changed: 556 additions & 34 deletions

addon.xml

Lines changed: 6 additions & 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~alpha1" provider-name="A Talented Community">
2+
<addon id="script.module.python.twitch" name="python-twitch for Kodi" version="1.0.0~alpha2" 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"/>
@@ -18,6 +18,11 @@
1818
- update usher to allow_source
1919
- videos.by_channel from broadcasts bool to broadcast_type: 'archive', 'highlight', 'upload'
2020
- 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
24+
- add basics for implicit oauth2
25+
- update usher base url
2126
</news>
2227
<assets>
2328
<icon>icon.png</icon>

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
- update usher to allow_source
99
- videos.by_channel from broadcasts bool to broadcast_type: 'archive', 'highlight', 'upload'
1010
- 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
14+
- add basics for implicit oauth2
15+
- update usher base url

resources/__init__.py

Whitespace-only changes.

resources/lib/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- encoding: utf-8 -*-
22

3-
from twitch.api import v3
4-
from twitch.api import v3 as default
3+
from twitch.api import v5
4+
from twitch.api import v5 as default
55

6-
__all__ = ['v3', 'default']
6+
__all__ = ['v5', 'default']
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/
3+
4+
from twitch.api.v5 import blocks # NOQA
5+
from twitch.api.v5 import channels # NOQA
6+
from twitch.api.v5 import follows # NOQA
7+
from twitch.api.v5 import games # NOQA
8+
from twitch.api.v5 import ingests # NOQA
9+
from twitch.api.v5 import search # NOQA
10+
from twitch.api.v5 import streams # NOQA
11+
from twitch.api.v5 import subscriptions # NOQA
12+
from twitch.api.v5 import teams # NOQA
13+
from twitch.api.v5 import users # NOQA
14+
from twitch.api.v5 import videos # NOQA
15+
from twitch.api.v5 import communities # NOQA
16+
from twitch.api.v5.root import root # NOQA
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/blocks.md
3+
4+
from twitch.queries import query
5+
6+
7+
# Needs Authentification
8+
@query
9+
def by_name(user):
10+
raise NotImplementedError
11+
12+
13+
# Needs Authentification, needs PUT
14+
@query
15+
def add_block(user, target):
16+
raise NotImplementedError
17+
18+
19+
# Needs Authentification, needs DELETE
20+
@query
21+
def del_block(user, target):
22+
raise NotImplementedError
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/channels.md
3+
4+
from twitch import keys
5+
from twitch.queries import V5Query as Qry
6+
from twitch.queries import query
7+
8+
from .videos import by_channel
9+
10+
11+
@query
12+
def by_name(name):
13+
q = Qry('channels/{channel}')
14+
q.add_urlkw(keys.CHANNEL, name)
15+
return q
16+
17+
18+
@query
19+
def channel():
20+
raise NotImplementedError
21+
22+
23+
def get_videos(name, **kwargs):
24+
return by_channel(name, **kwargs)
25+
26+
27+
@query
28+
def editors(name):
29+
raise NotImplementedError
30+
31+
32+
# TODO needs authentification and put requests
33+
@query
34+
def update(name, status=None, game=None, delay=0):
35+
raise NotImplementedError
36+
37+
38+
# TODO needs auth
39+
@query
40+
def delete(name):
41+
raise NotImplementedError
42+
43+
44+
# TODO needs auth, needs POST request
45+
@query
46+
def commercial(name, length=30):
47+
raise NotImplementedError
48+
49+
50+
@query
51+
def teams(name):
52+
q = Qry('channels/{channel}/teams')
53+
q.add_urlkw('channel', name)
54+
return q
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
from twitch import keys
4+
from twitch.queries import V5Query as Qry
5+
from twitch.queries import query
6+
7+
8+
@query
9+
def top(limit=10, cursor=0):
10+
q = Qry('communities/top')
11+
q.add_param(keys.LIMIT, limit, 10)
12+
q.add_param(keys.CURSOR, cursor, 0)
13+
return q
14+
15+
16+
@query
17+
def by_name(name):
18+
q = Qry('communities')
19+
q.add_param(keys.NAME, name)
20+
return q
21+
22+
23+
@query
24+
def by_id(identification):
25+
q = Qry('communities/{id}')
26+
q.add_urlkw(keys.ID, identification)
27+
return q
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md
3+
4+
from twitch import keys
5+
from twitch.api.parameters import Direction, SortBy
6+
from twitch.queries import V5Query as Qry
7+
from twitch.queries import query
8+
from twitch.api.parameters import Boolean
9+
10+
11+
@query
12+
def by_channel(name, limit=25, offset=0, direction=Direction.DESC):
13+
q = Qry('channels/{channel}/follows')
14+
q.add_urlkw(keys.CHANNEL, name)
15+
q.add_param(keys.LIMIT, limit, 25)
16+
q.add_param(keys.OFFSET, offset, 0)
17+
q.add_param(keys.DIRECTION, direction, Direction.DESC)
18+
return q
19+
20+
21+
@query
22+
def by_id(identification, limit=25, offset=0, direction=Direction.DESC,
23+
sort_by=SortBy.CREATED_AT):
24+
q = Qry('users/{id}/follows/channels')
25+
q.add_urlkw(keys.ID, identification)
26+
q.add_param(keys.LIMIT, limit, 25)
27+
q.add_param(keys.OFFSET, offset, 0)
28+
q.add_param(keys.DIRECTION, direction, Direction.DESC)
29+
q.add_param(keys.SORT_BY, sort_by, SortBy.CREATED_AT)
30+
return q
31+
32+
33+
@query
34+
def status(identification, target):
35+
q = Qry('users/{id}/follows/channels/{target}')
36+
q.add_urlkw(keys.ID, identification)
37+
q.add_urlkw(keys.TARGET, target)
38+
return q
39+
40+
41+
# Needs Auth, needs PUT
42+
@query
43+
def follow(identification, target, notification=Boolean.FALSE):
44+
q = Qry('users/{id}/follows/channels/{target}', method='PUT')
45+
q.add_urlkw(keys.ID, identification)
46+
q.add_urlkw(keys.TARGET, target)
47+
q.add_data('notification', notification)
48+
return q
49+
50+
51+
# Needs Auth, needs DELETE
52+
@query
53+
def unfollow(identification, target):
54+
q = Qry('users/{id}/follows/channels/{target}', method='DELETE')
55+
q.add_urlkw(keys.ID, identification)
56+
q.add_urlkw(keys.TARGET, target)
57+
return q
58+
59+
# Needs Auth
60+
@query
61+
def streams():
62+
raise NotImplementedError

0 commit comments

Comments
 (0)