February 2022
Intermediate to advanced
182 pages
4h 25m
English
If you installed Visual Studio Code, you’re welcome to use that editor to open the empty twitchtimer.py file we created earlier. But given the brevity of this project’s Python script, it may be easier to use the Nano text editor for now:
$ nano twitchtimer.py
Either manually enter or copy and paste the following Python code into the editor window:
| ① | import os, subprocess, signal, sys, time |
| | |
| ② | duration = int(sys.argv[1])*60 |
| | |
| ③ | cmd = "streamlink twitch.tv/mst3k 720p" |
| ④ | twitchstream = subprocess.Popen(cmd,shell=True) |
| | |
| ⑤ | time.sleep(duration) |
| ⑥ | os.killpg(os.getpgid(twitchstream.pid), signal.SIGTERM) |
The first line of code imports the Python standard libraries ...
Read now
Unlock full access