Python Forum
trying to change channels with python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to change channels with python
#2
Something like this put together.
# tv.py
from flask import Flask
import pyautogui
import time

app = Flask(__name__)

def change_channel(channel_number):
    # Test
    print(channel_number)

    # Wait for the HDHomerun app to be ready
    pyautogui.click('HDHR-live.png')
    time.sleep(25)  # Adjust this if needed

    # Change to the requested channel
    pyautogui.typewrite(channel_number)
    time.sleep(2)
    pyautogui.press('enter')

@app.route('/channel/<number>')
def channel_name(number):
    # Call the function to change the channel
    change_channel(number)
    return f'Channel changed to {number}!'

if __name__ == '__main__':
    # Run the Flask app, accessible from the network
    #app.run(host='0.0.0.0', port=5000)
    app.run()
Run.
G:\div_code\foobar
λ flask --app tv run
 * Serving Flask app 'tv'
 * Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
Press CTRL+C to quit
99
127.0.0.1 - - [16/Sep/2024 22:40:47] "GET /channel/99 HTTP/1.1" 200 -
In browser http://127.0.0.1:5000/channel/99
Output:
Channel changed to 99!
Reply


Messages In This Thread
trying to change channels with python - by greggk1 - Sep-16-2024, 08:06 PM
RE: trying to change channels with python - by snippsat - Sep-16-2024, 08:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding MIDI Channels to each Input zach1234 6 2,625 Apr-20-2023, 11:51 AM
Last Post: jefsummers
  mapping joystick axis to specific 'channels' in python DashOrion 1 3,844 Jul-07-2020, 04:26 PM
Last Post: DashOrion
  [split] building a transition matrix for ion channels satyam2007 1 2,127 Jul-31-2019, 04:20 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020