diff options
author | Anthony Wang | 2023-05-31 16:41:45 -0500 |
---|---|---|
committer | Anthony Wang | 2023-05-31 16:41:45 -0500 |
commit | 71b2bda6e0d29bafe8257d5c3a497dbc12e2b9c3 (patch) | |
tree | d38a93154e2ba8327241897e73bb16568862e0e1 /main.py | |
parent | 907c25b94faf38a77b07d6e3558f0c805ab51739 (diff) |
Add main.py
Diffstat (limited to 'main.py')
-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() |