11# -*- encoding: utf-8 -*-
2- # https://github.com/justintv/Twitch-API/blob/master/v3_resources/ channels.md
2+ # https://dev.twitch.tv/docs/v5/reference/ channels/
33
44from twitch import keys
55from twitch .queries import V5Query as Qry
66from twitch .queries import query
7-
8- from .videos import by_channel
7+ from twitch .api .parameters import Boolean , BroadcastType , Direction
98
109
1110@query
12- def by_name ( name ):
13- q = Qry ('channels/{channel }' )
14- q .add_urlkw (keys .CHANNEL , name )
11+ def by_id ( channel_id ):
12+ q = Qry ('channels/{id }' )
13+ q .add_urlkw (keys .ID , channel_id )
1514 return q
1615
1716
@@ -20,16 +19,12 @@ def channel():
2019 raise NotImplementedError
2120
2221
23- def get_videos (name , ** kwargs ):
24- return by_channel (name , ** kwargs )
25-
26-
2722@query
2823def editors (name ):
2924 raise NotImplementedError
3025
3126
32- # TODO needs authentification and put requests
27+ # TODO needs Authentication and put requests
3328@query
3429def update (name , status = None , game = None , delay = 0 ):
3530 raise NotImplementedError
@@ -48,7 +43,41 @@ def commercial(name, length=30):
4843
4944
5045@query
51- def teams (name ):
52- q = Qry ('channels/{channel}/teams' )
53- q .add_urlkw ('channel' , name )
46+ def teams (channel_id ):
47+ q = Qry ('channels/{id}/teams' )
48+ q .add_urlkw (keys .ID , channel_id )
49+ return q
50+
51+
52+ @query
53+ def followers (channel_id , limit = 25 , offset = 0 , direction = Direction .DESC ):
54+ q = Qry ('channels/{id}/follows' )
55+ q .add_urlkw (keys .ID , channel_id )
56+ q .add_param (keys .LIMIT , limit , 25 )
57+ q .add_param (keys .OFFSET , offset , 0 )
58+ q .add_param (keys .DIRECTION , direction , Direction .DESC )
59+ return q
60+
61+
62+ # Needs Authentication
63+ @query
64+ def subscribers (channel_id , limit = 25 , offset = 0 , direction = Direction .ASC ):
65+ raise NotImplementedError
66+
67+
68+ # Needs Authentication
69+ @query
70+ def subscription_status (channel_id , user_id ):
71+ raise NotImplementedError
72+
73+
74+ @query
75+ def videos (channel_id , limit = 10 , offset = 0 ,
76+ broadcast_type = BroadcastType .ARCHIVE , hls = Boolean .FALSE ):
77+ q = Qry ('channels/{id}/videos' )
78+ q .add_urlkw (keys .ID , channel_id )
79+ q .add_param (keys .LIMIT , limit , 10 )
80+ q .add_param (keys .OFFSET , offset , 0 )
81+ q .add_param (keys .BROADCAST_TYPE , BroadcastType .validate (broadcast_type ), BroadcastType .ARCHIVE )
82+ q .add_param (keys .HLS , Boolean .validate (hls ), Boolean .FALSE )
5483 return q
0 commit comments