Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions PLUGINS-LIST.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Plugin list

This list keeps track of scripts and plugins in this repository. Please ensure the list is kept in alphabetical order.

## Plugins

Category|Plugin Name|Description|Minimum Stash version
--------|-----------|-----------|---------------------
Scenes|[markerTagToScene](plugins/markerTagToScene)|Adds primary tag of Scene Marker to the Scene on marker create/update.|v0.8 ([46bbede](https://github.com/stashapp/stash/commit/46bbede9a07144797d6f26cf414205b390ca88f9))


## Utility Scripts

Category|Plugin Name|Description|Minimum Stash version
--------|-----------|-----------|---------------------
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CommunityPlugins

This repository contains plugin and utility scripts created by the Stash community.

To download a plugin, either clone the git repo, or download the files directly.

It is recommended that plugins are placed in their own subdirectory of your `plugins` directory. The `plugins` directory should be created as a subdirectory in the directory containing your `config.yml` file. This will be in `$HOME/.stash` by default.

When downloading directly click on the file you want and then make sure to click the raw button:

![](https://user-images.githubusercontent.com/1358708/82524777-cd4cfe80-9afd-11ea-808d-5ea7bf26704f.jpg)

A list of plugins is maintained in [PLUGINS-LIST.md](PLUGINS-LIST.md).
81 changes: 81 additions & 0 deletions plugins/markerTagToScene/markerTagToScene.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
function ok() {
return {
output: "ok"
};
}

function main() {
var hookContext = input.Args.hookContext;
var opInput = hookContext.input;
var primaryTagID = opInput.primary_tag_id;
var sceneID = opInput.scene_id;

// we can't currently find scene markers. If it's not in the input
// then just return
if (!primaryTagID || !sceneID) {
// just return
return ok();
}

// get the existing scene tags
var sceneTags = getSceneTags(sceneID);
var tagIDs = [];
for (var i = 0; i < sceneTags.length; ++i) {
var tagID = sceneTags[i].id;
if (tagID == primaryTagID) {
log.Debug("primary tag already exists on scene");
return;
}

tagIDs.push(tagID);
}

// set the tag on the scene if not present
tagIDs.push(primaryTagID);

setSceneTags(sceneID, tagIDs);
log.Info("added primary tag " + primaryTagID + " to scene " + sceneID);
}

function getSceneTags(sceneID) {
var query = "\
query findScene($id: ID) {\
findScene(id: $id) {\
tags {\
id\
}\
}\
}";

var variables = {
id: sceneID
};

var result = gql.Do(query, variables);
var findScene = result.findScene;
if (findScene) {
return findScene.tags;
}

return [];
}

function setSceneTags(sceneID, tagIDs) {
var mutation = "\
mutation sceneUpdate($input: SceneUpdateInput!) {\
sceneUpdate(input: $input) {\
id\
}\
}";

var variables = {
input: {
id: sceneID,
tag_ids: tagIDs
}
};

gql.Do(mutation, variables);
}

main();
14 changes: 14 additions & 0 deletions plugins/markerTagToScene/markerTagToScene.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# example plugin config
name: Scene Marker Tags to Scene
description: Adds primary tag of Scene Marker to the Scene on marker create/update.
url: https://github.com/stashapp/CommunityScripts
version: 1.0
exec:
- markerTagToScene.js
interface: js
hooks:
- name: Update scene with scene marker tag
description: Adds primary tag of Scene Marker to the Scene on marker create/update.
triggeredBy:
- SceneMarker.Create.Post
- SceneMarker.Update.Post