diff options
-rw-r--r-- | main.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -0,0 +1,20 @@ +import gzip +import re +import subprocess +import sys +import urllib.request + +cur = sys.argv[1] +while True: + proc = subprocess.Popen(['mpv', '--no-video', '--no-input-default-bindings', '--slang=zh-CN', 'https://www.bilibili.com/video/' + cur]) + try: + body = gzip.decompress(urllib.request.urlopen('https://www.bilibili.com/video/' + cur).read()).decode('utf-8') + print(cur, re.search('<title data-vue-meta="true">(.*?)<', body).group(1)) + rec = [ + (re.search('/video/(.*?)/', line).group(1), re.search('title="(.*?)"', line).group(1)) + for line in body.split('\n') if 'recommend_more' in line + ] + print(*enumerate(rec), sep='\n') + cur = rec[int(input())][0] + finally: + proc.kill() |