Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
stashapp fixes
  • Loading branch information
michal-repo committed Nov 28, 2023
1 parent 3f82366 commit 02ace8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 61 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

95 changes: 35 additions & 60 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function init() {
"Content-Type": "application/json",
},
body: JSON.stringify({
query: "{ allScenes {title file_mod_time files {width height} paths { screenshot stream } studio { id name } tags { id name } } }",
query: "{ allScenes {id title file_mod_time files {width height} paths { screenshot stream } studio { id name } tags { id name } } }",
}),
}
)
Expand All @@ -566,67 +566,42 @@ function processStashAppData(json) {
let preparedJson = { videos: [] };
let folders = [];
json.data.allScenes.forEach((scene) => {
if (
scene.tags.filter((obj) => {
if (
obj.name === "VR" ||
obj.name === "SBS" ||
obj.name === "TB" ||
obj.name === "SCREEN"
) {
return true;
} else {
return false;
}
})
) {
let screen_type = "sbs";
scene.tags.forEach((tag) => {
switch (tag.name) {
case "SBS":
screen_type = "sbs";
break;
case "TB":
screen_type = "tb";
break;
case "SCREEN":
screen_type = "screen";
break;
}
});
let epoch = Date.parse(scene.file_mod_time);
if (preparedJson.videos[folders[scene.studio.name] - 1]) {
preparedJson.videos[folders[scene.studio.name] - 1].list.push(
new VideoEntry(
scene.title,
scene.paths.stream,
scene.paths.screenshot,
screen_type,
scene.files[0].height,
scene.files[0].width,
scene.file_mod_time,
epoch
)
);
} else {
folders.push(scene.studio.name);
folders[scene.studio.name] = preparedJson.videos.push(
new FolderEntry(scene.studio.name)
);
preparedJson.videos[folders[scene.studio.name] - 1].list.push(
new VideoEntry(
scene.title,
scene.paths.stream,
scene.paths.screenshot,
screen_type,
scene.files[0].height,
scene.files[0].width,
scene.file_mod_time,
epoch
)
);
let screen_type = "screen";
scene.tags.forEach((tag) => {
switch (tag.name) {
case "SBS":
screen_type = "sbs";
break;
case "TB":
screen_type = "tb";
break;
case "SCREEN":
screen_type = "screen";
break;
}
});
let epoch = Date.parse(scene.file_mod_time);
if (scene.studio === null) {
scene.studio = { name: "MAIN" };
}
if (!(preparedJson.videos[folders[scene.studio.name] - 1])) {
folders.push(scene.studio.name);
folders[scene.studio.name] = preparedJson.videos.push(
new FolderEntry(scene.studio.name)
);
}
preparedJson.videos[folders[scene.studio.name] - 1].list.push(
new VideoEntry(
scene.title != "" ? scene.title : scene.id,
scene.paths.stream,
scene.paths.screenshot,
screen_type,
scene.files[0].height,
scene.files[0].width,
scene.file_mod_time,
epoch
)
);
});
return preparedJson;
}
Expand Down

0 comments on commit 02ace8f

Please sign in to comment.