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

books can't be downloaded if the filename contains symbol <?> #34

Open reason195 opened 4 years ago

reason195 commented 4 years ago

Starting to download G:\packt/AWS_CertifiedDeveloper???_AssociateGuide-_Second_Edition.epub Traceback (most recent call last): File "G:\packtpub-downloader-master\main.py", line 226, in main(sys.argv[1:]) File "G:\packtpub-downloader-master\main.py", line 218, in main download_book(filename, url) File "G:\packtpub-downloader-master\main.py", line 103, in download_book with open(filename, 'wb') as f: OSError: [Errno 22] Invalid argument: 'G:\packt/AWS_CertifiedDeveloper???_AssociateGuide-_Second_Edition.epub'

pablodelflo commented 3 years ago

Hello @reason195 @lmbringas .

I found a workarround for this issue. You have to edit the main.py file on line 209.

Originally we have:

book_name = book['productName'].replace(' ', '_').replace('.', '_').replace(':', '_').replace('/','')

Change it to:

book_name = book['productName'].replace(' ', '_').replace('.', '_').replace(':', '_').replace('/','').replace('?','')