Last active
October 12, 2023 12:38
-
-
Save lxfly2000/52ad1c81b22d81d9f94433d6fedbd3f6 to your computer and use it in GitHub Desktop.
Revisions
-
lxfly2000 revised this gist
Oct 12, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Python 3.9 import sys def restore_bili_video(video_path): -
lxfly2000 revised this gist
Oct 12, 2023 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,10 @@ 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: -
lxfly2000 created this gist
Oct 12, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import sys def restore_bili_video(video_path): print("Restoring... "+video_path) ext=video_path[video_path.rfind("."):] fin=open(video_path,"rb") 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])