Initial commit with framework class for twitch-requests
This commit is contained in:
parent
6c6585226e
commit
529e5980e4
3 changed files with 29 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
src/__pycache__
|
||||||
|
*.swp
|
||||||
|
src/.token
|
14
src/main.py
Executable file
14
src/main.py
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from twitch import TwitchClient
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with open('.token', 'r') as reader:
|
||||||
|
twitch_token = reader.read().strip()
|
||||||
|
|
||||||
|
client = TwitchClient(twitch_token)
|
||||||
|
print(client.raw_query('streams?first=20'))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
12
src/twitch.py
Normal file
12
src/twitch.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
class TwitchClient:
|
||||||
|
|
||||||
|
def __init__(self, token):
|
||||||
|
self.token = token
|
||||||
|
self.header = {'Client-ID': self.token}
|
||||||
|
self.urlbase = 'https://api.twitch.tv/helix/'
|
||||||
|
|
||||||
|
def raw_query(self, q):
|
||||||
|
r = requests.get(self.urlbase+q, headers=self.header)
|
||||||
|
return r.text
|
Loading…
Reference in a new issue