add download_only_missing_image config item

This commit is contained in:
lededev
2021-10-10 18:02:53 +08:00
parent 0933e87944
commit e5abac9138
3 changed files with 12 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ nfo_skip_days=30
stop_counter=0 stop_counter=0
; 以上两个参数配合使用可以以多次少量的方式刮削或整理数千个文件而不触发翻译或元数据站封禁 ; 以上两个参数配合使用可以以多次少量的方式刮削或整理数千个文件而不触发翻译或元数据站封禁
ignore_failed_list=0 ignore_failed_list=0
download_only_missing_images=1
[proxy] [proxy]
;proxytype: http or socks5 or socks5h switch: 0 1 ;proxytype: http or socks5 or socks5h switch: 0 1

View File

@@ -141,6 +141,8 @@ class Config:
return 0 return 0
def ignore_failed_list(self) -> bool: def ignore_failed_list(self) -> bool:
return self.getboolean_override("common", "ignore_failed_list") return self.getboolean_override("common", "ignore_failed_list")
def download_only_missing_images(self) -> bool:
return self.conf.getboolean("common", "download_only_missing_images")
def is_transalte(self) -> bool: def is_transalte(self) -> bool:
return self.conf.getboolean("transalte", "switch") return self.conf.getboolean("transalte", "switch")
def is_trailer(self) -> bool: def is_trailer(self) -> bool:
@@ -264,6 +266,7 @@ class Config:
conf.set(sec1, "nfo_skip_days", 30) conf.set(sec1, "nfo_skip_days", 30)
conf.set(sec1, "stop_counter", 0) conf.set(sec1, "stop_counter", 0)
conf.set(sec1, "ignore_failed_list", 0) conf.set(sec1, "ignore_failed_list", 0)
conf.set(sec1, "download_only_missing_images", 1)
sec2 = "proxy" sec2 = "proxy"
conf.add_section(sec2) conf.add_section(sec2)

10
core.py
View File

@@ -183,11 +183,15 @@ def trailer_download(trailer, leak_word, c_word, number, path, filepath):
# 剧照下载成功否则移动到failed # 剧照下载成功否则移动到failed
def extrafanart_download(data, path, filepath): def extrafanart_download(data, path, filepath):
j = 1 j = 1
path = os.path.join(path, config.getInstance().get_extrafanart()) conf = config.getInstance()
configProxy = config.getInstance().proxy() path = os.path.join(path, conf.get_extrafanart())
configProxy = conf.proxy()
download_only_missing_images = conf.download_only_missing_images()
for url in data: for url in data:
jpg_filename = f'extrafanart-{j}.jpg' jpg_filename = f'extrafanart-{j}.jpg'
jpg_fullpath = os.path.join(path, jpg_filename) jpg_fullpath = os.path.join(path, jpg_filename)
if download_only_missing_images and os.path.isfile(jpg_fullpath) and os.path.getsize(jpg_fullpath):
continue
if download_file_with_filename(url, jpg_filename, path, filepath) == 'failed': if download_file_with_filename(url, jpg_filename, path, filepath) == 'failed':
moveFailedFolder(filepath) moveFailedFolder(filepath)
return return
@@ -209,6 +213,8 @@ def extrafanart_download(data, path, filepath):
def image_download(cover, number, leak_word, c_word, path, filepath): def image_download(cover, number, leak_word, c_word, path, filepath):
filename = f"{number}{leak_word}{c_word}-fanart.jpg" filename = f"{number}{leak_word}{c_word}-fanart.jpg"
full_filepath = os.path.join(path, filename) full_filepath = os.path.join(path, filename)
if config.getInstance().download_only_missing_images() and os.path.isfile(full_filepath) and os.path.getsize(full_filepath):
return
if download_file_with_filename(cover, filename, path, filepath) == 'failed': if download_file_with_filename(cover, filename, path, filepath) == 'failed':
moveFailedFolder(filepath) moveFailedFolder(filepath)
return return