forked from Github/Axter-Stash
Added logic to pass API key to service automatically
This commit is contained in:
@@ -41,6 +41,7 @@ class StashPluginHelper(StashInterface):
|
||||
FRAGMENT_SERVER = None
|
||||
STASHPATHSCONFIG = None
|
||||
STASH_PATHS = []
|
||||
API_KEY = None
|
||||
|
||||
# printTo argument
|
||||
LOG_TO_FILE = 1
|
||||
@@ -95,6 +96,7 @@ class StashPluginHelper(StashInterface):
|
||||
config = None, # From pluginName_config.py or pluginName_setting.py
|
||||
fragmentServer = None,
|
||||
stash_url = None, # Stash URL (endpoint URL) Example: http://localhost:9999
|
||||
apiKey = None, # API Key only needed when username and password set while running script via command line
|
||||
DebugTraceFieldName = "zzdebugTracing",
|
||||
DryRunFieldName = "zzdryRun",
|
||||
setStashLoggerAsPluginLogger = False):
|
||||
@@ -122,7 +124,6 @@ class StashPluginHelper(StashInterface):
|
||||
self.FRAGMENT_SERVER = {'Scheme': 'http', 'Host': '0.0.0.0', 'Port': '9999', 'SessionCookie': {'Name': 'session', 'Value': '', 'Path': '', 'Domain': '', 'Expires': '0001-01-01T00:00:00Z', 'RawExpires': '', 'MaxAge': 0, 'Secure': False, 'HttpOnly': False, 'SameSite': 0, 'Raw': '', 'Unparsed': None}, 'Dir': os.path.dirname(pathlib.Path(self.MAIN_SCRIPT_NAME).resolve().parent), 'PluginDir': pathlib.Path(self.MAIN_SCRIPT_NAME).resolve().parent}
|
||||
|
||||
if debugTracing: self.DEBUG_TRACING = debugTracing
|
||||
apiKey = ""
|
||||
if config:
|
||||
self.pluginConfig = config
|
||||
if 'apiKey' in self.pluginConfig and self.pluginConfig['apiKey'] != "":
|
||||
@@ -132,6 +133,9 @@ class StashPluginHelper(StashInterface):
|
||||
if DryRunFieldName in self.pluginConfig:
|
||||
self.DRY_RUN = self.pluginConfig[DryRunFieldName]
|
||||
|
||||
if apiKey and apiKey != "":
|
||||
self.FRAGMENT_SERVER['ApiKey'] = apiKey
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
RUNNING_IN_COMMAND_LINE_MODE = True
|
||||
if not debugTracing or not stash_url:
|
||||
@@ -181,6 +185,8 @@ class StashPluginHelper(StashInterface):
|
||||
self.DEBUG_TRACING = self.pluginSettings[DebugTraceFieldName]
|
||||
if DryRunFieldName in self.pluginSettings:
|
||||
self.DRY_RUN = self.pluginSettings[DryRunFieldName]
|
||||
if 'apiKey' in self.STASH_CONFIGURATION:
|
||||
self.API_KEY = self.STASH_CONFIGURATION['apiKey']
|
||||
if self.DEBUG_TRACING: self.LOG_LEVEL = logging.DEBUG
|
||||
|
||||
logging.basicConfig(level=self.LOG_LEVEL, format=logFormat, datefmt=dateFmt, handlers=[RFH])
|
||||
|
||||
Reference in New Issue
Block a user