stashapp / CommunityScripts

This is a public repository containing plugin and utility scripts created by the Stash Community.
https://docs.stashapp.cc/add-ons/
GNU Affero General Public License v3.0
191 stars 147 forks source link

[Feature] Locate file in explorer #465

Open deliciousnights opened 3 years ago

deliciousnights commented 3 years ago

Often when finding a scene in Stash I want to locate it in the File explorer, to either move it or rename it, or even just open it with my player of choice. It would be very convenient to have this option directly in the scene list and in the scene details.

Describe the solution you'd like A button or a link in scene list/details to open the containing directory (and select the corresponding file). Something like: image

Describe alternatives you've considered Atm I have to check the file path and then navigate to it manually in the file manager. Which takes much longer than the proposed solution. And this works only from scene details, not from the scene list.

...

One step beyond would be to have the file rename option in Stash itself. But just opening the manager would be already a great help.

gitgiggety commented 3 years ago

Webbrowsers don't allow opening local directories, in the file explorer of the OS.

Furthermore Stash might not run on the same computer as that the user is using (I myself run stash on my homeserver) so the paths would also be incorrect.

So even if a workaround is possible (i.e.: letting the Stash backend start the file explorer, which already would be hard because of different OSes, possibly running in Docker, ...) it won't really work in any scenario where Stash is running on a different system.

deliciousnights commented 3 years ago

Could it be a plugin? If the plugins are allowed to run code on the server, it could open the file manager, if certain conditions are met.

alexhk commented 3 years ago

There already is a link to the file in the file info view. If you use Firefox and install this addon and you run Stash on your workstation you should be able to open the file via click.

2021-06-09_11h28_45

deliciousnights commented 3 years ago

Thanks for the tip, the extension works well! Would be even better if the context menu feature was actually implemented (to use it in the scene list with the tagger view - there the full path is visible), but it's already a great improvement.

For me this solves the issue, albeit by installing extra software. Feel free to close it if you feel Stash doesn't need to add anything here.

Actually the extension doesn't work reliably - sometimes it opens the folder three times instead of one, sometimes it doesn't open it at all. Last commit in its repo is over a year old, while these issues are open and even advertised features don't exist... :/

jeremymeyers commented 3 years ago

Perhaps an option or changing the default display to be the full path of the file rather than an abbreviated version? that would make it a simpler task to copy the directory to the clipboard?

jennygreene88 commented 3 years ago

I've rigged up a little solution to play the files in a native local player even when Stash is running on a different machine. I think it's the simplest working solution possible given the limitations. I:

  1. Modified the Scene and SceneCard components in the UI so that they have an extra Play button.
  2. Had that play button write the stream URI (e.g. http://192.168.1.103:9930/scene/13323/stream?apikey=foo) to the clipboard when clicked.
  3. Run a very short Python script on the client that watches the clipboard for stream URIs and invokes MPV to play them when they appear.

That script is super simple and short:

import re
import subprocess

import pyperclip

while True:
    text = pyperclip.waitForNewPaste()
    if re.match(r"http://[^/]+/scene/\d+/stream", text):
        subprocess.run([r"c:\apps\mpv\mpv.exe", text])

Now I'm happily streaming videos from the remote Stash server using my preferred native video player with a single click.

I think "Show 'Copy URI' button" would make for a good opt-in config option, to enable things like this. Including the separate program to play those URIs is probably outside the scope of the project, and unnecessary, but having the option to show these copy-URI buttons would be helpful.

I'm actually not sure to what extent the Stash plugin system could help, the links to the info pages about them were dead when I went to read up so I just modified the UI components directly.

cseverino commented 3 years ago

Part of the problem is that the "path" variable doesn't have a "/" after the drive letter so using the Local Filesystem Links extension doesn't work.

For example, my path is showing as: file://e:Porn-PC3\Movies Porn_ExternalHD2\movie.mp4

when it should be: file://e:\Porn-PC3\Movies Porn_ExternalHD2\movie.mp4 with the \ after the e:

Is there a way to modify the path so that it includes the \ when accessed through the File Info tab?

cseverino commented 3 years ago

My issue appears to be fixed in the latest developer release. The path now has the "/" after the driver letter on newly scanned files. I'll rescan my older files later and see if their paths get updated. This change means that using the Local Filesystem Links extension now works for opening files on your local system.

::: Fix links and styling of File Info tabs stashapp/stash#1622 See release# v0.8.0-35-g7b3b2ae9: Latest development build

laurus-lx commented 3 years ago

@jennygreene88

I've rigged up a little solution to play the files in a native local player even when Stash is running on a different machine. I think it's the simplest working solution possible given the limitations. I:

  1. Modified the Scene and SceneCard components in the UI so that they have an extra Play button.
  2. Had that play button write the stream URI (e.g. http://192.168.1.103:9930/scene/13323/stream?apikey=foo) to the clipboard when clicked. I'm actually not sure to what extent the Stash plugin system could help, the links to the info pages about them were dead when I went to read up so I just modified the UI components directly.

Can you please share how you added the Play button?

clangmoyai commented 2 years ago
// ==UserScript==
// @name         stash-iina
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  replace stash app docker path with https://iina.io/ network path
// @author       clangmoyai
// @match        http://192.168.1.55:9999/*
// @icon         https://raw.githubusercontent.com/stashapp/stash/0e514183a7492b80604218c6ee80652b5380333b/ui/v2.5/public/favicon.png
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // change @match url above

    // replace with iina url-scheme
    const stashPath = "file:///data";
    const stringRep = "iina://weblink?url=file:///Volumes/prn";

    // listen for click events
    document.body.addEventListener('click', function (event) {

        // file info tab is clicked
        if (event.target.dataset.rbEventKey === "scene-file-info-panel") {

            // find stashPath in links and replace href
            for (const link of document.querySelector("div.tab-content").querySelectorAll("a")) {
                if (link.href.includes(stashPath)) {
                    link.href = link.href.replace(stashPath, stringRep);
                    link.target = "_self";
                }
            }
        }
    });

})();
feederbox826 commented 1 month ago

Though, it has low chance of getting implemented into Stash due to browser sandboxing. It's better/faster to be solved via plugin or external tool. https://github.com/stashapp/stash/issues/5342#issuecomment-2394854488

It is impossible because of browser sandboxing, file:// paths are the only solution. Should this be moved instead to CommunityScripts since it's not possible via webUI?