-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathroku-set.py
More file actions
executable file
·61 lines (46 loc) · 1.58 KB
/
roku-set.py
File metadata and controls
executable file
·61 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
""" roku-set.py at https://github.com/wilsonmar/python-samples/blob/main/roku-set.py
STATUS: NOT WORKING. Opens YouTube with hard-coded values.
"v003 + flake8 fixes :roku-set.py"
This Python program sets a Roku device on the same network to a specific Youtube video."
"""
# pip install roku # roku-4.1.0
from roku import Roku # v3.1 Aug 4, 2019
# https://pypi.org/project/roku/
# https://github.com/jcarbaugh/python-roku
import time
# GLOBALS:
# Replace with your Roku's IP address
# obtained on Roku device connected using the same SSID as your computer.
# 1. Press the Home button on your remote to access the main menu.
# 2. Navigate to Settings. 3. Select Network. 4. Choose About.
# 5. Type below the IP address displayed on Roku's screen.
roku_id_discovered = Roku.discover()
# [<Roku: 192.168.10.163:8060>, <Roku: 192.168.1.23:80>]
print(f"roku_id discovered: {roku_id_discovered}")
ROKU_IP = '192.168.1.14'
# TODO: Ping ROKU_IP to test if valid.
# The part after 'v=' in the YouTube URL https://www.youtube.com/watch?v=nVULVZUuJOA
YOUTUBE_ID = 'nVULVZUuJOA'
# Connect to the Roku device
try:
roku = Roku(ROKU_IP)
except Exception as e:
print(f"failed {e}")
# roku.apps # returns list of apps
# Launch the YouTube app
youtube_app = roku['YouTube']
# OUTPUT: <Application: [2285] Hulu Plus v2.7.6>
youtube_app.launch()
# Wait for the app to load
time.sleep(20)
# Navigate to the search function
roku.home()
time.sleep(5)
roku.down()
roku.select()
# Enter the video ID text:
roku.literal(YOUTUBE_ID)
# Start the video
roku.right()
roku.select()