Fix oauth typo

This commit is contained in:
Alex Vanin 2021-05-16 12:06:28 +03:00
parent b37827b91d
commit 7d31d9f996
3 changed files with 12 additions and 12 deletions

2
.gitignore vendored
View file

@ -1,7 +1,7 @@
__pycache__ __pycache__
*.swp *.swp
.token .token
.oath .oauth
.secret .secret
server.conf server.conf
.*.log .*.log

14
main.py
View file

@ -13,8 +13,8 @@ class FleastServer(object):
try: try:
with open('.token', 'r') as reader: with open('.token', 'r') as reader:
self.twitch_token = reader.read().strip() self.twitch_token = reader.read().strip()
with open('.oath', 'r') as reader: with open('.oauth', 'r') as reader:
self.oath_token = reader.read().strip() self.oauth_token = reader.read().strip()
with open('./web/fl.html', 'r') as reader: with open('./web/fl.html', 'r') as reader:
self.index_page = reader.read() self.index_page = reader.read()
with open('./web/fl_template_main.html', 'r') as reader: with open('./web/fl_template_main.html', 'r') as reader:
@ -23,7 +23,7 @@ class FleastServer(object):
self.templ_stream = reader.read() self.templ_stream = reader.read()
with open('./web/fl_template_lang.html', 'r') as reader: with open('./web/fl_template_lang.html', 'r') as reader:
self.templ_lang = reader.read().splitlines() 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: except:
print("Cannot read token for twitch app or templates, abort.") print("Cannot read token for twitch app or templates, abort.")
exit(1) exit(1)
@ -88,10 +88,10 @@ class FleastServer(object):
irl_url = 'https://twitch.tv/{}' irl_url = 'https://twitch.tv/{}'
for s in data['streams']: for s in data['streams']:
result_str += self.templ_stream.format(irl_url.format(s['user_name']), result_str += self.templ_stream.format(irl_url.format(s['user_name']),
s['thumbnail_url'].format(width=320, height=180), s['thumbnail_url'].format(width=320, height=180),
self.to_html(s['title']), self.to_html(s['title']),
s['user_name'], s['user_name'],
s['viewer_count']) + '\n' s['viewer_count']) + '\n'
return self.templ_main.format(_stream_num_=len(data['streams']), return self.templ_main.format(_stream_num_=len(data['streams']),
_game_name_=game, _game_name_=game,

View file

@ -6,15 +6,15 @@ from urllib.parse import quote
class TwitchClient: class TwitchClient:
def __init__(self, token, oath, freq=2): def __init__(self, token, oauth, freq=2):
self.token = token self.token = token
self.oath = oath self.oauth = oauth
self.lock = threading.Lock() self.lock = threading.Lock()
self.header_v5 = {'Client-ID': self.token, self.header_v5 = {'Client-ID': self.token,
'Authorization': 'Bearer ' + self.oath, 'Authorization': 'Bearer ' + self.oauth,
'Accept': 'application/vnd.twitchtv.v5+json'} '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_v5 = 'https://api.twitch.tv/kraken'
self.urlbase_v6 = 'https://api.twitch.tv/helix' self.urlbase_v6 = 'https://api.twitch.tv/helix'