Skip to content

Commit 15bbbf0

Browse files
committed
python: add video decode for bili@v2.14.79.0
1 parent 00d7b1a commit 15bbbf0

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

python/project/rename/renameflv-no-seq.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def rename_cell_folder(folder_name):
5252
_file = all_file_name[i]
5353
if '.flv' in _file:
5454
old_file_path = os.path.join(folder_name, _file)
55+
decode_bili(old_file_path)
5556
suffix = _file[_file.rfind('_'):] # _10.flv
5657
if len(suffix) <= 1:
5758
new_file_path = os.path.join(folder_name, str(prefix + file_name + '.flv'))
@@ -61,6 +62,7 @@ def rename_cell_folder(folder_name):
6162
os.rename(old_file_path, new_file_path.zfill(3))
6263
if '.mp4' in _file:
6364
old_file_path = os.path.join(folder_name, _file)
65+
decode_bili(old_file_path)
6466
suffix = _file[_file.rfind('_'):] # _10.flv
6567
if len(suffix) <= 1:
6668
new_file_path = os.path.join(folder_name, str(prefix + file_name + '.flv'))
@@ -90,6 +92,18 @@ def get_cell_folder(dir_name, cell_folders):
9092
get_cell_folder(os.path.join(dir_name, _dir), cell_folders)
9193
return cell_folders
9294

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)
93107

94108
if __name__ == "__main__":
95109
try:

python/project/rename/renameflv.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import json
33
import os
44

5-
65
def 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+
94108
if __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

Comments
 (0)