Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
7dJx1qP committed Feb 13, 2024
1 parent 67db740 commit a626c9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def tag_performer(db: StashDatabase, stash_id: str, tag_id: int):
else:
log.debug(f'Performer already tagged {stash_id} {performer.id} {performer.name}')

def set_stashbox_favorite_performers(db: StashDatabase, endpoint: str, boxapi_key: str, tagErrors: bool, tagName: str):
def set_stashbox_favorite_performers(db: StashDatabase, endpoint: str, boxapi_key: str, tag_errors: bool, tag_name: str):
stash_ids = set([row["stash_id"] for row in db.fetchall("""SELECT DISTINCT b.stash_id
FROM performers a
JOIN performer_stash_ids b
Expand All @@ -163,13 +163,13 @@ def set_stashbox_favorite_performers(db: StashDatabase, endpoint: str, boxapi_ke
log.info(f'Stashbox endpoint {endpoint}')
log.info(f'Stash {len(stash_ids)} favorite performers')
tag = None
if tagErrors and tagName:
log.info(f'Tagging errors with performer tag: {tagName}')
tag = db.tags.selectone_name(tagName)
if tag_errors and tag_name:
log.info(f'Tagging errors with performer tag: {tag_name}')
tag = db.tags.selectone_name(tag_name)
if not tag:
log.info(f'Tag missing. Creating...')
db.tags.insert(tagName, get_timestamp(), get_timestamp(), True, 'Tag created by Set Stashbox Favorite Performers plugin. Applied to performers found to have stash ids deleted from stashbox.', None)
tag = db.tags.selectone_name(tagName)
db.tags.insert(tag_name, get_timestamp(), get_timestamp(), True, 'Tag created by Set Stashbox Favorite Performers plugin. Applied to performers found to have stash ids deleted from stashbox.', None)
tag = db.tags.selectone_name(tag_name)
if not tag:
log.error(f"Failed to create tag.")
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def get_database_config():
log.debug(f"databasePath: {database_path}")
return database_path, blobs_path, blobs_storage

pluginSettings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins'].get('stashSetStashboxFavoritePerformers', {})
tagErrors = pluginSettings.get('tagErrors', False)
tagName = pluginSettings.get('tagName')
plugin_settings = client.callGraphQL("""query Configuration { configuration { plugins } }""")['configuration']['plugins'].get('stashSetStashboxFavoritePerformers', {})
tag_errors = plugin_settings.get('tagErrors', False)
tag_name = plugin_settings.get('tagName')

if name == 'favorite_performers_sync':
endpoint = json_input['args']['endpoint']
Expand All @@ -36,7 +36,7 @@ def get_database_config():
except Exception as e:
log.error(str(e))
sys.exit(0)
set_stashbox_favorite_performers(db, endpoint, api_key, tagErrors, tagName)
set_stashbox_favorite_performers(db, endpoint, api_key, tag_errors, tag_name)
db.close()
elif name == 'favorite_performer_sync':
endpoint = json_input['args']['endpoint']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Stash Set Stashbox Favorite Performers
# requires: stashUserscriptLibrary7dJx1qP
description: Set Stashbox favorite performers according to stash favorites
version: 0.6.1
version: 0.6.2
url: https://github.com/7dJx1qP/stash-plugins#stash-set-stashbox-favorite-performers
ui:
requires:
Expand Down

0 comments on commit a626c9e

Please sign in to comment.