-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from offish/v1.3.2
v1.3.2
- Loading branch information
Showing
5 changed files
with
55 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
__title__ = 'twitchtube' | ||
__author__ = 'offish' | ||
__license__ = 'MIT' | ||
__version__ = '1.3.1' | ||
__version__ = '1.3.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import json | ||
|
||
from .config import OAUTH_TOKEN, CLIENT_ID | ||
|
||
import requests | ||
|
||
|
||
local = locals() | ||
|
||
|
||
def request(endpoint: str, headers: dict, params: dict) -> dict: | ||
return requests.get( | ||
'https://api.twitch.tv/' + endpoint, | ||
headers = headers, | ||
params = params | ||
) | ||
|
||
|
||
def data(slug: str) -> dict: | ||
return request( | ||
'helix/clips', | ||
{ | ||
'Authorization': f'Bearer {OAUTH_TOKEN}', | ||
'Client-Id': CLIENT_ID | ||
}, | ||
{'id': slug} | ||
) | ||
|
||
|
||
def top_clips(headers: dict, params: dict) -> dict: | ||
return request( | ||
'kraken/clips/top', | ||
headers, | ||
params | ||
) | ||
|
||
|
||
def get(name: str, **args) -> dict: | ||
response = local[name](**args) | ||
|
||
try: | ||
return response.json() | ||
except SyntaxError: | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters