def ttv(): """Processes and executes command paramters""" # Set up logging logging.basicConfig(filename='log.log', level=logging.INFO) # Load request keys keys = json.load(open('./keys.json')) # Set up Helix api api = Helix(user_name=keys['username'], client_id=keys['client_id'], access_token=keys['access_token']) # Param info (temp) """ Required Parameters: list - Lists active streamers ranked (aplhabetically? by num viewers?), then lists non active streamers open [name] - Opens streamer in browser, active or not follow - Follow a streamer check - check if a specific streamer is live """ # Process params command_length = len(sys.argv) command_tag = str(sys.argv[1]) if command_length < 2: print("No paramters given. Showing usage") sys.exit(1) elif command_tag == "list": if command_length > 2: print("Incorrect usage of list. Showing usage") sys.exit(1) else: print(api.get_streams()) sys.exit(0) elif command_tag == "open": if command_length != 3: print("Incorrect usage of open. Showing usage") sys.exit(1) else: api.open_stream(str(sys.argv[2])) sys.exit(0) elif command_tag == "check": if command_length != 3: print("Incorrect usage of check. Showing usage") sys.exit(1) else: status = api.check_stream(str(sys.argv[2])) print(status) sys.exit(0) else: print("Parameter not recognized") sys.exit(1)
import numpy as np import numpy.linalg as LA from scipy.special import erf, erfc import nlopt from helix import Helix from config import * # setup the data N = 11 Y = Helix(radius=2, slope=1, num_points=N).coords.T p = 3 q = 2 # initialize a set of means and standard deviations for the latent variables latent_means = [np.random.randn(q, 1) for _ in range(N)] latent_variances = [np.random.randn(q)**2 for _ in range(N)] latent_Sigmas = [np.diag(var) for var in latent_variances] ss = [-mi[-1]*si[-1] for mi, si in zip(latent_means, latent_variances)] # set starting values for sigma2, mu, B_1, B_2, g_1, and g_2 mu = np.mean(Y, axis=1).reshape(1, -1) # the optimal value for mu is the empirical mean of the data sigma2 = np.random.rand() # set to random positive number B1 = np.random.randn(p, q) B2 = np.random.randn(p, q) g1 = 1. g2 = 1. # I want the observations to be 1xp arrays for later computations Y = [yi.reshape(1, -1) for yi in Y.T]
import time import serial from helix import Helix import json import requests import sys serialcomm = serial.Serial('COM5', 115200) serialcomm.timeout = 1 keys = json.load(open('./keys.json')) api = Helix( user_name = keys['username'], client_id = keys['client_id'], access_token = keys['access_token']) while True: # Get list of followed streamers url = 'https://api.twitch.tv/helix/users/follows?from_id=' #TODO Change to get id dynamically # sys.exit(1) r = requests.get(url, headers=api.headers) followed = [] for streamer in r.json()['data']: followed.append(streamer['to_name']) url2 = 'https://api.twitch.tv/helix/streams?user_login=' for streamer in followed: r2 = requests.get(url=url2 + streamer, headers=api.headers)