blob: 7bd135c40697621faec51a6d69eb2b7bd9ed50ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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()
|