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

Add support for downloading book from book id #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

levirs565
Copy link

I've made these modifications, because the book that I bought was very much and i don't need to download all the books

Thanks for this great tool!

@blackout314
Copy link

where u find id of book?

@levirs565
Copy link
Author

levirs565 commented Jun 11, 2019

I ussually finding my owned product id by visiting Owned | Packt Subscription. Then i click View Details for product that i will download.

gambar

Then you're linked to product detail. The product id is located at the end of url, eg, https://subscription.packtpub.com/book/big_data_and_business_intelligence/9781788473040 have id 9781788473040

@blackout314
Copy link

thanks

@Letouane
Copy link

Thank you for that upgrade, this way I don't have to download all the books after every new book I claim.

@Letouane
Copy link

Letouane commented Oct 5, 2020

Good day,
This weekend something has changed on the packt web API. When I use the -i argument I have the following error (seems that it works without -i) :

ERROR (please copy and paste in the issue)
Traceback (most recent call last):
  File "main.py", line 337, in <module>
    main(sys.argv[1:])
  File "main.py", line 333, in main
    separate, root_directory, verbose, quiet)
  File "main.py", line 218, in downlaod_all_books
    user, book, file_type, separate, root_directory, verbose)
  File "main.py", line 198, in download_book_by_type
    url = get_url_book(user, book['productId'], file_type)
  File "main.py", line 108, in get_url_book
    tqdm.write(r.json())
  File "C:\Users\letouane\AppData\Local\Programs\Python\Python37\lib\site-packages\tqdm\_tqdm.py", line 517, in write
    fp.write(s)
TypeError: write() argument must be str, not dict

Obviously I'm not complaining about the current bug, but only want to share the current result. I'll try to solve it when I have time, it doesn't seem to be be that complex.

@Letouane
Copy link

Letouane commented Oct 5, 2020

Nevermind, it seems to be related to the right to access a book which is bugged for some FreeLearning content.
Dumping the r.json of line 108 returns :
{'data': 'https:// [...] } when you have the right to download and,
{'message': 'User [user id] is not entitled to access the content [book id]', 'errorCode': [...], 'errorId': '[...]'} when you don't have the right to download.

I'll give a look at handling that error.

.sonarlint

# Downloaded Media
media/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can erase this part, because this is a really good option and i really want to use it. Thanks both!

@Rewonka
Copy link

Rewonka commented Feb 25, 2023

Good day, This weekend something has changed on the packt web API. When I use the -i argument I have the following error (seems that it works without -i) :

ERROR (please copy and paste in the issue)
Traceback (most recent call last):
  File "main.py", line 337, in <module>
    main(sys.argv[1:])
  File "main.py", line 333, in main
    separate, root_directory, verbose, quiet)
  File "main.py", line 218, in downlaod_all_books
    user, book, file_type, separate, root_directory, verbose)
  File "main.py", line 198, in download_book_by_type
    url = get_url_book(user, book['productId'], file_type)
  File "main.py", line 108, in get_url_book
    tqdm.write(r.json())
  File "C:\Users\letouane\AppData\Local\Programs\Python\Python37\lib\site-packages\tqdm\_tqdm.py", line 517, in write
    fp.write(s)
TypeError: write() argument must be str, not dict

Obviously I'm not complaining about the current bug, but only want to share the current result. I'll try to solve it when I have time, it doesn't seem to be be that complex.

First you should click "Access eBook now" and read some page online at free-learning, after that you will have the rights to download with script. I tried and it worked :)

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

Successfully merging this pull request may close these issues.

5 participants