packt-cli / Packt-Publishing-Free-Learning

Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Book downloads should strip leading dot on filename

eharris opened this issue · comments

If a book is downloaded and the title starts with a dot (.) then it no longer gets stripped, which causes the book to be "hidden" insofar as normal unix filenaming conventions.

This is a bug/side effect introduced in version 1.5.1 (checkin baa8d8f) which changed to allow punctuation (including dot) in downloaded filenames.

I have books in my library with titles that start with .Net, which manifests this problem.

That's right, I'd also consider that a bug (it has been caused by python-slugify) upgrade - so what's the expected behaviour? Should we remove the period from the title?

The simplest thing is probably just to remove it or replace it with something else like an underscore. Other alternatives would be to replace it with something that looks similar but doesn't behave as a normal ASCII period, like UTF-8 U+FF0E (FULLWIDTH FULL STOP). Substituting a dash - might be better from a sorting standpoint, since dash and period are immediately adjacent in ASCII, but that would present issues when trying to use/open the files from a command line (requiring the use of a preceeding --).

Personally, I would probably just substitute an underscore _, as that avoids possible character encoding issues on filesystems, and the underscore could easily be thought of as a "wide" dot, while still showing that there is something that should be there.