Created
June 28, 2022 05:16
-
-
Save benthetechguy/2960b8cb880ace8dbd0595fc330dcece to your computer and use it in GitHub Desktop.
Roku remote script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2022 Ben Westover | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# You can receive a copy of the GNU General Public License at | |
# <http://www.gnu.org/licenses/>. | |
import sys | |
from time import sleep | |
from requests import post | |
from keyboard import read_key | |
if len(sys.argv) < 2: | |
raise ValueError("Please provide the IP address of your Roku device.") | |
def send(key): | |
print(key) | |
post(f"http://{sys.argv[1]}:8060/keypress/{key}") | |
sleep(0.2) | |
print(""" | |
Up arrow: Up | |
Down arrow: Down | |
Left arrow: Left | |
Right arrow: Right | |
Enter: OK | |
Backspace: Back | |
P: Play/Pause | |
U: Volume Up | |
D: Volume Down | |
M: Mute | |
""") | |
while True: | |
match read_key(): | |
case "up": | |
send("Up") | |
case "down": | |
send("Down") | |
case "left": | |
send("Left") | |
case "right": | |
send("Right") | |
case "enter": | |
send("Select") | |
case "backspace": | |
send("Back") | |
case "h": | |
send("Home") | |
case "p": | |
send("Play") | |
case "u": | |
send("VolumeUp") | |
case "d": | |
send("VolumeDown") | |
case "m": | |
send("VolumeMute") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea behind this eventually became controku.