alexgand / springer_free_books

Python script to download all Springer books released for free during the 2020 COVID-19 quarantine
GNU General Public License v3.0
1.64k stars 366 forks source link

Avoid incomplete downloaded book from being taken as valid one #42

Closed chaosAD closed 4 years ago

chaosAD commented 4 years ago

Instead of downloading a book directly to its folder, the amended script downloads into a temporary file in the tmp folder. If a user hits Ctrl+C or Ctrl+Break, the incomplete book stays in the tmp folder. Otherwise, it will be moved over to the intended folder once the download has completed. The amended script also fixes the EPUB being missed out after Ctrl+C or Ctrl+Break and restarting script. Both code fixes solves #41.

I heavily cleaned up the code to keep it D.R.Y. I also improved on the generation of book name. A book name consists of title + author + edition + isbn. Most books have quite reasonable title lengths, but the length of author names can be very long. A few books breach the filename's 150 characters limit due to that. The new book name generator keeps it to the limit by trying different combinations. For example, if the author names are too lengthy, it will be shorten to only the first author's name, like Dietrich Braun et al..