packtpub-downloader icon indicating copy to clipboard operation
packtpub-downloader copied to clipboard

NameError: name 'e' is not defined

Open burkesquires opened this issue 2 years ago • 6 comments

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 protected] -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

burkesquires avatar Aug 13 '21 11:08 burkesquires

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...

miguelatpereira avatar Sep 15 '21 10:09 miguelatpereira

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

ckykenken avatar Oct 03 '21 06:10 ckykenken

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

farzadso avatar Oct 11 '21 05:10 farzadso

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.

lpalli avatar Nov 13 '21 07:11 lpalli

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.

crodgersfl avatar Feb 05 '22 19:02 crodgersfl

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

ibehnam avatar Jan 23 '23 20:01 ibehnam