22import json
33import os
44
5-
65def is_target_folder (all_file_name ):
76 """
87 :function: judge the target folder
@@ -52,6 +51,7 @@ def rename_cell_folder(folder_name):
5251 _file = all_file_name [i ]
5352 if '.flv' in _file :
5453 old_file_path = os .path .join (folder_name , _file )
54+ decode_bili (old_file_path )
5555 suffix = _file [_file .rfind ('_' ):] # _10.flv
5656 if len (suffix ) <= 1 :
5757 new_file_path = os .path .join (folder_name , str (prefix + file_name + '.flv' ))
@@ -61,6 +61,7 @@ def rename_cell_folder(folder_name):
6161 os .rename (old_file_path , new_file_path .zfill (3 ))
6262 if '.mp4' in _file :
6363 old_file_path = os .path .join (folder_name , _file )
64+ decode_bili (old_file_path )
6465 suffix = _file [_file .rfind ('_' ):] # _10.flv
6566 if len (suffix ) <= 1 :
6667 new_file_path = os .path .join (folder_name , str (prefix + file_name + '.flv' ))
@@ -91,11 +92,24 @@ def get_cell_folder(dir_name, cell_folders):
9192 return cell_folders
9293
9394
95+ def decode_bili (name ):
96+ """
97+ just decode video for v2.14.79.0
98+ :param name: full video name
99+ :return:
100+ """
101+ with open (name , mode = 'rb+' ) as f :
102+ old = f .readlines ()
103+ while old [0 ].startswith (b'\xff ' ):
104+ old [0 ] = old [0 ][1 :]
105+ f .seek (0 ) # rewind
106+ f .writelines (old )
107+
94108if __name__ == "__main__" :
95109 try :
96110 # 自动获取目录
97111 current_path = os .path .dirname (os .path .abspath (__file__ ))
98- # current_path = "E :\\bilibili\\629300292 "
112+ # current_path = "C :\\Users\\zack\\336748125 "
99113 cell_folders = []
100114 cell_folders = get_cell_folder (current_path , cell_folders )
101115
0 commit comments