def main(): # Locate the roku device printing("Finding roku device ...") rokus = Roku.discover() printing("Done finding roku device ...") # IF no devices found ... if len(rokus) == 0: print("No rokus found") sys.exit(-1) # Otherwise, get the ip and port of the device else: roku_ip_address = rokus[0].host roku_port = rokus[0].port # Setup API object to make requests to the roku device print("Connecting ...") roku = Roku(host=roku_ip_address, port=roku_port) print("Done connecting ...") # Find youtube app print("Finding youtube app ...") youtube_app = [a for a in roku.apps if 'youtube' in a.name.lower()][0] print("Done finding youtube app ...") # Wait for the app to start print("Starting youtube app ...") APP_LAUNCH_TIMEOUT = 15 youtube_app.launch() time.sleep(APP_LAUNCH_TIMEOUT) print("Done starting youtube app ...") # Series of remote clicks to get to youtube Watch Later playlist # TODO: sleeps may not be needed roku.left() time.sleep(1) roku.left() time.sleep(1) roku.down() time.sleep(1) roku.down() time.sleep(1) roku.right() time.sleep(1) roku.down() time.sleep(1) roku.down() time.sleep(1) roku.right() time.sleep(1) roku.select()
app = next((a for a in roku.apps if 'plex' in a.name.lower()), None) if app: app.launch() time.sleep(20) for i in range(100): roku.volume_down() for i in range(14): roku.volume_up() roku.down() time.sleep(2) roku.select() time.sleep(2) roku.up() time.sleep(1) roku.up() time.sleep(1) roku.right() time.sleep(1) roku.right() time.sleep(1) roku.select() time.sleep(1) roku.down() time.sleep(1) roku.select() time.sleep(1) roku.right() time.sleep(1) roku.select()
from roku import Roku rokuls = Roku.discover(timeout=10); print(rokuls); ip = input('IP: '); roku = Roku(ip); while True: remoteinput = input('Remote Input (i.e. down, up, left, right, back, home, ok): '); if remoteinput == 'down': roku.down(); elif remoteinput == 'up': roku.up(); elif remoteinput == 'left': roku.left(); elif remoteinput == 'right': roku.right(); elif remoteinput == 'back': roku.back(); elif remoteinput == 'home': roku.home(); elif remoteinput == 'ok': roku.select(); else: print('Not a valid command.');
def roku_command(remote_command): delay = 1 #connect to roku #enter your rokus ip address to test roku = Roku('192.168.0.110') #remote command is place holder for list of commands from remote to dashboard #remote_command=['triangle'] #if circle shape is registered on remote than launch the most recent episode of a users favorite show. #In this case Silicon Valley. for i in remote_command: if i == 'circle': for light in lights: light.brightness = 254 light.xy = [.1, .1] hbo = roku["HBO GO"] hbo.launch() sleep(6 * delay) roku.down() sleep(delay) roku.right() sleep(delay) roku.right() sleep(delay) roku.select() sleep(3 * delay) roku.select() sleep(2 * delay) roku.select() sleep(delay) # roku.up() # sleep(delay) # roku.left() # sleep(delay) # roku.down() # sleep(delay) # roku.left() # sleep(delay) # roku.select() # sleep(2*delay) # roku.right() # sleep(delay) # roku.select() # sleep(2*delay) # roku.select() # sleep(2*delay) for light in lights: light.brightness = 100 if i == "left_swipe": #move cursor left roku.left() if i == "up_swipe": roku.up() if i == "down_swipe": roku.down() if i == "right_swipe": #move curser right roku.right() if i == "triangle": print "test" b.set_light([2, 3], 'on', True) # Prints if light 1 is on or not b.get_light(2, 'on') # Set brightness of lamp 1 to max b.set_light(2, 'bri', 254) # Set brightness of lamp 2 to 50% b.set_light(3, 'bri', 254) for light in lights: light.brightness = 254 light.xy = [.9, .7] #enter search commands roku.search() if i == "square": roku.info() if i == 'quad_diagonal_1': b.set_light(1, 'on', False) return True
###################################################################################### try: roku = Roku(userInput) # Channel shortcuts sling = roku['Sling TV'] netflix = roku['Netflix'] amazon = roku['Prime Video'] nbc = roku['NBC News'] hbo = roku['HBO Max'] # Keybindings keyboard.add_hotkey(72, lambda: roku.up()) keyboard.add_hotkey(75, lambda: roku.left()) keyboard.add_hotkey(77, lambda: roku.right()) keyboard.add_hotkey(80, lambda: roku.down()) keyboard.add_hotkey(14, lambda: roku.backspace()) keyboard.add_hotkey(28, lambda: rokuSubmitText()) def rokuHome(): roku.home() def rokuSearch(): roku.search() def rokuBack(): roku.back() def rokuOK(): roku.select()