mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add management of live2d model in assets folder.
This commit is contained in:
@@ -66,6 +66,26 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
for (const folder of folders) {
|
for (const folder of folders) {
|
||||||
if (folder == "temp")
|
if (folder == "temp")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Live2d assets
|
||||||
|
if (folder == "live2d") {
|
||||||
|
output[folder] = [];
|
||||||
|
const live2d_folders = fs.readdirSync(path.join(folderPath, folder));
|
||||||
|
for (let model_folder of live2d_folders) {
|
||||||
|
const live2d_model_path = path.join(folderPath, folder, model_folder);
|
||||||
|
if (fs.statSync(live2d_model_path).isDirectory()) {
|
||||||
|
for (let file of fs.readdirSync(live2d_model_path)) {
|
||||||
|
if (file.includes("model")) {
|
||||||
|
//console.debug("Asset live2d model found:",file)
|
||||||
|
output[folder].push([`${model_folder}`,path.join("assets", folder, model_folder, file)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other assets (bgm/ambient/blip)
|
||||||
const files = fs.readdirSync(path.join(folderPath, folder))
|
const files = fs.readdirSync(path.join(folderPath, folder))
|
||||||
.filter(filename => {
|
.filter(filename => {
|
||||||
return filename != ".placeholder";
|
return filename != ".placeholder";
|
||||||
@@ -235,7 +255,7 @@ function registerEndpoints(app, jsonParser) {
|
|||||||
const live2dModelPath = path.join(folderPath, modelFolder);
|
const live2dModelPath = path.join(folderPath, modelFolder);
|
||||||
if (fs.statSync(live2dModelPath).isDirectory()) {
|
if (fs.statSync(live2dModelPath).isDirectory()) {
|
||||||
for (let file of fs.readdirSync(live2dModelPath)) {
|
for (let file of fs.readdirSync(live2dModelPath)) {
|
||||||
console.debug(file)
|
//console.debug("Character live2d model found:", file)
|
||||||
if (file.includes("model"))
|
if (file.includes("model"))
|
||||||
output.push([`${modelFolder}`,`/characters/${name}/${category}/${modelFolder}/${file}`]);
|
output.push([`${modelFolder}`,`/characters/${name}/${category}/${modelFolder}/${file}`]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user