Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem dowloading #17

Open
learning-123 opened this issue Jul 21, 2019 · 9 comments
Open

problem dowloading #17

learning-123 opened this issue Jul 21, 2019 · 9 comments

Comments

@learning-123
Copy link

I get the following error.
Traceback (most recent call last):
File "main.py", line 227, in
main(sys.argv[1:])
File "main.py", line 199, in main
books = get_books(user, is_verbose=verbose, is_quiet=quiet)
File "main.py", line 41, in get_books
print(f'You have {str(r.json()["count"])} books')
KeyError: 'count'
Can anyone please tell me how exactly it should be done. i.e.
python main.py -e email -p password -d ~/Desktop/packt -b pdf
What should be after -b, is it file name or just pdf.

@lmbringas
Copy link
Owner

Hey, after -b should write file type that you want to download, i.e. pdf, epub etc. I don't know why you get this the error. I'll check if packtpub changed anything in his api and maybe next week I'll fix.

@learning-123
Copy link
Author

so if I need a file called excel.pdf, I should write excel.pdf at the end or just pdf in general.

@0xKiewicz
Copy link

hi, it's not working, i guess something changed in the API as you say.

@BurnhamG
Copy link
Contributor

@learning-123 You should be able to just use "pdf" after the -b option.

@0xKiewicz What options are you using (please make sure to exclude your username and password)? I haven't found any problems downloading, so there may be a bug here.

@0xKiewicz
Copy link

0xKiewicz commented Aug 14, 2019

Hi @BurnhamG , I'm using:
python3 main.py -e [email protected] -p xxxxxxxxxx -d ~/Desktop/packt -b pdf -v

Book is already in "saved titles", and i get this error:

You are in!
Traceback (most recent call last):
File "main.py", line 226, in
main(sys.argv[1:])
File "main.py", line 198, in main
books = get_books(user, is_verbose=verbose, is_quiet=quiet)
File "main.py", line 41, in get_books
print(f'You have {str(r.json()["count"])} books')
KeyError: 'count'

@BurnhamG
Copy link
Contributor

Thanks, @0xKiewicz! It seems like there's some problem or change in the response from the server. I'd say you should try editing the main.py file, and inserting this above line 41 in the file:

print(str(r.json())

Then run the same command, copy what that returns for you, and paste it here. Thanks again, I hope we can get this resolved for you.

@0xKiewicz
Copy link

You are in!
{'message': 'User ID d343422-05bd-40b9-n76f-nh4gdhh42 does not own product', 'errorCode': 4000031, 'errorId': 'aa4f1997-5a60-4622-b606-21bdfaaca2da'}
Getting list of books...
Traceback (most recent call last):
File "main.py", line 226, in
main(sys.argv[1:])
File "main.py", line 198, in main
books = get_books(user, is_verbose=verbose, is_quiet=quiet)
File "main.py", line 45, in get_books
pages_list = trange(r.json()['count'] // limit, unit='Pages')
KeyError: 'count'

@BurnhamG
Copy link
Contributor

@0xKiewicz That's an odd error, and unfortunately there's not much there to tell us why the API returns that error. The only thing I can think of that might cause that error is logging in with an account that doesn't have any purchased or claimed products, but if your account does have claimed products then I'm not sure what the problem is. I haven't been able to replicate it on my end either, unfortunately.

@BurnhamG
Copy link
Contributor

Hi @0xKiewicz and @learning-123, I haven't given up on trying to have the program handle this. Thank you both for your patience.

Here's the info from this comment:

Below are links to a version that is this repo's master branch with slight changes to address these problems, as well as a version that includes parallel downloading (from PR #18).

Current master with patch:
https://github.com/BurnhamG/packtpub-downloader/tree/error_fix

Patch with parallel downloads:
https://github.com/BurnhamG/packtpub-downloader/tree/async

Let me know whether these seem to help, or if you're still seeing the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants