Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Maisonave committed Nov 28, 2024
2 parents fdb786e + 512fbb8 commit 46edadd
Show file tree
Hide file tree
Showing 9 changed files with 427 additions and 711 deletions.
20 changes: 20 additions & 0 deletions plugins/CommunityScriptsUILibrary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ All the following functions are exposed under `window.csLib` and `csLib`
*/
```

## setConfiguration
```js
/**
* Set configuration of a plugin in the server via GraphQL
* @param {string} pluginId - The ID of the plugin as it is registered in the server
* @param {*} values - The configuration object with the values you want to save in the server
* @returns {Object} - The configuration object of the plugin as it is stored in the server after update
*
* @example
* // fetch config from the server
* const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
* // config = { theme: 'dark' }
* // update the config based on user input
* // config = { theme: 'light' }
* // save config in the server
* await setConfiguration('CommunityScriptsUIPlugin', config);
* }
*/
```

## waitForElement
```js
/**
Expand Down
30 changes: 30 additions & 0 deletions plugins/CommunityScriptsUILibrary/cs-ui-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,35 @@
return response.configuration.plugins?.[pluginId] ?? fallback;
};

/**
* Set configuration of a plugin in the server via GraphQL
* @param {string} pluginId - The ID of the plugin as it is registered in the server
* @param {*} values - The configuration object with the values you want to save in the server
* @returns {Object} - The configuration object of the plugin as it is stored in the server after update
*
* @example
* // fetch config from the server
* const config = await getConfiguration('CommunityScriptsUIPlugin', defaultConfig);
* // config = { theme: 'dark' }
* // update the config based on user input
* // config = { theme: 'light' }
* // save config in the server
* await setConfiguration('CommunityScriptsUIPlugin', config);
* }
*/
const setConfiguration = async (pluginId, values) => {
const query = `mutation ConfigurePlugin($pluginId: ID!, $input: Map!) { configurePlugin(plugin_id: $pluginId, input: $input) }`;
const queryBody = {
query: query,
variables: {
pluginId: pluginId,
input: values,
},
};
const response = await csLib.callGQL({ ...queryBody });
return response.configurePlugin;
};

