fix
This commit is contained in:
parent
39fde06ff0
commit
30d39584f0
8
test.py
8
test.py
@ -2,7 +2,7 @@ from src.common.naming import FileNaming
|
||||
from src.common.ComicInfo import ImageInfo
|
||||
from zipfile import ZipFile
|
||||
from datetime import datetime
|
||||
import time
|
||||
import time, shutil
|
||||
import os,hashlib
|
||||
import xml.etree.ElementTree as ET
|
||||
from PIL import Image
|
||||
@ -210,7 +210,7 @@ class comicInfo:
|
||||
# 创建临时文件处理覆盖操作
|
||||
with NamedTemporaryFile(delete=False) as tmp:
|
||||
tmp.close()
|
||||
os.replace(cbz_path, tmp.name) # 备份原文件
|
||||
shutil.copy(cbz_path, tmp.name)
|
||||
|
||||
# 读取原文件并替换 ComicInfo.xml
|
||||
with ZipFile(tmp.name, 'r') as source_zip:
|
||||
@ -223,7 +223,7 @@ class comicInfo:
|
||||
# 添加新 XML
|
||||
new_zip.writestr("ComicInfo.xml", new_xml_content)
|
||||
|
||||
os.remove(tmp.name) # 清理临时文件
|
||||
shutil.rmtree(tmp.name) # 清理临时文件
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"更新 CBZ 文件失败: {e}")
|
||||
@ -277,7 +277,7 @@ if __name__ == "__main__":
|
||||
create_time = time.localtime(os.path.getctime(file)) # 注意:st_birthtime 在Linux/MacOS中可用,但不是所有系统都支持
|
||||
# 格式化时间
|
||||
formatted_time = time.strftime('%Y%m%d', create_time)
|
||||
if int(formatted_time) < 20250204:
|
||||
if int(formatted_time) > 20250204:
|
||||
print(f"{file} 文件创建时间:", formatted_time)
|
||||
comicInfo().update_comicinfo_cbz(file)
|
||||
#if size < 3000:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user