From 03534b3fcfd56f7725b5a558a1c6361a1d6db1da Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 5 May 2020 19:22:23 +0200 Subject: Fallback to backup image source if download fails for manganelo --- plugins/manganelo.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/manganelo.py b/plugins/manganelo.py index 3ce51b8..b19d3e9 100755 --- a/plugins/manganelo.py +++ b/plugins/manganelo.py @@ -89,9 +89,24 @@ def download_chapter(url, download_dir): print("Downloading {} to {}".format(image_source, image_path)) file_size = download_file(image_source, image_path) if file_size < 255: - print("resource temporary unavailable: %s" % image_source) - os.remove(in_progress_filepath) - exit(2) + try_backup_url = False + new_image_source = image_source.replace("s3.mkklcdnv3.com", "bu.mkklcdnbuv1.com") + if new_image_source != image_source: + try_backup_url = True + else: + new_image_source = image_source.replace("s41.mkklcdnv41.com", "bu.mkklcdnbuv1.com") + try_backup_url = (new_image_source != image_source) + + if try_backup_url: + file_size = download_file(new_image_source, image_path) + if file_size < 255: + print("resource temporary unavailable: %s" % new_image_source) + os.remove(in_progress_filepath) + exit(2) + else: + print("resource temporary unavailable: %s" % image_source) + os.remove(in_progress_filepath) + exit(2) img_number += 1 if img_number == 1: -- cgit v1.2.3