/**
* Waits for an element to be available in the DOM and runs the callback function once it is
* @param {string} selector - The CSS selector of the element to wait for
Expand Down Expand Up @@ -105,6 +134,7 @@
baseURL,
callGQL,
getConfiguration,
setConfiguration,
waitForElement,
PathElementListener,
};
Expand Down
1,004 changes: 308 additions & 696 deletions plugins/DupFileManager/DupFileManager.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions plugins/DupFileManager/DupFileManager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ version: 1.0.0
url: https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/DupFileManager
ui:
javascript:
- DupFileManager.js
- DupFileManager.js
css:
- DupFileManager.css
- DupFileManager.css.map
- DupFileManager.js.map
- DupFileManager.css
- DupFileManager.css.map
- DupFileManager.js.map
settings:
matchDupDistance:
displayName: Match Duplicate Distance
description: (Default=0) Where 0 = Exact Match, 1 = High Match, 2 = Medium Match, and 3 = Low Match.
description: (Default=0) Where 0 = Exact Match, 1 = High Match, 2 = Medium Match, and 3 = Low Match.
type: NUMBER
mergeDupFilename:
displayName: Merge Duplicate Tags
Expand Down
17 changes: 8 additions & 9 deletions plugins/DupFileManager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It has both **task** and **tools-UI** components.

- Creates a duplicate file report which can be accessed from the settings->tools menu options.The report is created as an HTML file and stored in local path under plugins\DupFileManager\report\DuplicateTagScenes.html.
- See screenshot at the bottom of this page for example report.
- Items on the left side of the report are the primary duplicates designated for deletion. By default, these duplicates are given a special \_duplicate tag.
- Items on the left side of the report are the primary duplicates designated for deletion. By default, these duplicates are given a special _duplicate tag.
- Items on the right side of the report are designated as primary duplicates to keep. They usually have higher resolution, duration and/or preferred paths.
- The report has the following options:
- Delete: Delete file and remove from Stash library.
Expand Down Expand Up @@ -45,11 +45,11 @@ It has both **task** and **tools-UI** components.
- **Delete Duplicates** - Deletes duplicate files. Performs deletion without first tagging.
- Plugin UI options (Settings->Plugins->Plugins->[DupFileManager])
- Has a 3 tier path selection to determine which duplicates to keep, and which should be candidates for deletions.
- **Whitelist** - List of paths NOT to be deleted.
- **Whitelist** - List of paths NOT to be deleted.
- E.g. C:\Favorite\,E:\MustKeep\
- **Gray-List** - List of preferential paths to determine which duplicate should be the primary.
- **Gray-List** - List of preferential paths to determine which duplicate should be the primary.
- E.g. C:\2nd_Favorite\,H:\ShouldKeep\
- **Blacklist** - List of LEAST preferential paths to determine primary candidates for deletion.
- **Blacklist** - List of LEAST preferential paths to determine primary candidates for deletion.
- E.g. C:\Downloads\,F:\DeleteMeFirst\
- **Permanent Delete** - Enable to permanently delete files, instead of moving files to trash can.
- **Max Dup Process** - Use to limit the maximum files to process. Can be used to do a limited test run.
Expand All @@ -61,9 +61,8 @@ It has both **task** and **tools-UI** components.
- **toRecycleBeforeSwap** - When enabled, moves destination file to recycle bin before swapping files.
- **addPrimaryDupPathToDetails** - If enabled, adds the primary duplicate path to the scene detail.
- Tools UI Menu
![Screenshot 2024-11-22 145512](https://github.com/user-attachments/assets/03e166eb-ddaa-4eb8-8160-4c9180ca1323)
![Screenshot 2024-11-22 145512](https://github.com/user-attachments/assets/03e166eb-ddaa-4eb8-8160-4c9180ca1323)
- Can access either **Duplicate File Report (DupFileManager)** or **DupFileManager Tools and Utilities** menu options.

### Requirements

- `pip install --upgrade stashapp-tools`
Expand Down Expand Up @@ -91,9 +90,9 @@ That's it!!!
- ![Screenshot 2024-11-22 225359](https://github.com/user-attachments/assets/dc705b24-e2d7-4663-92fd-1516aa7aacf5)
- If there's a scene on the left side that has a higher resolution or duration, it gets a yellow highlight on the report.
- There's an optional setting that allows both preview videos and preview images to be displayed on the report. See settings **htmlIncludeImagePreview** in the **DupFileManager_report_config.py** file.
- There are many more options available for how the report is created. These options are targeted for more advanced users. The options are all available in the **DupFileManager_report_config.py** file, and the settings have commented descriptions preceeding them. See the **DupFileManager_report_config.py** file in the DupFileManager plugin folder for more details.
- There are many more options available for how the report is created. These options are targeted for more advanced users. The options are all available in the **DupFileManager_report_config.py** file, and the settings have commented descriptions preceeding them. See the **DupFileManager_report_config.py** file in the DupFileManager plugin folder for more details.
- Tools UI Menu
![Screenshot 2024-11-22 145512](https://github.com/user-attachments/assets/03e166eb-ddaa-4eb8-8160-4c9180ca1323)
![Screenshot 2024-11-22 145512](https://github.com/user-attachments/assets/03e166eb-ddaa-4eb8-8160-4c9180ca1323)
- Can access either **Duplicate File Report (DupFileManager)** or **DupFileManager Tools and Utilities** menu options.
- DupFileManager Report Menu
- ![Screenshot 2024-11-22 151630](https://github.com/user-attachments/assets/834ee60f-1a4a-4a3e-bbf7-23aeca2bda1f)
Expand All @@ -103,9 +102,9 @@ That's it!!!
- ![Screenshot 2024-11-22 232208](https://github.com/user-attachments/assets/bf1f3021-3a8c-4875-9737-60ee3d7fe675)

### Future Planned Features

- Add logic to merge performers and galaries seperatly from tag merging on report. Planned for 1.5.0 Version.
- Add code to report to make it when the report updates the screen (due to tag merging), it stays in the same row position. Planned for 1.5.0 Version.
- Add logic to merge group metadata when selecting merge option on report. Planned for 2.0.0 Version.
- Add advanced menu directly to the Settings->Tools menu. Planned for 2.0.0 Version.
- Add report directly to the Settings->Tools menu. Planned for 2.0.0 Version.

5 changes: 5 additions & 0 deletions plugins/scenePageRememberStates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Scene Page Remember States

This plugin uses local storage to rememebr what is the current active nav tab of the scenes' detail panel, and upon any page load activate the last remembered active nav tab.

It also rembers the active collapsed state of the divider button and upon page load if it's true, it will automatically collapse the divider.
39 changes: 39 additions & 0 deletions plugins/scenePageRememberStates/scenePageRememberStates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function sceneDivider(tabs) {
const dividerBtn = document.querySelector(".scene-divider > button");

// check if tab is currently collapsed, and if it should be
const isCollapsed = () => tabs.classList.contains("collapsed");
const storedCollapse =
localStorage.getItem("remember-state-divider") == "true";
// if it should be, but is not, collapse
if (storedCollapse && !isCollapsed()) dividerBtn.click();

// add listener to change desired state based on current collapsed state
dividerBtn.addEventListener("click", () => {
// isCollapsed does not update in time
const newState = !isCollapsed();
localStorage.setItem("remember-state-divider", newState);
});
}

function navTab() {
const detailsNav = document.querySelector(".nav-tabs");

// Check local storage for entries
let activeKey = localStorage.getItem("remember-state-navtab");

// click on desired active key if defined
if (activeKey) {
detailsNav.querySelector(`a[data-rb-event-key="${activeKey}"]`).click();
}

// add event listener
detailsNav.querySelectorAll("a").forEach((href) => {
href.addEventListener("click", function () {
localStorage.setItem("remember-state-navtab", this.dataset.rbEventKey);
});
});
}

csLib.PathElementListener("/scenes/", ".nav-tabs", navTab);
csLib.PathElementListener("/scenes/", ".scene-tabs", sceneDivider);
9 changes: 9 additions & 0 deletions plugins/scenePageRememberStates/scenePageRememberStates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Scene Page Remember States
description: Uses local storage to remember the state of the scene page detail panel nav bar and activate it on page load. Remembers collapse state of the divider.
url:
version: 0.2
ui:
requires:
- CommunityScriptsUILibrary
javascript:
- scenesPageRememberStates.js
4 changes: 3 additions & 1 deletion plugins/timestampTrade/timestampTrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def processSceneTimestamTrade(s):
marker["primary_tag"] = m["name"]

if settings["addTsTradeTitle"]:
marker["title"] = f"[TsTrade] {m["name"]}"
marker["title"] = f"[TsTrade] {m['name']}"

# check for markers with a zero length title, skip adding
if len(marker["primary_tag"]) == 0:
Expand Down Expand Up @@ -1331,7 +1331,9 @@ def excluded_marker_tag(marker):
"submitFunscriptHash": True,
"excludedMarkerWords": "",
"matchFunscripts": True,
"addTsTradeTag": False,
"addTsTradeTitle": False,
"path": "/download_dir/tt-auto"
}
if "timestampTrade" in config["plugins"]:
settings.update(config["plugins"]["timestampTrade"])
Expand Down

0 comments on commit 46edadd

Please sign in to comment.