From e819dbe1370faaf9758c9d71def6d47ff6dd881d Mon Sep 17 00:00:00 2001 From: midcoastal Date: Wed, 3 May 2023 11:44:03 -0400 Subject: [PATCH] Fetch the 'parent' information Allows us to track Tags, as well as the propper description, since CivitAI doesn't seem to want to roll it overto the Version API... --- scripts/ch_lib/civitai.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/ch_lib/civitai.py b/scripts/ch_lib/civitai.py index 2a15ae7..fef414c 100644 --- a/scripts/ch_lib/civitai.py +++ b/scripts/ch_lib/civitai.py @@ -70,12 +70,25 @@ def get_model_info_by_hash(hash:str): util.printD("error, content from civitai is None") return + util.printD("Fetching Parent Model Information") + parent_model = get_model_info_by_id(content['modelId']) + + # this is VERY un-safe, as CivitAI returns full HTML in this, and the + # version's, description, but we haven't been filtering it so far, so + # I guess we'll get to it later... + content['model']['description'] = parent_model['description'] + content['model']['tags'] = parent_model['tags'] + content['model']['allowNoCredit'] = parent_model['allowNoCredit'] + content['model']['allowCommercialUse'] = parent_model['allowCommercialUse'] + content['model']['allowDerivatives'] = parent_model['allowDerivatives'] + content['model']['allowDifferentLicense'] = parent_model['allowDifferentLicense'] + return content def get_model_info_by_id(id:str) -> dict: - util.printD("Request model info from civitai") + util.printD("Request model info from civitai: "+str(id)) if not id: util.printD("id is empty")