aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-10-28 20:04:22 +0200
committerdec05eba <dec05eba@protonmail.com>2022-10-28 20:08:38 +0200
commitbdb699135b7144d86a71bb154bfe069d75715102 (patch)
treef397cb111a1d3a117ba8d5b4585bf011a9612c3e
parente6e441ab1d7f9f02be8f935bfff4391b2ce215f2 (diff)
Mangakatana: use i3 server instead of i2 because its borked
-rwxr-xr-xplugins/mangakatana.py24
1 files changed, 14 insertions, 10 deletions
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)