diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-06-06 18:49:24 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:12:34 +0200 |
commit | 4b19a46148d8c739ae3e558290ce37a30a28f292 (patch) | |
tree | 5d05d07d0faa8aef712d779eb4590a5834053443 | |
parent | 33990a67620c185788a7e92bf96291d7126c3010 (diff) |
Exit manga download on failure
-rw-r--r-- | README.md | 3 | ||||
-rwxr-xr-x | automedia.py | 9 | ||||
-rwxr-xr-x | plugins/manganelo.py | 3 | ||||
-rwxr-xr-x | plugins/readms.py | 3 |
4 files changed, 8 insertions, 10 deletions
@@ -1,5 +1,6 @@ # TODO -Periodically check and remove in_progress files and their directories. This can happen if the computer crashes while adding rss. +1. Periodically check and remove in_progress files and their directories. This can happen if the computer crashes while adding rss. +2. Automatically remove torrents that have finished seeding, to reduce memory usage and startup time of transmission. # Requirements ## System transmission-cli diff --git a/automedia.py b/automedia.py index 4d6f140..171108b 100755 --- a/automedia.py +++ b/automedia.py @@ -327,14 +327,12 @@ def resume_tracked_html(plugin_entry, download_dir, tracked_html, session_id): item_session_id = file.read() if item_session_id != session_id: invalid_session = True - plugin_download(plugin_entry, url, item_dir) - show_notification("Resuming", "Resuming download for item {} with plugin {}".format(item, tracked_html.plugin)) except FileNotFoundError as e: invalid_session = True - plugin_download(plugin_entry, url, item_dir) - show_notification("Resuming", "Resuming download for item {} with plugin {}".format(item, tracked_html.plugin)) if invalid_session: + plugin_download(plugin_entry, url, item_dir) + show_notification("Resuming", "Resuming download for item {} with plugin {}".format(item, tracked_html.plugin)) with open(os.path.join(item_dir, "session_id"), "w") as file: file.write(session_id) except FileNotFoundError as e: @@ -377,9 +375,6 @@ def sync_html(tracked_html, download_dir, session_id): # A file called "finished" should be added to the download directory when the download has finished. # ./program download url download_dir latest = None - if len(items["items"]) > 0: - latest = items["items"][0]["name"].replace("/", "_") - for item in reversed(items["items"]): url = item["url"] name = item["name"].replace("/", "_") diff --git a/plugins/manganelo.py b/plugins/manganelo.py index 1526e6f..25114fa 100755 --- a/plugins/manganelo.py +++ b/plugins/manganelo.py @@ -73,7 +73,8 @@ def download_chapter(url, download_dir): image_name = str(img_number) + ext image_path = os.path.join(download_dir, image_name) print("Downloading {} to {}".format(image_source, image_path)) - download_file(image_source, image_path) + if not download_file(image_source, image_path): + exit(1) img_number += 1 with open(os.path.join(download_dir, "finished"), "w") as file: diff --git a/plugins/readms.py b/plugins/readms.py index d88deb1..878a043 100755 --- a/plugins/readms.py +++ b/plugins/readms.py @@ -79,7 +79,8 @@ def download_chapter(url, download_dir): image_name = str(img_number) + ext image_path = os.path.join(download_dir, image_name) print("Downloading {} to {}".format(image_source, image_path)) - download_file(image_source, image_path) + if not download_file(image_source, image_path): + exit(1) next_pages = tree.xpath('//div[@class="page"]//a/@href') if len(next_pages) != 1: |