Conversation
Just a warning for this functionality. Trigerring the above will make all the post update plugins run. I don't think there are [m]any atm :-) but it could be an issue later on. I think you should warn users or even better defer that to a separate |
| > Note: The priority is Tag > Studio > Default | ||
|
|
||
| If you only want change 1 tag: | ||
| The config will be: |
There was a problem hiding this comment.
Configuration sample: ?
Not sure for this one....
Also adding warning for unidecode module if non latin
|
Fixed some typos and removed unneeded parts from the queries ( i dont think i broke anything from a few tests i did) diff --git a/plugins/renamerOnUpdate/renamerOnUpdate.py b/plugins/renamerOnUpdate/renamerOnUpdate.py
index 5a8beb9..e4105f8 100644
--- a/plugins/renamerOnUpdate/renamerOnUpdate.py
+++ b/plugins/renamerOnUpdate/renamerOnUpdate.py
@@ -37,9 +37,9 @@ if FRAGMENT_SCENE_ID:
PLUGIN_ARGS = FRAGMENT['args'].get("mode")
if PLUGIN_ARGS:
- log.LogDebug("--Starting Plugin 'Renammer'--")
+ log.LogDebug("--Starting Plugin 'Renamer'--")
else:
- log.LogDebug("--Starting Hook 'Renammer'--")
+ log.LogDebug("--Starting Hook 'Renamer'--")
#log.LogDebug("{}".format(FRAGMENT))
@@ -94,37 +94,19 @@ def graphql_getScene(scene_id):
}
fragment SceneData on Scene {
id
- checksum
- oshash
title
- details
- url
date
- rating
- o_counter
organized
path
- phash
- interactive
file {
- size
- duration
video_codec
audio_codec
width
height
- framerate
- bitrate
}
studio {
...SlimStudioData
}
- movies {
- movie {
- ...MovieData
- }
- scene_index
- }
tags {
...SlimTagData
}
@@ -139,23 +121,7 @@ def graphql_getScene(scene_id):
id
name
}
- details
- rating
- aliases
- }
- fragment MovieData on Movie {
- id
- checksum
- name
aliases
- date
- rating
- director
- studio {
- ...SlimStudioData
- }
- synopsis
- url
}
fragment SlimTagData on Tag {
id
@@ -164,32 +130,8 @@ def graphql_getScene(scene_id):
}
fragment PerformerData on Performer {
id
- checksum
name
- url
- gender
- twitter
- instagram
- birthdate
- ethnicity
- country
- eye_color
- height
- measurements
- fake_tits
- career_length
- tattoos
- piercings
aliases
- favorite
- tags {
- ...SlimTagData
- }
- rating
- details
- death_date
- hair_color
- weight
}
"""
variables = {
@@ -225,39 +167,14 @@ def graphql_findScene(perPage,direc="DESC"):
}
fragment SlimSceneData on Scene {
id
- checksum
- oshash
title
- details
- url
date
- rating
- o_counter
organized
path
- phash
- interactive
- scene_markers {
- id
- title
- seconds
- }
- galleries {
- id
- path
- title
- }
studio {
id
name
}
- movies {
- movie {
- id
- name
- }
- scene_index
- }
tags {
id
name
@@ -265,8 +182,6 @@ def graphql_findScene(perPage,direc="DESC"):
performers {
id
name
- gender
- favorite
}
}
"""
@@ -490,10 +405,10 @@ else:
# Replace the old filename by the new in the filepath
new_path = current_path.rstrip(current_filename) + new_filename
-# Trying to prevent error with long path for Win10
+# Trying to prevent error with long paths for Win10
# https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd
if len(new_path) > 240:
- log.LogWarning("The Path is too long ({})...".format(len(new_path)))
+ log.LogWarning("Resulting Path is too long ({})...".format(len(new_path)))
for word in ORDER_SHORTFIELD:
if word not in filename_template:
continue
@@ -505,13 +420,13 @@ if len(new_path) > 240:
log.LogInfo("Reduced filename to: {}".format(new_filename))
break
if len(new_path) > 240:
- exit_plugin(err="Can't manage to reduce the path, operation aborted.")
+ exit_plugin(err="Can't shorten path, operation aborted.")
#log.LogDebug("Filename: {} -> {}".format(current_filename,new_filename))
#log.LogDebug("Path: {} -> {}".format(current_path,new_path))
if (new_path == current_path):
- exit_plugin("Filename already correct. ({})".format(current_filename))
+ exit_plugin("Filename already ok. ({})".format(current_filename))
if ALT_DIFF_DISPLAY:
find_diff_text(current_filename,new_filename)
@@ -533,14 +448,14 @@ cursor.execute("SELECT id FROM scenes WHERE path LIKE ? AND NOT id=?;", ["%" + f
dupl_check = cursor.fetchall()
if len(dupl_check) > 0:
for dupl_row in dupl_check:
- log.LogError("Same path: [{}]".format(dupl_row[0]))
+ log.LogError("Identical path: [{}]".format(dupl_row[0]))
exit_plugin(err="Duplicate path detected, check log!")
cursor.execute("SELECT id FROM scenes WHERE path LIKE ? AND NOT id=?;", ["%" + new_filename, FRAGMENT_SCENE_ID])
dupl_check = cursor.fetchall()
if len(dupl_check) > 0:
for dupl_row in dupl_check:
- log.LogInfo("Same filename: [{}]".format(dupl_row[0]))
+ log.LogInfo("Duplicate filename: [{}]".format(dupl_row[0]))
# OS Rename
if (os.path.isfile(current_path) == True):
@@ -548,20 +463,20 @@ if (os.path.isfile(current_path) == True):
os.rename(current_path, new_path)
except PermissionError as err:
if "[WinError 32]" in str(err) and MODULE_PSUTIL:
- log.LogWarning("A process use this file, trying to find it (Probably FFMPEG)")
- # Find what process access the file, it's ffmpeg for sure...
+ log.LogWarning("A process is using this file (Probably FFMPEG), trying to find it ...")
+ # Find which process accesses the file, it's ffmpeg for sure...
process_use = has_handle(current_path, PROCESS_ALLRESULT)
if process_use:
# Terminate the process then try again to rename
- log.LogDebug("Process that use this file: {}".format(process_use))
+ log.LogDebug("Process that uses this file: {}".format(process_use))
if PROCESS_KILL:
p = psutil.Process(process_use.pid)
p.terminate()
p.wait(10)
- # If we don't manage to close it, this will create a error again.
+ # If process is not terminated, this will create an error again.
os.rename(current_path, new_path)
else:
- exit_plugin(err="A process prevent editing the file.")
+ exit_plugin(err="A process prevents renaming the file.")
else:
log.LogError(err)
sys.exit()
@@ -572,9 +487,9 @@ if (os.path.isfile(current_path) == True):
f.write("{}|{}|{}\n".format(FRAGMENT_SCENE_ID, current_path, new_path))
else:
# I don't think it's possible.
- exit_plugin(err="[OS] File failed to rename ? {}".format(new_path))
+ exit_plugin(err="[OS] Failed to rename the file ? {}".format(new_path))
else:
- exit_plugin(err="[OS] File don't exist in your Disk/Drive ({})".format(current_path))
+ exit_plugin(err="[OS] File doesn't exist in your Disk/Drive ({})".format(current_path))
# Database rename
cursor.execute("UPDATE scenes SET path=? WHERE id=?;", [new_path, FRAGMENT_SCENE_ID]) |
review by Bnkai
|
Hmh somehow it gives me a strange error: |
* Create config.py * Update renamerOnUpdate.yml * Update renamerOnUpdate.py * Update README.md * Update README.md * Update config.py * correct by Bnkai * Update config.py Also adding warning for unidecode module if non latin * removing task * removing task * remove task from readme * using len instead of removing 1 character * Update renamerOnUpdate.py * Update renamerOnUpdate.py review by Bnkai
Edit: Close #18 (My update include the config). Thanks to jthrow0451 for the idea :)