-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_twitch.py
executable file
·33 lines (24 loc) · 1.2 KB
/
auto_twitch.py
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
#!/usr/bin/env python3
#this above line is called the shebang line, which allows you to run the script on background with the nohup command
# you also gotta change the permission for the file which is "chmod +x auto_twitch.py" navigate to the folder where the file is present then type the command
# this whole thing was the command for me "nohup python3 /home/samurai/Code/daily-scripts/auto_twitch.py &"
# program is very specific to debian-linux
import os
from time import sleep
import schedule
def open_stream_and_shutdown():
os.system("google-chrome https://www.twitch.tv/brawlhalla")
os.system("firefox https://www.twitch.tv/brawlhalla")
os.system("shutdown +75")
#An extray layer of fail safe shutdown
#stream lasts for 4500 seconds, triggering a shutdown command after the stream
sleep(4500)
os.system("shutdown -h now")
schedule.every().tuesday.at("23:27").do(open_stream_and_shutdown)
schedule.every().friday.at("23:27").do(open_stream_and_shutdown)
# yet another fail safe shutdown
schedule.every().wednesday.at("00:35").do(os.system, "shutdown -h now")
schedule.every().saturday.at("00:35").do(os.system, "shutdown -h now")
while True:
schedule.run_pending()
sleep(60)