joaoandre / springer_books_download

This is a script that downloads a list of free springer books that were made available by them during the covid-19 quarantine.
0 stars 1 forks source link

Error in resuming download from a previous interrupted download #5

Closed sglebs closed 4 years ago

sglebs commented 4 years ago
(.env) mqm-Mac-Black:springer_books_download mqm$ date
Sun 19 Apr 2020 22:09:20 -03
(.env) mqm-Mac-Black:springer_books_download mqm$ git pull
Already up to date.
(.env) mqm-Mac-Black:springer_books_download mqm$ python download_books.py
...
...
Ignoring Introduction to Programming with Fortran.pdf. Book already downloaded
Ignoring Fundamentals of Solid State Engineering.pdf. Book already downloaded
Ignoring Introduction to Digital Systems Design.pdf. Book already downloaded
Ignoring Neural Networks and Deep Learning.pdf. Book already downloaded
Ignoring Data Science and Predictive Analytics.pdf. Book already downloaded
Downloading Systems Programming in Unix/Linux by K.C. Wang on URL https://link.springer.com/content/pdf//10.1007/978-3-319-92429-8.pdf
-------------------------------------------------------------------
Traceback (most recent call last):
  File "download_books.py", line 41, in <module>
    open(file_name, "wb").write(f.content)
FileNotFoundError: [Errno 2] No such file or directory: 'Systems Programming in Unix/Linux.pdf'
sglebs commented 4 years ago

I believe these file names nee to be escaped.

sglebs commented 4 years ago

The fix:

    file_name = re.sub ('[<>:"\/\\\|\?\*]', '_' , book['Book Title']) + '.pdf'

And

import re
joaoandre commented 4 years ago

This was fixed in an earlier PR. Thanks for reporting it.