diff options
Diffstat (limited to 'plugins/mangatown.py')
-rwxr-xr-x | plugins/mangatown.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/plugins/mangatown.py b/plugins/mangatown.py index 87a1173..15f5681 100755 --- a/plugins/mangatown.py +++ b/plugins/mangatown.py @@ -26,7 +26,7 @@ def usage_list(): def usage_download(): print("mangatown.py download <url> <download_dir>") print("examples:") - print(" mangatown.py download \"https://www.mangatown.com/manga/naruto/v63/c700.2/\" /home/adam/Manga/MangaName") + print(" mangatown.py download \"https://www.mangatown.com/manga/naruto/v63/c700.2/\" /home/user/Manga/MangaName") print("") print("Note: The manga directory has to exist.") exit(1) @@ -48,9 +48,7 @@ def download_file(url, save_path): def list_chapters(url, chapter_list_input): response = requests.get(url, headers=headers) - if response.status_code != 200: - print("Failed to list chapters, server responded with status code %d" % response.status_code) - exit(2) + response.raise_for_status() seen_titles = set() for item in chapter_list_input: @@ -86,9 +84,7 @@ def is_only_num(s): def download_chapter(url, download_dir): response = requests.get(url, headers=headers) - if response.status_code != 200: - print("Failed to list chapter images, server responded with status code %d" % response.status_code) - exit(2) + response.raise_for_status() in_progress_filepath = os.path.join(download_dir, ".in_progress") with open(in_progress_filepath, "w") as file: @@ -107,7 +103,7 @@ def download_chapter(url, download_dir): while True: full_url = url + str(img_number) + ".html" response = requests.get(full_url, headers=headers) - if response.status_code != 200: + if not response.ok(): break tree = etree.HTML(response.text) |