v1.6.3
parent
b3af55204f
commit
abfa9e9635
|
|
@ -230,6 +230,9 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl
|
||||||
|
|
||||||
|
|
||||||
# Change Log
|
# Change Log
|
||||||
|
## v1.6.3
|
||||||
|
* Support downloading multiple files, not avaiable when checking new version.
|
||||||
|
|
||||||
## v1.6.2.1
|
## v1.6.2.1
|
||||||
* when parsing civitai url, remove query string by PR
|
* when parsing civitai url, remove query string by PR
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,48 @@ def get_model_info_by_url(model_url_or_id:str) -> tuple:
|
||||||
|
|
||||||
return (model_info, model_name, model_type, subfolders, version_strs)
|
return (model_info, model_name, model_type, subfolders, version_strs)
|
||||||
|
|
||||||
|
# get version info by version string
|
||||||
|
def get_ver_info_by_ver_str(version_str:str, model_info:dict) -> dict:
|
||||||
|
if not version_str:
|
||||||
|
util.printD("version_str is empty")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not model_info:
|
||||||
|
util.printD("model_info is None")
|
||||||
|
return
|
||||||
|
|
||||||
|
# get version list
|
||||||
|
if "modelVersions" not in model_info.keys():
|
||||||
|
util.printD("modelVersions is not in model_info")
|
||||||
|
return
|
||||||
|
|
||||||
|
modelVersions = model_info["modelVersions"]
|
||||||
|
if not modelVersions:
|
||||||
|
util.printD("modelVersions is Empty")
|
||||||
|
return
|
||||||
|
|
||||||
|
# find version by version_str
|
||||||
|
version = None
|
||||||
|
for ver in modelVersions:
|
||||||
|
# version name can not be used as id
|
||||||
|
# version id is not readable
|
||||||
|
# so , we use name_id as version string
|
||||||
|
ver_str = ver["name"]+"_"+str(ver["id"])
|
||||||
|
if ver_str == version_str:
|
||||||
|
# find version
|
||||||
|
version = ver
|
||||||
|
|
||||||
|
if not version:
|
||||||
|
util.printD("can not find version by version string: " + version_str)
|
||||||
|
return
|
||||||
|
|
||||||
|
# get version id
|
||||||
|
if "id" not in version.keys():
|
||||||
|
util.printD("this version has no id")
|
||||||
|
return
|
||||||
|
|
||||||
|
return version
|
||||||
|
|
||||||
|
|
||||||
# get download url from model info by version string
|
# get download url from model info by version string
|
||||||
# return - (version_id, download_url)
|
# return - (version_id, download_url)
|
||||||
|
|
@ -387,24 +429,28 @@ def dl_model_by_input(model_info:dict, model_type:str, subfolder_str:str, versio
|
||||||
util.printD(output)
|
util.printD(output)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# get download url
|
# get version info
|
||||||
r = get_id_and_dl_url_by_version_str(version_str, model_info)
|
ver_info = get_ver_info_by_ver_str(version_str, model_info)
|
||||||
if not r:
|
if not ver_info:
|
||||||
output = "Fail to get download url, check console log for detail"
|
output = "Fail to get version info, check console log for detail"
|
||||||
util.printD(output)
|
util.printD(output)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
version_id, url = r
|
version_id = ver_info["id"]
|
||||||
if not version_id:
|
|
||||||
output = "Fail to get version id, check console log for detail"
|
# get all download url from files info
|
||||||
util.printD(output)
|
# some model versions have multiple files
|
||||||
return output
|
download_urls = []
|
||||||
|
if "files" in ver_info.keys():
|
||||||
|
for file_info in ver_info["files"]:
|
||||||
|
if "downloadUrl" in file_info.keys():
|
||||||
|
download_urls.append(file_info["downloadUrl"])
|
||||||
|
|
||||||
|
if not len(download_urls):
|
||||||
|
if "downloadUrl" in ver_info.keys():
|
||||||
|
download_urls.append(ver_info["downloadUrl"])
|
||||||
|
|
||||||
|
|
||||||
if not url:
|
|
||||||
output = "Fail to get download url, check console log for detail"
|
|
||||||
util.printD(output)
|
|
||||||
return output
|
|
||||||
|
|
||||||
# check if this model is already existed
|
# check if this model is already existed
|
||||||
r = civitai.search_local_model_info_by_version_id(model_folder, version_id)
|
r = civitai.search_local_model_info_by_version_id(model_folder, version_id)
|
||||||
if r:
|
if r:
|
||||||
|
|
@ -413,11 +459,19 @@ def dl_model_by_input(model_info:dict, model_type:str, subfolder_str:str, versio
|
||||||
return output
|
return output
|
||||||
|
|
||||||
# download
|
# download
|
||||||
filepath = downloader.dl(url, model_folder, None, None)
|
filepath = ""
|
||||||
|
for url in download_urls:
|
||||||
|
model_filepath = downloader.dl(url, model_folder, None, None)
|
||||||
|
if not model_filepath:
|
||||||
|
output = "Downloading failed, check console log for detail"
|
||||||
|
util.printD(output)
|
||||||
|
return output
|
||||||
|
|
||||||
|
if url == ver_info["downloadUrl"]:
|
||||||
|
filepath = model_filepath
|
||||||
|
|
||||||
if not filepath:
|
if not filepath:
|
||||||
output = "Downloading failed, check console log for detail"
|
filepath = model_filepath
|
||||||
util.printD(output)
|
|
||||||
return output
|
|
||||||
|
|
||||||
# get version info
|
# get version info
|
||||||
version_info = civitai.get_version_info_by_version_id(version_id)
|
version_info = civitai.get_version_info_by_version_id(version_id)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue