aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)