|
| 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 |
0 commit comments