Last active
October 12, 2023 12:38
-
-
Save lxfly2000/52ad1c81b22d81d9f94433d6fedbd3f6 to your computer and use it in GitHub Desktop.
恢复B站UWP下载的加密视频(可将该脚本放在sendto文件夹下)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3.9 | |
import sys | |
def restore_bili_video(video_path): | |
print("Restoring... "+video_path) | |
ext=video_path[video_path.rfind("."):] | |
fin=open(video_path,"rb") | |
if fin.read(1)!=b"\xff": | |
print("This file is not encrypted by bilibili.") | |
fin.close() | |
return | |
fout=open(video_path[:-len(ext)]+"_restore"+ext,"wb") | |
is_video_file=False | |
while True: | |
b=fin.read(4096 if is_video_file else 1) | |
if b==b"": | |
break | |
if not is_video_file and b == b"\xff": | |
continue | |
is_video_file=True | |
fout.write(b) | |
fin.close() | |
fout.close() | |
if len(sys.argv) < 2: | |
print("Usage: "+sys.argv[0]+" <video1> [video2] ...") | |
else: | |
for i in range(1,len(sys.argv)): | |
restore_bili_video(sys.argv[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment