Skip to content

Commit 81e85da

Browse files
authored
Merge pull request #114 from anxdpanic/pr_isengard
add helix search endpoints
2 parents 96ddf33 + a5417b4 commit 81e85da

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

resources/lib/twitch/keys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
LANGUAGE = 'language'
7171
LIMIT = 'limit'
7272
LIVE = 'live'
73+
LIVE_ONLY = 'live_only'
7374
LOGIN = 'login'
7475
MANIFEST_ID = 'manifest_id'
7576
MEDIAPLAYER = 'mediaplayer'

0 commit comments

Comments
 (0)