aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2023-06-01 09:54:59 -0500
committerAnthony Wang2023-06-01 09:54:59 -0500
commit7267b6eb927ea9e2a43f3d5d24484c854403fbde (patch)
tree26ed7dc34c30ebb88a0a2a56c334939f1940e911
parenteb84ecef4a40302e27a81ad1185463548f6ed2fa (diff)
Enable mpv keyboard input again, wait until mpv quits before prompting for next video
-rwxr-xr-xmain.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/main.py b/main.py
index 09a8ee7..b8008c8 100755
--- a/main.py
+++ b/main.py
@@ -15,10 +15,8 @@ url = 'https://www.bilibili.com/video/'
cur = sys.argv[1]
while True:
# First start mpv in the background
- # Disable mpv keyboard input
- # That took me a stupidly long time to figure out
# Also enable subtitles because why not
- proc = subprocess.Popen(['mpv', '--no-video', '--no-input-terminal', '--slang=zh-CN', url + cur])
+ proc = subprocess.Popen(['mpv', '--no-video', '--slang=zh-CN', url + cur])
# The try finally block is to ensure that proc gets killed no matter what
try:
# I could use the Python requests library...
@@ -42,13 +40,14 @@ while True:
# Print it out the smart way!
# Who needs loops smh
print(*enumerate(rec), sep='\n')
- # Choose a recommended video
- # If you don't like any, just stop the app, burn your computer, and try again
- cur = rec[int(input())][0]
+ proc.wait()
finally:
# Kill mpv with fire because sometimes it likes the music too much and refuses to stop if you ask nicely
proc.kill()
- # Give instant feedback so it doesn't look like the app is hanging
- print(cur)
- # I have more comments than code so I must be doing something right right?
- # Right???
+ # Choose a recommended video
+ # If you don't like any, just stop the app, burn your computer, and try again
+ cur = rec[int(input("Choose next: "))][0]
+ # Give instant feedback so it doesn't look like the app is hanging
+ print(cur)
+ # I have more comments than code so I must be doing something right right?
+ # Right???