Skip to content

Commit 1300f4e

Browse files
committed
initial v5 and oauth mobile client
1 parent 8cf9040 commit 1300f4e

21 files changed

Lines changed: 460 additions & 1 deletion

addon.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<import addon="xbmc.python" version="2.1.0"/>
55
<import addon="script.module.six" version="1.9.0"/>
66
<import addon="script.module.requests" version="2.9.1"/>
7+
<import addon="script.module.oauthlib"/>
78
</requires>
89
<extension point="xbmc.python.module" library="resources/lib"/>
910
<extension point="xbmc.addon.metadata">

resources/__init__.py

Whitespace-only changes.

resources/lib/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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.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?name={communities}')
19+
q.add_urlkw(keys.COMMUNITIES, 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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
9+
10+
@query
11+
def by_channel(name, limit=25, offset=0, direction=Direction.DESC):
12+
q = Qry('channels/{channel}/follows')
13+
q.add_urlkw(keys.CHANNEL, name)
14+
q.add_param(keys.LIMIT, limit, 25)
15+
q.add_param(keys.OFFSET, offset, 0)
16+
q.add_param(keys.DIRECTION, direction, Direction.DESC)
17+
return q
18+
19+
20+
@query
21+
def by_id(identification, limit=25, offset=0, direction=Direction.DESC,
22+
sort_by=SortBy.CREATED_AT):
23+
q = Qry('users/{id}/follows/channels')
24+
q.add_urlkw(keys.ID, identification)
25+
q.add_param(keys.LIMIT, limit, 25)
26+
q.add_param(keys.OFFSET, offset, 0)
27+
q.add_param(keys.DIRECTION, direction, Direction.DESC)
28+
q.add_param(keys.SORT_BY, sort_by, SortBy.CREATED_AT)
29+
return q
30+
31+
32+
@query
33+
def status(user, target):
34+
q = Qry('users/{user}/follows/channels/{target}')
35+
q.add_urlkw(keys.USER, user)
36+
q.add_urlkw(keys.TARGET, target)
37+
return q
38+
39+
40+
# Needs Auth, needs PUT
41+
@query
42+
def follow(user, target):
43+
raise NotImplementedError
44+
45+
46+
# Needs Auth, needs DELETE
47+
@query
48+
def unfollow(user, target):
49+
raise NotImplementedError
50+
51+
52+
# Needs Auth
53+
@query
54+
def streams():
55+
raise NotImplementedError
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md
3+
4+
from twitch import keys
5+
from twitch.queries import V5Query as Qry
6+
from twitch.queries import query
7+
8+
9+
@query
10+
def top(limit=10, offset=0):
11+
q = Qry('games/top')
12+
q.add_param(keys.LIMIT, limit, 10)
13+
q.add_param(keys.OFFSET, offset, 0)
14+
return q
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# -*- encoding: utf-8 -*-
2+
# https://github.com/justintv/Twitch-API/blob/master/v3_resources/ingests.md
3+
4+
from twitch.queries import V5Query as Qry
5+
from twitch.queries import query
6+
7+
8+
@query
9+
def get():
10+
q = Qry('ingests')
11+
return q

0 commit comments

Comments
 (0)