From 7267b6eb927ea9e2a43f3d5d24484c854403fbde Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Thu, 1 Jun 2023 09:54:59 -0500 Subject: Enable mpv keyboard input again, wait until mpv quits before prompting for next video --- main.py | 19 +++++++++---------- 1 file 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??? -- cgit v1.2.3-70-g09d2