Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/books
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,4 @@ python3 archive-org-downloader.py -e myemail@tempmail.com -p Passw0rd -r 0 -u ht
If you want to download a lot of books, you can paste the urls of the books in a .txt file (one per line) and use `--file`
```sh
python3 archive-org-downloader.py -e myemail@tempmail.com -p Passw0rd --file books_to_download.txt
```

## Donation
If you want to support my work, you can send 2 or 3 Bitcoins 🙃 to this address:
```
bc1q4nq8tjuezssy74d5amnrrq6ljvu7hd3l880m7l
```
![bitcoin_address](https://user-images.githubusercontent.com/54740007/169100171-1061c7a0-207e-459b-84de-2d6bb93b0f38.png)
```
35 changes: 25 additions & 10 deletions archive-org-downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,30 @@ def get_book_infos(session, url):

def login(email, password):
session = requests.Session()
session.get("https://archive.org/account/login")
response = session.get("https://archive.org/services/account/login/")
login_data = response.json()
if not login_data['success']:
display_error(response, "[-] Error while getting login token:")

data = {"username":email, "password":password}
login_token = login_data["value"]["token"]

response = session.post("https://archive.org/account/login", data=data)
if "bad_login" in response.text:
print("[-] Invalid credentials!")
exit()
elif "Successful login" in response.text:
headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = {"username":email, "password":password, "t": login_token}

response = session.post("https://archive.org/services/account/login/", headers=headers, data=json.dumps(data))
try:
response_json = response.json()
except:
display_error(response, "[-] Error while login:")

if response_json["success"] == False:
if response_json["value"] == "bad_login":
print("[-] Invalid credentials!")
exit()
display_error(response, "[-] Error while login:")
else:
print("[+] Successful login")
return session
else:
display_error(response, "[-] Error while login:")

def loan(session, book_id, verbose=True):
data = {
Expand Down Expand Up @@ -316,7 +327,11 @@ def make_pdf(pdf, title, directory):
pdfmeta['keywords'] = [f"https://archive.org/details/{book_id}"]

pdf = img2pdf.convert(images, **pdfmeta)
make_pdf(pdf, title, args.dir if args.dir != None else "")
if 'title-alt-script' in metadata:
title = metadata['title-alt-script']
title = title.replace("\\"," ").replace("/"," ").replace(":"," ").replace("*"," ").replace("?"," ")
title = title.replace("\""," ").replace("<"," ").replace(">"," ").replace("|"," ")
make_pdf(pdf, title, args.dir if args.dir != None else "")
try:
shutil.rmtree(directory)
except OSError as e:
Expand Down
Empty file added book.txt
Empty file.
1 change: 1 addition & 0 deletions download.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python archive-org-downloader.py -e *** -p *** -r 3 -d books --file book.txt