Skip to content

Instantly share code, notes, and snippets.

@drewbitt
Created June 12, 2019 08:19
Show Gist options
  • Save drewbitt/a794fc6e82acb1e2572d27d2517645a3 to your computer and use it in GitHub Desktop.
Save drewbitt/a794fc6e82acb1e2572d27d2517645a3 to your computer and use it in GitHub Desktop.
Madokami Downloader
#!/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)
#!/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)
@drewbitt
Copy link
Author

this seems... particularly slow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment