Created
June 12, 2019 08:19
-
-
Save drewbitt/a794fc6e82acb1e2572d27d2517645a3 to your computer and use it in GitHub Desktop.
Madokami Downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# for a list as expected in https://gist.github.com/drewbitt/43cab7b6c0792b30a46d65c226a741db | |
import base64 | |
import argparse | |
import urllib.parse | |
import httplib2 | |
from pathlib import Path | |
parser = argparse.ArgumentParser() | |
parser.add_argument("download_list", nargs=1) | |
args = parser.parse_args() | |
madokami_url = "https://manga.madokami.al/" | |
username = "" | |
password = "" | |
with open(args.download_list[0], "r") as my_list: | |
h = httplib2.Http() | |
data_str = str(username) + ':' + str(password) | |
auth = base64.encodestring(data_str.encode("utf-8")) | |
response, content = h.request( | |
madokami_url, | |
'GET', | |
headers = { 'Authorization' : 'Basic ' + auth.decode("utf-8") }) | |
cookie = response['set-cookie'] | |
for line in my_list: | |
line = line.rstrip("\n") | |
path = urllib.parse.urlsplit(line).path | |
filename = urllib.parse.unquote(Path(path).name) | |
print("Downloading {}".format(filename)) | |
headers = {'Cookie': cookie} | |
response, content = h.request(line, 'GET', headers=headers) | |
with open(filename, "wb") as test: | |
test.write(content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# for single link downloads now that cookies are required | |
import base64 | |
import argparse | |
import urllib.parse | |
import httplib2 | |
from pathlib import Path | |
parser = argparse.ArgumentParser() | |
parser.add_argument("download_url", nargs=1) | |
args = parser.parse_args() | |
madokami_url = "https://manga.madokami.al/" | |
username = "" | |
password = "" | |
h = httplib2.Http() | |
data_str = str(username) + ':' + str(password) | |
auth = base64.encodestring(data_str.encode("utf-8")) | |
response, content = h.request( | |
madokami_url, | |
'GET', | |
headers = { 'Authorization' : 'Basic ' + auth.decode("utf-8") }) | |
path = urllib.parse.urlsplit(args.download_url[0]).path | |
filename = urllib.parse.unquote(Path(path).name) | |
print("Downloading {}".format(filename)) | |
headers = {'Cookie': response['set-cookie']} | |
response, content = h.request(args.download_url[0], 'GET', headers=headers) | |
with open(filename, "wb") as test: | |
test.write(content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this seems... particularly slow