OwenTruong / civitdl

A CLI python script to batch download models from CivitAI with CivitAI Api V1
Apache License 2.0
46 stars 6 forks source link

WinErrors when trying to download models with special characters #58

Closed Mystos007 closed 7 months ago

Mystos007 commented 7 months ago

When using the development branch, I am getting WinError issues and they seems to related to illegal filename/folder characters that Windows considers invalid and doesn't allow in file names.

Now downloading "Uzaki Tsuki / Uzaki-chan wa Asobitai!"...
            - Model ID: 250013
            - Version ID: 282137
---------
[WinError 3] The system cannot find the path specified: './models/Anime\\Uzaki Tsuki / Uzaki-chan wa Asobitai!'

Now downloading "Quikantel | Manhwa | Swordmaster's Youngest"...
            - Model ID: 250455
            - Version ID: 282617
---------
[WinError 123] The filename, directory name, or volume label syntax is incorrect: "./models/Anime\\Quikantel | Manhwa | Swordmaster's Youngest"

Now downloading "Irene Honma (本間イレーヌ) - Anohana: The Flower We Saw That Day (あの日見た花の名前を僕達はまだ知らな い。)"...
            - Model ID: 252289
            - Version ID: 284658
---------
[WinError 267] The directory name is invalid: './models/Anime\\Irene Honma (本間イレーヌ) - Anohana: The Flower We Saw That Day (あの日見た花の名前を僕達はまだ知らない。)'

So there is an example of a few of the WinErrors, the main ones are 3, 123, and 267. Everything else works fine, so far the characters seem to be "/" "|" and "\".

And looking up what characters are illegal in Windows gives: https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names

< (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)

I also noticed someone posted a related bug at #56 which is the "/" creating folders on Mac OS.

OwenTruong commented 7 months ago

Thanks for letting me know about this! I will add that to the bugs to fix as soon as possible! A potential solution might be to convert some of them to spaces, or dashes, or remove them depending on which special character it is.

OwenTruong commented 7 months ago

Hi, the latest development branch with version v2.0.0-dev13 now removes/replaces the special characters mentioned in the stack overflow page.