Stash Explorer

Open galleries/images in Windows Explorer. Requires included stashExplorer.py to be running locally.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

Автор
stashtastic
Установок в день
0
Всего установок
5
Оценки
0 0 0
Версия
2024-09-13
Создано
05.10.2024
Обновлено
05.10.2024
Размер
6,8 КБ
Лицензия
MIT
Работает на

Open images/galleries in Windows Explorer from Stash https://github.com/stashapp/stash/

  • Adds a folder icon to the top-left of gallery/image pages.
  • Clicking the icon will open Windows Explorer, automatically selecting the file.

NOTE: Required Python Script

UserScripts do not have the ability to open Windows Explorer.

This script requires a separate Python script is running on your local host, in order to open Windows Explorer.

The Python script will open a port on your computer (port 9998). The Python script code is included in the UserScript comments, and below:

from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib.parse import urlparse
from urllib.parse import parse_qs
import subprocess

class StashExplorerHandler(BaseHTTPRequestHandler):
    def o(self, text):
        text = str(text)
        print(f"[StashExplorer.py] {text}")
        output = text + "\n\n"
        self.wfile.write(output.encode("utf-8"))

    def do_GET(self):
        """handle GET requests."""
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()

        # Parse path
        parsed_url = urlparse(self.path)
        params = parse_qs(parsed_url.query)

        if "path" not in params:
            self.o(f"Could not find 'path' in params: {params}")
            return

        path = params["path"][0]
        path = path.replace('/', '\\')

        # Sanitize
        if '"' in path:
            path = path.replace('"', '\\"')

        command = f'explorer /select,"{path}"'
        self.o(f"Opening: {command}")
        subprocess.Popen(command)


def run(server_class=HTTPServer, handler_class=StashExplorerHandler):
    server_address = ('', 9998)
    httpd = server_class(server_address, handler_class)
    httpd.serve_forever()

run()