forked from Github/Axter-Stash
Update filemonitor.py
This commit is contained in:
@@ -75,34 +75,6 @@ if plugin.DRY_RUN:
|
|||||||
plugin.Log("Dry run mode is enabled.")
|
plugin.Log("Dry run mode is enabled.")
|
||||||
plugin.Trace(f"(SCAN_MODIFIED={SCAN_MODIFIED}) (SCAN_ON_ANY_EVENT={SCAN_ON_ANY_EVENT}) (RECURSIVE={RECURSIVE})")
|
plugin.Trace(f"(SCAN_MODIFIED={SCAN_MODIFIED}) (SCAN_ON_ANY_EVENT={SCAN_ON_ANY_EVENT}) (RECURSIVE={RECURSIVE})")
|
||||||
|
|
||||||
# ToDo: Add logic here for reoccurring scheduler
|
|
||||||
def runTask(task):
|
|
||||||
if task['task'] == "Clean":
|
|
||||||
plugin.STASH_INTERFACE.metadata_clean(paths=stashPaths, dry_run=plugin.DRY_RUN)
|
|
||||||
elif task['task'] == "Generate":
|
|
||||||
plugin.STASH_INTERFACE.metadata_generate()
|
|
||||||
elif task['task'] == "Backup":
|
|
||||||
plugin.STASH_INTERFACE.call_GQL("mutation { backupDatabase(input: {download: false})}")
|
|
||||||
elif task['task'] == "Scan":
|
|
||||||
plugin.STASH_INTERFACE.metadata_scan(paths=stashPaths)
|
|
||||||
# elif task['task'] == "Create Tags":
|
|
||||||
# plugin.STASH_INTERFACE.run_plugin_task(plugin_id="pathParser", task_name="Create Tags")
|
|
||||||
elif task['task'] == "Auto Tag":
|
|
||||||
plugin.Warn("Auto Tag is not implemented!!!")
|
|
||||||
else:
|
|
||||||
plugin.STASH_INTERFACE.run_plugin_task(plugin_id=task['pluginId'], task_name=task['task'])
|
|
||||||
|
|
||||||
|
|
||||||
def reoccurringScheduler():
|
|
||||||
import schedule # pip install schedule # https://github.com/dbader/schedule
|
|
||||||
for task in plugin.pluginConfig['task_reoccurring_scheduler']:
|
|
||||||
if task['hours'] > 0:
|
|
||||||
plugin.Log(f"Adding to reoccurring scheduler task '{task['task']}' at {task['hours']} hour(s) interval")
|
|
||||||
schedule.every(task['hours']).hours.do(runTask, task)
|
|
||||||
|
|
||||||
if plugin.pluginConfig['turnOnScheduler']:
|
|
||||||
reoccurringScheduler()
|
|
||||||
|
|
||||||
FileMonitorPluginIsOnTaskQue = plugin.CALLED_AS_STASH_PLUGIN
|
FileMonitorPluginIsOnTaskQue = plugin.CALLED_AS_STASH_PLUGIN
|
||||||
StopLibraryMonitorWaitingInTaskQueue = False
|
StopLibraryMonitorWaitingInTaskQueue = False
|
||||||
JobIdInTheQue = 0
|
JobIdInTheQue = 0
|
||||||
@@ -134,6 +106,34 @@ def isJobWaitingToRun():
|
|||||||
if plugin.CALLED_AS_STASH_PLUGIN:
|
if plugin.CALLED_AS_STASH_PLUGIN:
|
||||||
plugin.Trace(f"isJobWaitingToRun() = {isJobWaitingToRun()})")
|
plugin.Trace(f"isJobWaitingToRun() = {isJobWaitingToRun()})")
|
||||||
|
|
||||||
|
# ToDo: Add logic here for reoccurring scheduler
|
||||||
|
def runTask(task):
|
||||||
|
if task['task'] == "Clean":
|
||||||
|
plugin.STASH_INTERFACE.metadata_clean(paths=stashPaths, dry_run=plugin.DRY_RUN)
|
||||||
|
elif task['task'] == "Generate":
|
||||||
|
plugin.STASH_INTERFACE.metadata_generate()
|
||||||
|
elif task['task'] == "Backup":
|
||||||
|
plugin.STASH_INTERFACE.call_GQL("mutation { backupDatabase(input: {download: false})}")
|
||||||
|
elif task['task'] == "Scan":
|
||||||
|
plugin.STASH_INTERFACE.metadata_scan(paths=stashPaths)
|
||||||
|
# elif task['task'] == "Create Tags":
|
||||||
|
# plugin.STASH_INTERFACE.run_plugin_task(plugin_id="pathParser", task_name="Create Tags")
|
||||||
|
elif task['task'] == "Auto Tag":
|
||||||
|
plugin.Warn("Auto Tag is not implemented!!!")
|
||||||
|
else:
|
||||||
|
plugin.STASH_INTERFACE.run_plugin_task(plugin_id=task['pluginId'], task_name=task['task'])
|
||||||
|
|
||||||
|
|
||||||
|
def reoccurringScheduler():
|
||||||
|
import schedule # pip install schedule # https://github.com/dbader/schedule
|
||||||
|
for task in plugin.pluginConfig['task_reoccurring_scheduler']:
|
||||||
|
if task['hours'] > 0:
|
||||||
|
plugin.Log(f"Adding to reoccurring scheduler task '{task['task']}' at {task['hours']} hour(s) interval")
|
||||||
|
schedule.every(task['hours']).hours.do(runTask, task)
|
||||||
|
|
||||||
|
if plugin.pluginConfig['turnOnScheduler']:
|
||||||
|
reoccurringScheduler()
|
||||||
|
|
||||||
def start_library_monitor():
|
def start_library_monitor():
|
||||||
global shouldUpdate
|
global shouldUpdate
|
||||||
global TargetPaths
|
global TargetPaths
|
||||||
|
|||||||
Reference in New Issue
Block a user