From bdb699135b7144d86a71bb154bfe069d75715102 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 28 Oct 2022 20:04:22 +0200 Subject: Mangakatana: use i3 server instead of i2 because its borked --- plugins/mangakatana.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/mangakatana.py b/plugins/mangakatana.py index 85fd8d0..e7e0604 100755 --- a/plugins/mangakatana.py +++ b/plugins/mangakatana.py @@ -36,15 +36,19 @@ if len(sys.argv) < 2: def download_file(url, save_path): file_size = 0 - with requests.get(url, headers=headers, stream=True, timeout=30) as response: - if not response.ok: - return 0 - with open(save_path, "wb") as file: - for chunk in response.iter_content(chunk_size=8192): - if chunk: - file.write(chunk) - file_size += len(chunk) - return file_size + try: + with requests.get(url, headers=headers, stream=True, timeout=30) as response: + if not response.ok: + return 0 + with open(save_path, "wb") as file: + for chunk in response.iter_content(chunk_size=8192): + if chunk: + file.write(chunk) + file_size += len(chunk) + return file_size + except requests.exceptions.ChunkedEncodingError as e: + print("Warning: error while downloading %s: %s" % (url, str(e))) + return 0 def list_chapters(url, chapter_list_input): response = requests.get(url, headers=headers, timeout=30) @@ -146,9 +150,9 @@ def download_chapter(url, download_dir): ext = image_source[image_source.rfind("."):] image_name = str(img_number) + ext image_path = os.path.join(download_dir, image_name) + image_source = image_source.replace("://i1", "://i3") print("Downloading {} to {}".format(image_source, image_path)) if not download_file(image_source, image_path): - image_source = image_source.replace("://i3", "://i2") if not download_file(image_source, image_path): print("Failed to download image: %s" % image_source) os.remove(in_progress_filepath) -- cgit v1.2.3