From f5d02c8e76663a5e4dd63e752d06f55737841668 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 22 Mar 2020 22:32:12 +0100 Subject: Remove dependency on wget --- plugins/manganelo.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'plugins/manganelo.py') diff --git a/plugins/manganelo.py b/plugins/manganelo.py index 9d8a644..e8e7efb 100755 --- a/plugins/manganelo.py +++ b/plugins/manganelo.py @@ -5,7 +5,6 @@ import time import sys import requests import json -import subprocess from lxml import etree @@ -32,12 +31,12 @@ if len(sys.argv) < 2: usage() def download_file(url, save_path): - process = subprocess.Popen(["wget", "-q", "-o", "/dev/null", "-O", save_path, url], stderr=subprocess.PIPE) - _, stderr = process.communicate() - if process.returncode != 0: - print("Failed to download file: {}, error: {}".format(url, stderr.decode('utf-8'))) - return False - return True + with requests.get(url, stream=True) as response: + response.raise_for_status() + with open(save_path, "wb") as file: + for chunk in response.iter_content(chunk_size=8192): + if chunk: + file.write(chunk) def list_chapters(url, chapter_list_input): response = requests.get(url) @@ -84,8 +83,7 @@ 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)) - if not download_file(image_source, image_path): - exit(1) + download_file(image_source, image_path) img_number += 1 with open(os.path.join(download_dir, ".finished"), "w") as file: -- cgit v1.2.3