Lofter1 / anyflip-downloader

Download anyflip books as PDF
GNU General Public License v3.0
226 stars 38 forks source link

Fails If Title Name Has Characters that Can't Be Used in Filename #67

Open YisroelTech opened 1 month ago

YisroelTech commented 1 month ago

When downloading a book with a title that has characters that aren't allowed in a filename (and not specifying a new title with -title) the process fails:

Preparing to download
https://anyflip.com/t---m/s--t
Downloading 100% |█████████████████████████████████████████████████████████████████████████████████████████| (100/100)
Converting to pdf
2024/09/25 12:07:55 open גליון 2 | טעסט.pdf: The filename, directory name, or volume label syntax is incorrect.

Can it be added to the script to sanitize the title to delete/replace all characters not allowed in a filename?

The characters (at least on Windows) include:

/ (forward slash)
< (less than)
> (greater than)
: (colon - sometimes works, but is actually NTFS Alternate Data Streams)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
YisroelTech commented 1 month ago

I actually notice now that the getBookTitle function seems to already be doing that for the \. Can the rest be added?

https://github.com/Lofter1/anyflip-downloader/blob/8a10cf74e6e7c7a92c4a19d621cb3ab5aa8f4ea5/configjs.go#L29-L43