From be5a4dcd7bdb957b7423bc679283ead948e403cc Mon Sep 17 00:00:00 2001 From: Scruffy Nerf Date: Mon, 1 Jan 2024 11:48:07 -0500 Subject: [PATCH] v2.5.0 - limited changes to work with Stash v24 - STOPGAP RELEASE --- plugins/renamerOnUpdate/README.md | 16 ++++++++-- plugins/renamerOnUpdate/renamerOnUpdate.py | 35 +++++++++++---------- plugins/renamerOnUpdate/renamerOnUpdate.yml | 2 +- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/plugins/renamerOnUpdate/README.md b/plugins/renamerOnUpdate/README.md index 8eaa7c3a..08dd0ede 100644 --- a/plugins/renamerOnUpdate/README.md +++ b/plugins/renamerOnUpdate/README.md @@ -1,6 +1,17 @@ # *renamerOnUpdate* Using metadata from your Stash to rename/move your file. +# WARNING - This is a stopgap release +It is labeled 2.5.0, to fill the gap until v3.0 is released +It is NOT heavily tested, with the bare minimum needed to work with Stash v24 +Version 3 is a major rewrite, but since it's not quite ready, pushing 2.5.0 seems necessary +It worked for me, using my old config, and I got no errors during my limited tests. +YOU HAVE BEEN WARNED - any potential data loss is on you. +BEFORE YOU USE IT TO MOVE/RENAME ANYTHING CRITICAL, test it yourself. +I still suggest you wait for v3, but... if you can't, this is now out. + +All credit to Belley for all of his work over the years... and v3 is coming soon + ## Table of Contents - [*renamerOnUpdate*](#renameronupdate) @@ -33,10 +44,9 @@ Using metadata from your Stash to rename/move your file. - [*performer_limit*](#performer_limit) # Requirement -- Stash (v0.15+) -- Python 3.6+ (Tested on Python v3.9.1 64bit, Win10) +- Stash (v0.24+) +- Python 3.6+ (Tested LIGHTLY on Python v3.11 Linux) - Request Module (https://pypi.org/project/requests/) -- Tested on Windows 10/Synology/docker. # Installation diff --git a/plugins/renamerOnUpdate/renamerOnUpdate.py b/plugins/renamerOnUpdate/renamerOnUpdate.py index cf145a62..9dab0410 100644 --- a/plugins/renamerOnUpdate/renamerOnUpdate.py +++ b/plugins/renamerOnUpdate/renamerOnUpdate.py @@ -106,11 +106,9 @@ def graphql_getScene(scene_id): } fragment SceneData on Scene { id - oshash - checksum title date - rating + rating100 stash_ids { endpoint stash_id @@ -133,7 +131,7 @@ def graphql_getScene(scene_id): name gender favorite - rating + rating100 stash_ids{ endpoint stash_id @@ -168,11 +166,9 @@ def graphql_findScene(perPage, direc="DESC") -> dict: } fragment SlimSceneData on Scene { id - oshash - checksum title date - rating + rating100 organized stash_ids { endpoint @@ -196,7 +192,7 @@ def graphql_findScene(perPage, direc="DESC") -> dict: name gender favorite - rating + rating100 stash_ids{ endpoint stash_id @@ -467,7 +463,7 @@ def extract_info(scene: dict, template: None): # note: basename contains the extension scene_information['current_filename'] = os.path.basename(scene_information['current_path']) scene_information['current_directory'] = os.path.dirname(scene_information['current_path']) - scene_information['oshash'] = scene['oshash'] + scene_information['oshash'] = scene.get("oshash") scene_information['checksum'] = scene.get("checksum") scene_information['studio_code'] = scene.get("code") @@ -506,8 +502,8 @@ def extract_info(scene: dict, template: None): scene_information['duration'] = str(scene_information['duration']) # Grab Rating - if scene.get("rating"): - scene_information['rating'] = RATING_FORMAT.format(scene['rating']) + if scene.get("rating100"): + scene_information['rating'] = RATING_FORMAT.format(scene['rating100']) # Grab Performer scene_information['performer_path'] = None @@ -527,10 +523,10 @@ def extract_info(scene: dict, template: None): if "inverse_performer" in template["path"]["option"]: perf["name"] = re.sub(r"([a-zA-Z]+)(\s)([a-zA-Z]+)", r"\3 \1", perf["name"]) perf_list.append(perf['name']) - if perf.get('rating'): - if perf_rating.get(str(perf['rating'])) is None: - perf_rating[str(perf['rating'])] = [] - perf_rating[str(perf['rating'])].append(perf['name']) + if perf.get('rating100'): + if perf_rating.get(str(perf['rating100'])) is None: + perf_rating[str(perf['rating100'])] = [] + perf_rating[str(perf['rating100'])].append(perf['name']) else: perf_rating["0"].append(perf['name']) if perf.get('favorite'): @@ -630,7 +626,7 @@ def extract_info(scene: dict, template: None): scene_information['tags'] = TAGS_SPLITCHAR.join(tag_list) # Grab Height (720p,1080p,4k...) - scene_information['bitrate'] = str(round(int(scene['file']['bitrate']) / 1000000, 2)) + scene_information['bit_rate'] = str(round(int(scene['file']['bit_rate']) / 1000000, 2)) scene_information['resolution'] = 'SD' scene_information['height'] = f"{scene['file']['height']}p" if scene['file']['height'] >= 720: @@ -1068,10 +1064,12 @@ def renamer(scene_id, db_conn=None): stash_scene["oshash"] = f["oshash"] if f.get("md5"): stash_scene["checksum"] = f["md5"] + if f.get("checksum"): + stash_scene["checksum"] = f["checksum"] stash_scene["path"] = scene_file["path"] stash_scene["file"] = scene_file if scene_file.get("bit_rate"): - stash_scene["file"]["bitrate"] = scene_file["bit_rate"] + stash_scene["file"]["bit_rate"] = scene_file["bit_rate"] if scene_file.get("frame_rate"): stash_scene["file"]["framerate"] = scene_file["frame_rate"] @@ -1318,6 +1316,9 @@ def exit_plugin(msg=None, err=None): frame_rate duration bit_rate + phash: fingerprint(type: "phash") + oshash: fingerprint(type: "oshash") + checksum: fingerprint(type: "checksum") fingerprints { type value diff --git a/plugins/renamerOnUpdate/renamerOnUpdate.yml b/plugins/renamerOnUpdate/renamerOnUpdate.yml index 9a2d6b0f..f1381fe0 100644 --- a/plugins/renamerOnUpdate/renamerOnUpdate.yml +++ b/plugins/renamerOnUpdate/renamerOnUpdate.yml @@ -1,7 +1,7 @@ name: renamerOnUpdate description: Rename/move filename based on a template. url: https://github.com/stashapp/CommunityScripts -version: 2.4.4 +version: 2.5.0 exec: - python - "{pluginDir}/renamerOnUpdate.py"