lmbringas / packtpub-downloader

Script to download all your books from PacktPub inspired by https://github.com/ozzieperez/packtpub-library-downloader
267 stars 84 forks source link

NameError: name 'e' is not defined #44

Open burkesquires opened 3 years ago

burkesquires commented 3 years ago

This was working yesterday...

It would time out after downloading about 100 books but I could rerun it and it would start where it left off. Now I get the following error.

Is it possible the Packt just happened to change their API last night?

I tried using the "--email" option but it makes no difference.

Thank for all of your work in putting this together!

The error:

(base) packtpub-downloader-master>python main.py -e email@domain.com -p XXXXXXX -d ~/Desktop/packt -b pdf,epub,mobi,code Error login, check user and password Traceback (most recent call last): File "main.py", line 226, in main(sys.argv[1:]) File "main.py", line 195, in main user = User(email, password) File "C:\Users\Burke\Documents\Python Scripts\packtpub-downloader-master\user.py", line 24, in init self.header["Authorization"] = self.get_token() File "C:\Users\Burke\Documents\Python Scripts\packtpub-downloader-master\user.py", line 39, in get_token print("Error {}".format(e)) NameError: name 'e' is not defined

miguelatpereira commented 3 years ago

Hello! Easy fix for this...

On user.py, replace single quote for double quote on line 32 concerning the username and password parameters.

Some validators tolerate the use single quotes but it is considered that double quotes is the correct wrapper for parameters names and strings...

ckykenken commented 3 years ago

Hello! Easy fix for this...

On user.py, replace single quote for double quote on line 32 concerning the username and password parameters.

Some validators tolerate the use single quotes but it is considered that double quotes is the correct wrapper for parameters names and strings...

Tried, but not working The script was working yesterday, but not today

farzadso commented 3 years ago

This happens every once in a while. Just try again tomorrow.

lpalli commented 3 years ago

Apparently Packt has changed the login service, the JSON request need also a recaptcha element.

Making the login from the website, intercepting the https://services.packtpub.com/auth-v1/users/tokens response and adding the data.access value manually in the get_token function from user.py allow to use packtpub-downloader until the token still valid.

crodgersfl commented 2 years ago

As of 2022-02-04, this code works without login issues. I was able to download pdf, mobi, epub, and code (.zip) for over 300 books. There were a few random errors over time (it takes a while to download 46GB of files for 350+ books), but I eventually got through it.

ibehnam commented 1 year ago

had to remove some special characters in my password. No need to put username and password in quotation marks. Worked for me.