From 83142498b3a60239b0fbba0829deaf9c422cbc0e Mon Sep 17 00:00:00 2001 From: caiwx86 Date: Fri, 7 Apr 2023 10:35:25 +0800 Subject: [PATCH] fix --- common/BaseComicEntity.py | 3 ++- main.py | 6 ++---- utils/FileUtils.py | 16 +++++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/common/BaseComicEntity.py b/common/BaseComicEntity.py index 0765083..b0f7d36 100644 --- a/common/BaseComicEntity.py +++ b/common/BaseComicEntity.py @@ -70,7 +70,8 @@ class baseComic: #if ciUtils.isProgressDone() and fu.notExists(ComicPath.getNewCBZComicChapter("file")): # ciUtils.setProgressFail() cbz_path = ComicPath.getPathCBZComicChapter() - if fileUtils.getModificationDateYMD(cbz_path,not_exists="20101010") > 20230405: + file_date = int(fileUtils.getModificationDate(cbz_path,"%Y%m%d%H",not_exists="2010010101")) + if file_date > 2023040610 and file_date < 2023040710: os.remove(cbz_path) print(f"已删除CBZ, {cbz_path}") ciUtils.setProgressFail() diff --git a/main.py b/main.py index ed72ecf..61b96aa 100644 --- a/main.py +++ b/main.py @@ -19,7 +19,5 @@ def proxy(): os.environ["https_proxy"] = "http://127.0.0.1:7890" if __name__ == '__main__': -# rouman() -# baozi() - result = fileUtils.getModificationDateYMD("D:\mnt\Comics\RM\CBZ\把妹鬼达人\第1话-色鬼授予的爱爱超能力.CBZ") - print(result) \ No newline at end of file + rouman() +# baozi() \ No newline at end of file diff --git a/utils/FileUtils.py b/utils/FileUtils.py index 4b91408..85deac4 100644 --- a/utils/FileUtils.py +++ b/utils/FileUtils.py @@ -195,17 +195,19 @@ class imageUtils: print("remove=",imgpath) class fileUtils: + @classmethod - def getModificationDate(cls,file_path): - return os.path.getmtime(file_path) + def getModificationDate(cls,file_path,format="%Y%m%d",not_exists=None): + if cls.notExists(file_path): return not_exists + file_date = os.path.getmtime(file_path) + s = time.localtime(file_date) + format_date = time.strftime(format,s) + print(f"file={file_path} {format_date}") + return format_date @classmethod def getModificationDateYMD(cls,file_path,not_exists="9999"): - if cls.notExists(file_path): return not_exists - file_date = cls.getModificationDate(file_path) - s = time.localtime(file_date) - ymd = time.strftime("%Y%m%d",s) - print(f"file={file_path} {ymd}") + ymd = cls.getModificationDate(file_path,"%Y%m%d",not_exists) return int(ymd) @classmethod