From 7d31d9f9963494ac80f28ec45525f2cd276f6b63 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Sun, 16 May 2021 12:06:28 +0300 Subject: [PATCH] Fix oauth typo --- .gitignore | 2 +- main.py | 14 +++++++------- twitch.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 31f6707..1f87ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ __pycache__ *.swp .token -.oath +.oauth .secret server.conf .*.log diff --git a/main.py b/main.py index a453869..36138e2 100755 --- a/main.py +++ b/main.py @@ -13,8 +13,8 @@ class FleastServer(object): try: with open('.token', 'r') as reader: self.twitch_token = reader.read().strip() - with open('.oath', 'r') as reader: - self.oath_token = reader.read().strip() + with open('.oauth', 'r') as reader: + self.oauth_token = reader.read().strip() with open('./web/fl.html', 'r') as reader: self.index_page = reader.read() with open('./web/fl_template_main.html', 'r') as reader: @@ -23,7 +23,7 @@ class FleastServer(object): self.templ_stream = reader.read() with open('./web/fl_template_lang.html', 'r') as reader: self.templ_lang = reader.read().splitlines() - self.client = TwitchClient(self.twitch_token, self.oath_token, freq=1) + self.client = TwitchClient(self.twitch_token, self.oauth_token, freq=1) except: print("Cannot read token for twitch app or templates, abort.") exit(1) @@ -88,10 +88,10 @@ class FleastServer(object): irl_url = 'https://twitch.tv/{}' for s in data['streams']: result_str += self.templ_stream.format(irl_url.format(s['user_name']), - s['thumbnail_url'].format(width=320, height=180), - self.to_html(s['title']), - s['user_name'], - s['viewer_count']) + '\n' + s['thumbnail_url'].format(width=320, height=180), + self.to_html(s['title']), + s['user_name'], + s['viewer_count']) + '\n' return self.templ_main.format(_stream_num_=len(data['streams']), _game_name_=game, diff --git a/twitch.py b/twitch.py index a473ce6..93b588e 100644 --- a/twitch.py +++ b/twitch.py @@ -6,15 +6,15 @@ from urllib.parse import quote class TwitchClient: - def __init__(self, token, oath, freq=2): + def __init__(self, token, oauth, freq=2): self.token = token - self.oath = oath + self.oauth = oauth self.lock = threading.Lock() self.header_v5 = {'Client-ID': self.token, - 'Authorization': 'Bearer ' + self.oath, + 'Authorization': 'Bearer ' + self.oauth, 'Accept': 'application/vnd.twitchtv.v5+json'} - self.header_v6 = {'Client-ID': self.token, 'Authorization': 'Bearer ' + self.oath} + self.header_v6 = {'Client-ID': self.token, 'Authorization': 'Bearer ' + self.oauth} self.urlbase_v5 = 'https://api.twitch.tv/kraken' self.urlbase_v6 = 'https://api.twitch.tv/helix'