Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add RENAME button to Scene->Edit #5074

Closed
David-Maisonave opened this issue Jul 14, 2024 · 7 comments
Closed

[Feature] Add RENAME button to Scene->Edit #5074

David-Maisonave opened this issue Jul 14, 2024 · 7 comments

Comments

@David-Maisonave
Copy link

David-Maisonave commented Jul 14, 2024

Is your feature request related to a problem? Please describe.
Version v0.25.1 and v0.26.2
As I'm reviewing a scene, I often see the need to rename the file based on the scene content. If I rename the file directly ( via File-Explorer), Stash has to rescan the path, and I loose any Stash metadata which I may have manually added.

I reviewed issue #3269, which referred to renamerOnUpdate, but I couldn't get it to work. I tried it with version v0.25.1 and v0.26.2.
Moreover, I get the impression that renamerOnUpdate overly complex for the simple option of renaming the specific file being viewed.

Describe the solution you'd like
Add [Rename] button next to the [Save] [Delete] button on the Scene-Edit dialog. I would think this would be easy to implement, sense there's already a Delete and Save option, and it looks like some of the code already exist in Stash_Sqlite_Renamer.py.

Describe alternatives you've considered
Alternative (1)
Rename file manually ( via File-Explorer), edit Sqlite directly using Sqlite-Editor.

Alternative (2)
Get renamerOnUpdate to work or fix it so that it works with v0.26.2, and see if option can be added for Rename button.

Alternative (3)
Try to use Stash_Sqlite_Renamer.py. But this seems to be a lot of work to perform every time the user wants to rename a single file. IMHO, alternative (1) is simpler.

Additional context
Add_Rename_Button

Implementation
I'm a season C++ programmer, and I wouldn't mind making the changes myself. However I looked to see if I could make these changes by looking for the onSave and onDelete, but it wasn't clear to me where to find the code. The GO format and syntax turn out to be harder to read than I thought.

I found onSave function in stash\ui\v2.5\src\components\Scenes\EditScenesDialog.tsx. But I'm not positive if that would be the correct starting point to make this change.

Could someone please give me some pointers as to where to add the OnRenameFile function and image?

Thanks

@DogmaDragon
Copy link
Collaborator

At the moment, Stash doesn't touch files on purpose and that functionality is covered by plugins.

If I rename the file directly ( via File-Explorer), Stash has to rescan the path, and I loose any Stash metadata which I may have manually added.

Re-scan should just remap the file to the correct path, and all the Stash metadata should still be there. Are you also embedding the metadata and not just renaming the file? That would change the hash. Stash keeps track of files by hash and path. You can change one of them and Stash will be able to successfully find the file, but if both gets changed, Stash will see it as a new file.

There is also https://github.com/Serechops/Serechops-Stash/tree/main/plugins/Renamer which might be easier to set up compared to https://github.com/stashapp/CommunityScripts/tree/main/plugins/renamerOnUpdate.

renamerOnUpdate should work. Tested up to v0.26.2 on Windows.

@David-Maisonave
Copy link
Author

That would change the hash. Stash keeps track of files by hash and path.

I didn't realized it used the hash to keep track of the file in case of rename.
However, there's still problems with that approach. 1st user has to go to fileinfo tab to copy and paste the path, and access it in file explorer. If the user is watching the video at the time, renaming the file is blocked, so the user has to refresh the URL in-order to unlock the file.
At that time, the file can be renamed, however, after renaming the file, it can no longer be played, until a re-scan is performed.

It would be far better if the user can renamed the file on the fly, and be able to make multiple changes while reviewing a video without having to continuously perform a rescan.

https://github.com/Serechops/Serechops-Stash/tree/main/plugins/Renamer

That plugin is not listed in the official or unofficial list. Is there another list of plugins?

The Renamer plugin seems to be similar to the renamerOnUpdate in that it seams to be made for pattern changes, instead of a feature to just change a single file on the fly.

At the moment, Stash doesn't touch files on purpose and that functionality is covered by plugins.

I would agree with that if Stash didn't have a [Delete] button, which is the most harm you can do to a file. If it has a delete function, then it should be able to support a rename function.

Am I able to add a button next to the [Delete] button by creating a plugin?
If so, am I correct in assuming I would have to create an Embedded Plugin in order to do this, or would an External Plugin be the correct approach?
Can a plugin stop the scene being played on the same page?

Any help you can give me to implement this would be appreciated.
Thank you

@echo6ix
Copy link
Contributor

echo6ix commented Jul 20, 2024

If the user is watching the video at the time, renaming the file is blocked, so the user has to refresh the URL in-order to unlock the file.

I've never experienced issues renaming or moving a file that was simultaneously playing, other than the video eventually stops playing of course. Just tested this in fact to verify, no issues (stash-linux).

@David-Maisonave
Copy link
Author

I've never experienced issues renaming or moving a file

This is easy to reproduce on Windows 11 (x64). It even happen when I was using the Renamer plugin.

Here's what I got from the renamer.log file:
2024-07-19 13:00:45,898 - Failed to rename file: B:\V\V\1\VideoTestFile.mp4. Error: [WinError 32] The process cannot access the file because it is being used by another process:

New Plugin [RenameFileName]

I'm happy to say, I've been able to modify the Renamer plugin, and I'm able to get it to do most of what I was looking for.
I'm creating a new plugin based on it.

By default the new plugin does the following:

  1. Renames the file in the following format {title}-{tags}.ext.
  2. If the title field is empty, it will use the original file name.
  3. It only adds tags which do not already exist in the original file name.
  4. The user will be able to change how it works from the settings file.

If a user wants to rename the file, they only have to populate the title field with the desired new name.

This plugin will still have the problem with renaming a file while the user is playing it. I'll have to check if moving the file creates the same issue as renaming it.

@David-Maisonave
Copy link
Author

I've finished with the RenameFile plugin, and I would like to add it to the Community Scripts.

Do you have any issues with adding RenameFile to the Community Scripts list?
See following link to read what it does, and usage.
https://github.com/David-Maisonave/Axter-Stash/tree/main/plugins/RenameFile

To add it, do I have to create a new repository based on https://github.com/stashapp/CommunityScripts?
Or do you have another method to allow users to add to the list?

@DogmaDragon
Copy link
Collaborator

DogmaDragon commented Jul 22, 2024

@David-Maisonave added stashapp/CommunityScripts#369.

Generally, submitting via PR from the fork is easiest.

@David-Maisonave
Copy link
Author

Closing feature request since it's been largely accomplish using plugin RenameFile.

Thanks for the help in creating the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants