33 lines
845 B
Python
33 lines
845 B
Python
from flask import Flask, render_template, request
|
|
from twitch import TwitchClient
|
|
from pprint import pprint
|
|
import json
|
|
|
|
application = Flask(__name__)
|
|
application.config['DEBUG'] = True
|
|
|
|
|
|
try:
|
|
cred_file = open('.tcreds')
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
details = json.load(cred_file)
|
|
|
|
#Setup Authed Twitch Client
|
|
tclient = TwitchClient(client_id=details["client_id"], oauth_token=details["oauth"])
|
|
|
|
def get_followed():
|
|
return tclient.streams.get_followed()
|
|
#Debug
|
|
#for stream in streams_live:
|
|
# print("%s: \t\t\t%s Logo is: %s" %(stream["channel"]["display_name"], stream["channel"]["game"],stream["channel"]["logo"]))
|
|
|
|
@application.route('/')
|
|
def index():
|
|
livestreamdata = get_followed()
|
|
return render_template('index.html', livestreamdata=livestreamdata)
|
|
|
|
if __name__ == '__main__':
|
|
application.run(host='0.0.0.0')
|