Forum Archive

Remotely control roku 3 from pythonista

Webmaster4o

I've been able to get the roku module working on pythonista! I briefly had a problem when it required lxml, but it seems to work just fine if I replace

from lxml import etree

With

from xml import etree

I've been able to successfully connect to my roku with my iPad and act as the remote (up, down, left, right, select) more to come!

Webmaster4o

Script to type on the keyboard using up/down/left/right:

# coding: utf-8
import roku, time

r = roku.Roku('192.168.1.110')

keylist = [
['a','b','c','d','e','f','g'],
['h','i','j','k','l','m','n'],
['o','p','q','r','s','t','u'],
['v','w','x','y','z','-','\''],
[' '],]

keymap = {}

for y in range(len(keylist)):
    for x in range(len(keylist[y])):
        key = keylist[y][x]
        keymap[key]=(x, y)




def type(string):
    for l in string.lower():
        x, y = keymap[l]

        for _ in range(x):
            r.right()
        for _ in range(y):
            r.down()
        r.select()
        for _ in range(x):
            r.left()
        for _ in range(y):
            r.up()

while 1:    
    type(raw_input())

It was designed for the YouTube app's size keyboard. Resets the cursor to 'a' every time, but the version that didn't failed miserably. Still experimental.