OwenTruong / civitdl

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

bug: api-key argument not working (temp fix) #78

Closed kurayamiblackheart closed 5 months ago

kurayamiblackheart commented 5 months ago

the key argument does not accept input, and force to terminate the program with CTRL+C. trying to paste, or type anything while it asks for the key does not work, it also does not seem to accept the key given during the command line call (in arguments).

OwenTruong commented 5 months ago

I fixed an issue (not sure if it is related to this one) with the api-key will ask for api-key args on civitdl that was affecting all OS.

For some reason, api-key is not working for a different reason on Windows. Will need to keep investigating.

OwenTruong commented 5 months ago

I tried to figure out what the issue was and managed to pin point to one of python's package, "getpass". For some reason it is not working on Windows. I will need to investigate some more later, but for now, a temporary solution is to use api-key as as an argument:

civitdl 123456 ./models --api-key MyKeyHere (Note I recommend running civitconfig default --api-key MyKeyHere instead so you don't have to put in an api key every single time.)

Please run pip install civitdl --upgrade for the latest changes.

Also I have noticed that the models that previously didn't need an api key requires one now... strange.

kurayamiblackheart commented 5 months ago

I believe that civitai forces people to use API keys now, as the old civitdl from a few days ago (v1 I believe) simply stopped working 10 hours ago.

I wasn't able to run "make" on windows to re-build the project, so I added a "no-model" bool argument myself (to just download .json and images, not the models), and ran it without re-building it (just messed with the .py scripts). I know that "make" is linux-based, but even when downloading a windows-version of "make" it just threw errors so I gave up

also on python there's already a way to let users input text, without the need of an external module, it's called input("")

OwenTruong commented 5 months ago

I... should probably remove make soon 😂. Not the best for being OS independent.

But if you would like to build it locally instead of installing from pypi, you could try the following:

git pull
git checkout master
pip install --upgrade .

(btw new option is called without-model, I will add it to doc later. I called it that since we already have a with-prompt option, and I am planning on adding metadata and etc. to opt out of downloading, so maybe without-metadata) And thanks, I will try to change program to use input("") instead of getpass 🙂

OwenTruong commented 5 months ago

Hey! Wasn't able to figure out how to use input() while hiding the key so I decided to create a second function to handle the Windows issue using msvcrt package. I tested it in my Windows VM and it seems to work. Please try it too on your side.

git pull
git checkout master # same code on master and development, or you can install the latest on pypi
pip install --upgrade .