Skip to content

Add Rating Folders plugin: move scene files to a folder per rating - #820

Open
reeltier wants to merge 1 commit into
stashapp:mainfrom
reeltier:add-rating-folders
Open

reeltier wants to merge 1 commit into
stashapp:mainfrom
reeltier:add-rating-folders

Conversation

@reeltier

Copy link
Copy Markdown

This adds Rating Folders, a plugin that moves a scene's file to a folder you pick for its rating, with optional renaming. For example: 9-10 goes to Top, 7-8 to Keep, 1-4 to Trash.

How it works

  • Hook on Scene.Update.Post. It only acts when rating100 is among the changed fields.
  • Two tasks: "Preview rating folders (dry run)", which never moves anything, and "Apply rating folders to all rated scenes".
  • Moves go through the moveFiles mutation, so Stash keeps tracking the file without a rescan.
  • Optional rename template: {performers} - {studio} - {date} - {title}, plus {year}, {code}, {rating} and {original}. Empty fields are dropped along with their separator.
  • .funscript and subtitle sidecars with the same name move along with the video. A setting turns this off.

Safety

  • Dry run is on by default. The "Move files for real" setting is a BOOLEAN that defaults to off.
  • It never deletes anything and never overwrites a file: on a name clash it adds (2), (3) and so on, and Stash's own existing-file check stays in place as a backstop.
  • It never creates folders. The destination has to exist, be inside a Stash library, not be in a library that excludes video, and not match an exclude pattern.
  • Invalid settings stop it before anything moves. Zip members and missing files are skipped. Re-running it changes nothing.

Dependencies: Python standard library only, so there's nothing to pip install and it doesn't need PythonDepManager.

Testing: 34 automated end-to-end tests run the plugin as Stash does (JSON on stdin, encoded log lines on stderr) against a local mock of the GraphQL endpoints it uses. The mock follows the moveFiles behaviour in resolver_mutation_file.go and pkg/file/move.go.

Testing on a real Stash: I ran it on Stash v0.32.0 for Windows (the official release binary), on a separate test instance bound to 127.0.0.1 with its own config and database, with small generated test videos (no real content), Top/Keep/Trash folders and a .funscript and .srt next to one video. Scripted checks against the real web UI (Playwright) and the GraphQL API covered: stars set on the scene page moving the file (5 stars to Top, 1 star to Trash), a title edit not moving it, dry run (log only), sidecars, a name clash (" (2)"), a missing destination folder (not moved, warning logged), removing a rating, bulkSceneUpdate (the hook fires once per scene), the rename template, the Preview and Apply tasks (a second Apply changed nothing), and a rescan afterwards. This found three issues, now fixed with tests: renamed .srt/.vtt files lost their link in Stash (the plugin now asks Stash to rescan the video and then the subtitles), the preview could announce the same target name for two scenes, and two misleading task log messages.

Human check: I rated a scene with 5 stars in the Stash web UI on that test instance and its file moved from Library\Inbox to Library\Top, with the new path shown in File Info.

Disclosure: I'm the developer of ReelTier (https://reeltier.com), a free Windows app with the same "rate it and it moves" idea for VR players. This plugin doesn't need ReelTier and doesn't talk to it. It was written with the help of an LLM coding assistant. I tested it myself as described above and I take full responsibility for the code, including license compliance, and for maintaining it. It's under the repository's AGPL-3.0 license.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant