aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplugins/mangadex.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/plugins/mangadex.py b/plugins/mangadex.py
index 79b519d..5890b92 100755
--- a/plugins/mangadex.py
+++ b/plugins/mangadex.py
@@ -35,8 +35,8 @@ def usage_download():
if len(sys.argv) < 2:
usage()
-def download_file(url, save_path):
- with requests.get(url, headers=headers, stream=True) as response:
+def download_file(url, cookies, save_path):
+ with requests.get(url, headers=headers, cookies=cookies, stream=True) as response:
if not response.ok:
return False
with open(save_path, "wb") as file:
@@ -130,6 +130,13 @@ def download_chapter(url, download_dir):
print("Failed to extract manga id from url: %s. Note: url is expected to be in this format: mangadex.org/chapter/<number>" % url)
exit(2)
+ response = requests.get(request_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)
+
+ cookies = response.cookies
+
url = "https://mangadex.org/api/?id=%s&server=null&type=chapter" % manga_id
response = requests.get(url, headers=headers)
@@ -156,7 +163,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_url, image_path))
- if not download_file(image_url, image_path):
+ if not download_file(image_url, cookies, image_path):
print("Failed to download image: %s" % image_url)
os.remove(in_progress_filepath)
exit(2)