aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-03-22 22:32:12 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:12:34 +0200
commitf5d02c8e76663a5e4dd63e752d06f55737841668 (patch)
treec4494dba70e874cb4b35202563a896cb166dbc21
parent27634797e19622060180a3d972ffc69cc16217b3 (diff)
Remove dependency on wget
-rw-r--r--README.md2
-rwxr-xr-xplugins/lhtranslation.py16
-rwxr-xr-xplugins/manganelo.py16
3 files changed, 15 insertions, 19 deletions
diff --git a/README.md b/README.md
index d17c213..90dba1c 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ Run automedia without any options to see all options.
2. Automatically remove torrents that have finished seeding, to reduce memory usage and startup time of transmission.
# Requirements
## System
-wget, transmission-cli, notify-send (optional)
+transmission-cli, notify-send (optional)
## Python
feedparser, transmissionrpc, lxml, requests
# Requirements when using read_manga.py
diff --git a/plugins/lhtranslation.py b/plugins/lhtranslation.py
index 9b29a47..f23806d 100755
--- a/plugins/lhtranslation.py
+++ b/plugins/lhtranslation.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)
@@ -85,8 +84,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:
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: