Skip to content

Commit

Permalink
Update main.py (#108)
Browse files Browse the repository at this point in the history
* Update main.py

大幅提高检测本地是否存在此图片的速度

* Update function.py

* revert changes
  • Loading branch information
RookiesTwo authored Nov 24, 2024
1 parent c144248 commit 77b23cd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ def chapter_allocation(manga_chapter_json):
download_path = config.SETTINGS['download_path']
chapter_name = manga_chapter_info_json['results']['chapter']['name']
# 检查漫画文件夹是否存在

if not os.path.exists(f"{download_path}/{manga_name}/"):
os.mkdir(f"{download_path}/{manga_name}/")
# 创建多线程
Expand All @@ -570,6 +569,10 @@ def chapter_allocation(manga_chapter_json):
os.mkdir(f"{download_path}/{manga_name}/{chapter_name}/")
# 组成下载路径
filename = f"{download_path}/{manga_name}/{chapter_name}/{str(img_words[i] + 1).zfill(3)}.jpg"
# 判断是否已经下载
if os.path.exists(filename):
print(f"[blue]您已经下载了{filename},跳过下载[/]")
continue
t = threading.Thread(target=download, args=(url, filename))
# 开始线程
threads.append(t)
Expand Down Expand Up @@ -601,10 +604,6 @@ def chapter_allocation(manga_chapter_json):
# 下载相关

def download(url, filename, overwrite=False):
# 判断是否已经下载
if not overwrite and os.path.exists(filename):
print(f"[blue]您已经下载了{filename},跳过下载[/]")
return
img_api_restriction()
if config.SETTINGS['HC'] == "1":
url = url.replace("c800x.jpg", "c1500x.jpg")
Expand Down

0 comments on commit 77b23cd

Please sign in to comment.