forked from Github/Axter-Stash
updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from stashapi.stashapp import StashInterface
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import inspect, sys, os, pathlib, logging, json
|
||||
import re, inspect, sys, os, pathlib, logging, json
|
||||
import concurrent.futures
|
||||
from stashapi.stash_types import PhashDistance
|
||||
import __main__
|
||||
@@ -30,7 +30,6 @@ class StashPluginHelper(StashInterface):
|
||||
PLUGINS_PATH = None
|
||||
pluginSettings = None
|
||||
pluginConfig = None
|
||||
STASH_INTERFACE_INIT = False
|
||||
STASH_URL = None
|
||||
STASH_CONFIGURATION = None
|
||||
JSON_INPUT = None
|
||||
@@ -62,6 +61,7 @@ class StashPluginHelper(StashInterface):
|
||||
pluginLog = None
|
||||
logLinePreviousHits = []
|
||||
thredPool = None
|
||||
STASH_INTERFACE_INIT = False
|
||||
|
||||
# Prefix message value
|
||||
LEV_TRACE = "TRACE: "
|
||||
@@ -106,7 +106,7 @@ class StashPluginHelper(StashInterface):
|
||||
if logToNormSet: self.log_to_norm = logToNormSet
|
||||
if stash_url and len(stash_url): self.STASH_URL = stash_url
|
||||
self.MAIN_SCRIPT_NAME = mainScriptName if mainScriptName != "" else __main__.__file__
|
||||
self.PLUGIN_ID = pluginID if pluginID != "" else pathlib.Path(self.MAIN_SCRIPT_NAME).stem.lower()
|
||||
self.PLUGIN_ID = pluginID if pluginID != "" else pathlib.Path(self.MAIN_SCRIPT_NAME).stem
|
||||
# print(f"self.MAIN_SCRIPT_NAME={self.MAIN_SCRIPT_NAME}, self.PLUGIN_ID={self.PLUGIN_ID}", file=sys.stderr)
|
||||
self.LOG_FILE_NAME = logFilePath if logFilePath != "" else f"{pathlib.Path(self.MAIN_SCRIPT_NAME).resolve().parent}{os.sep}{pathlib.Path(self.MAIN_SCRIPT_NAME).stem}.log"
|
||||
self.LOG_FILE_DIR = pathlib.Path(self.LOG_FILE_NAME).resolve().parent
|
||||
@@ -355,24 +355,20 @@ class StashPluginHelper(StashInterface):
|
||||
|
||||
def rename_generated_files(self):
|
||||
return self.call_GQL("mutation MigrateHashNaming {migrateHashNaming}")
|
||||
# def find_duplicate_scenes(self, distance: PhashDistance=PhashDistance.EXACT, fragment=None):
|
||||
# query = """
|
||||
# query FindDuplicateScenes($distance: Int) {
|
||||
# findDuplicateScenes(distance: $distance) {
|
||||
# ...SceneSlim
|
||||
# }
|
||||
# }
|
||||
# """
|
||||
# if fragment:
|
||||
# query = re.sub(r'\.\.\.SceneSlim', fragment, query)
|
||||
# else:
|
||||
# query = """
|
||||
# query FindDuplicateScenes($distance: Int) {
|
||||
# findDuplicateScenes(distance: $distance)
|
||||
# }
|
||||
# """
|
||||
# variables = {
|
||||
# "distance": distance
|
||||
# }
|
||||
# result = self.call_GQL(query, variables)
|
||||
# return result['findDuplicateScenes']
|
||||
|
||||
def find_duplicate_scenes_diff(self, distance: PhashDistance=PhashDistance.EXACT, fragment='id', duration_diff: float=10.00 ):
|
||||
query = """
|
||||
query FindDuplicateScenes($distance: Int, $duration_diff: Float) {
|
||||
findDuplicateScenes(distance: $distance, duration_diff: $duration_diff) {
|
||||
...SceneSlim
|
||||
}
|
||||
}
|
||||
"""
|
||||
if fragment:
|
||||
query = re.sub(r'\.\.\.SceneSlim', fragment, query)
|
||||
else:
|
||||
query += "fragment SceneSlim on Scene { id }"
|
||||
|
||||
variables = { "distance": distance, "duration_diff": duration_diff }
|
||||
result = self.call_GQL(query, variables)
|
||||
return result['findDuplicateScenes']
|
||||
|
||||
@@ -11,16 +11,22 @@ config = {
|
||||
# The hour section in time MUST be a two digit number, and use military time format. Example: 1PM = "13:00" and 1AM = "01:00"
|
||||
# Note: Look at filemonitor_task_examples.py for many example task having more detailed usage.
|
||||
"task_scheduler": [
|
||||
# To create a daily task, include each day of the week for the weekday field.
|
||||
{"task" : "Auto Tag", "weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "06:00"}, # Auto Tag -> [Auto Tag] (Daily at 6AM)
|
||||
{"task" : "Optimise Database", "weekday" : "monday,tuesday,wednesday,thursday,friday", "time" : "07:00"}, # Maintenance -> [Optimise Database] (Every weekday at 7AM)
|
||||
# To create a daily task, include each day of the week for the weekday field.
|
||||
# Optional field for task "Auto Tag" is 'paths'. For detail usage, see example #A3: in filemonitor_task_examples.py
|
||||
{"task" : "Auto Tag", "weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "05:00"}, # Auto Tag -> [Auto Tag] (Daily at 6AM)
|
||||
# Task "Create Tags" is a plugin task. All plugin task have a REQUIRED pluginId field and an optional validateDir field. For detail usage, see examples #B1 and #B2 in filemonitor_task_examples.py
|
||||
{"task" : "Create Tags", "pluginId" : "pathParser", "validateDir" : "pathParser",
|
||||
"weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "05:00"}, # [Plugin Tasks] - > [Path Parser] -> [Create Tags] (Daily at 5AM) : This task requires plugin [Path Parser]
|
||||
|
||||
"weekday" : "monday,tuesday,wednesday,thursday,friday,saturday,sunday", "time" : "05:30"}, # [Plugin Tasks] - > [Path Parser] -> [Create Tags] (Daily at 5AM) : This task requires plugin [Path Parser]
|
||||
{"task" : "Optimise Database", "weekday" : "monday,tuesday,wednesday,thursday,friday", "time" : "07:00"}, # Maintenance -> [Optimise Database] (Every weekday at 7AM)
|
||||
|
||||
# The following tasks are scheduled weekly
|
||||
{"task" : "Generate", "weekday" : "saturday", "time" : "07:00"}, # Generated Content-> [Generate] (Every saturday at 7AM)
|
||||
{"task" : "Scan", "weekday" : "saturday", "time" : "03:00"}, # Library -> [Scan] (Weekly) (Every saturday at 3AM)
|
||||
# Optional field for task "Scan", "Auto Tag", and "Clean" is 'paths'. For detail usage, see examples #A3: in filemonitor_task_examples.py
|
||||
{"task" : "Scan", "weekday" : "saturday", "time" : "03:00"}, # Library -> [Scan] (Weekly) (Every saturday at 3AM)
|
||||
{"task" : "Auto Tag", "weekday" : "saturday", "time" : "03:30"}, # Auto Tag -> [Auto Tag] (Weekly) (Every saturday at 3:30AM)
|
||||
{"task" : "Generate", "weekday" : "saturday", "time" : "04:00"}, # Generated Content-> [Generate] (Every saturday at 4AM)
|
||||
{"task" : "Clean", "weekday" : "saturday", "time" : "04:30"}, # Maintenance -> [Clean] (Every saturday at 4:30AM)
|
||||
{"task" : "Clean Generated Files", "weekday" : "saturday", "time" : "05:00"}, # Maintenance -> [Clean Generated Files] (Every saturday at 5AM)
|
||||
{"task" : "Optimise Database", "weekday" : "saturday", "time" : "05:30"}, # Maintenance -> [Optimise Database] (Every saturday at 5:30AM)
|
||||
|
||||
# To perform a task monthly, specify the day of the month as in the weekly schedule format, and add a monthly field.
|
||||
# The monthly field value must be 1, 2, 3, or 4.
|
||||
@@ -28,25 +34,25 @@ config = {
|
||||
# 2 = 2nd specified weekday of the month. Example 2nd monday of the month.
|
||||
# 3 = 3rd specified weekday of the month.
|
||||
# 4 = 4th specified weekday of the month.
|
||||
# The following task is scheduled monthly
|
||||
# The Backup task is scheduled monthly
|
||||
# Optional field for task "Backup" is maxBackup. For detail usage, see example #A5 in filemonitor_task_examples.py
|
||||
{"task" : "Backup", "weekday" : "sunday", "time" : "01:00", "monthly" : 2}, # Backup -> [Backup] 2nd sunday of the month at 1AM (01:00)
|
||||
{"task" : "Clean", "weekday" : "sunday", "time" : "01:00", "monthly" : 3}, # Maintenance -> [Clean]
|
||||
{"task" : "Clean Generated Files", "weekday" : "sunday", "time" : "03:00", "monthly" : 3}, # Maintenance -> [Clean Generated Files]
|
||||
|
||||
# The [CheckStashIsRunning] task checks if Stash is running. If not running, it will start up stash.
|
||||
# This task only works if FileMonitor is started as a service or in command line mode.
|
||||
# For more detailed usage, see examples #C1 and #C2 in filemonitor_task_examples.py
|
||||
# Optional fields are 'command' and 'RunAfter'. For detail usage, see examples #C1 and #C2 in filemonitor_task_examples.py
|
||||
{"task" : "CheckStashIsRunning", "minutes" :5}, # Checks every 5 minutes
|
||||
],
|
||||
|
||||
# ApiKey only needed when Stash credentials are set and while calling FileMonitor via command line.
|
||||
"apiKey" : "", # Example: "eyJabccideJIUfg1NigRInD345I6dfpXVCfd.eyJ1abcDEfGheHRlHJiJklMonPQ32FsVewtsfSIsImlhdCI6MTcyMzg2NzkwOH0.5bkHU6sfs3532dsryu1ki3iFBwnd_4AHs325yHljsPw"
|
||||
# Timeout in seconds. This is how often FileMonitor will check the scheduler and (in-plugin mode) check if another job (Task) is in the queue.
|
||||
"timeOut": 60,
|
||||
# ApiKey only needed when Stash credentials are set and while calling FileMonitor via command line.
|
||||
"apiKey" : "", # Example: "eyJabccideJIUfg1NigRInD345I6dfpXVCfd.eyJ1abcDEfGheHRlHJiJklMonPQ32FsVewtsfSIsImlhdCI6MTcyMzg2NzkwOH0.5bkHU6sfs3532dsryu1ki3iFBwnd_4AHs325yHljsPw"
|
||||
# Enable to run metadata clean task after file deletion.
|
||||
"runCleanAfterDelete": False,
|
||||
# Enable to run metadata_generate (Generate Content) after metadata scan.
|
||||
"runGenerateContent": False,
|
||||
|
||||
# When populated (comma separated list [lower-case]), only scan for changes for specified file extension
|
||||
"fileExtTypes" : "", # Example: "mp4,mpg,mpeg,m2ts,wmv,avi,m4v,flv,mov,asf,mkv,divx,webm,ts,mp2t"
|
||||
# When populated, only include file changes in specified paths.
|
||||
@@ -54,7 +60,7 @@ config = {
|
||||
# When populated, exclude file changes in paths that start with specified entries.
|
||||
"excludePathChanges" :[], # Example: ["C:\\MyVideos\\SomeSubFolder\\", "C:\\MyImages\\folder\\Sub\\"]
|
||||
|
||||
# The following fields are ONLY used when running FileMonitor in script mode.
|
||||
# The following fields are ONLY used when running FileMonitor in command line mode.
|
||||
"endpoint_Scheme" : "http", # Define endpoint to use when contacting the Stash server
|
||||
"endpoint_Host" : "0.0.0.0", # Define endpoint to use when contacting the Stash server
|
||||
"endpoint_Port" : 9999, # Define endpoint to use when contacting the Stash server
|
||||
|
||||
@@ -41,7 +41,7 @@ task_examples = {
|
||||
# Example#B4: Task to execute a command with optional args field, and using keyword <plugin_path>, which gets replaced with filemonitor.py current directory.
|
||||
{"task" : "execute", "command" : "<plugin_path>HelloWorld.cmd", "args" : "--name David", "minutes" : 0},
|
||||
|
||||
# Example#C1 Some OS may need the "command" field, which specifies the binary path
|
||||
# Example#C1 Some OS may need the "command" field, which specifies the binary path.
|
||||
{"task" : "CheckStashIsRunning", "command" : "<stash_path>stash-linux-arm64v8", "minutes" :0},
|
||||
# Example#C2 RunAfter field can be used to specify task to run after starting Stash
|
||||
{"task" : "CheckStashIsRunning", "RunAfter" : [{"task" : "Scan"},{"task" : "Backup", "maxBackup" : 0},{"task" : "Clean"}], "minutes" :0},
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
stashapp-tools >= 0.2.49
|
||||
stashapp-tools >= 0.2.50
|
||||
pyYAML
|
||||
watchdog
|
||||
Reference in New Issue
Block a user