|
| 1 | +# -*- encoding: utf-8 -*- |
| 2 | +""" |
| 3 | + Reference: https://dev.twitch.tv/docs/api/reference |
| 4 | +
|
| 5 | + Copyright (C) 2022- script.module.python.twitch |
| 6 | +
|
| 7 | + This file is part of script.module.python.twitch |
| 8 | +
|
| 9 | + SPDX-License-Identifier: GPL-3.0-only |
| 10 | + See LICENSES/GPL-3.0-only for more information. |
| 11 | +""" |
| 12 | + |
| 13 | +from ... import keys |
| 14 | +from ...api.parameters import Boolean, Cursor, IntRange |
| 15 | +from ...queries import HelixQuery as Qry |
| 16 | +from ...queries import query |
| 17 | + |
| 18 | + |
| 19 | +# required scope: none |
| 20 | +@query |
| 21 | +def get_categories(search_query, after='MA==', first=20, use_app_token=False): |
| 22 | + q = Qry('search/categories', use_app_token=use_app_token) |
| 23 | + q.add_param(keys.QUERY, search_query) |
| 24 | + q.add_param(keys.AFTER, Cursor.validate(after), 'MA==') |
| 25 | + q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20) |
| 26 | + |
| 27 | + return q |
| 28 | + |
| 29 | + |
| 30 | +# required scope: none |
| 31 | +@query |
| 32 | +def get_channels(search_query, after='MA==', first=20, live_only=True, use_app_token=False): |
| 33 | + q = Qry('search/channels', use_app_token=use_app_token) |
| 34 | + q.add_param(keys.QUERY, search_query) |
| 35 | + q.add_param(keys.AFTER, Cursor.validate(after), 'MA==') |
| 36 | + q.add_param(keys.FIRST, IntRange(1, 100).validate(first), 20) |
| 37 | + q.add_param(keys.LIVE_ONLY, Boolean.validate(live_only), True) |
| 38 | + |
| 39 | + return q |
0 commit comments