Skip to content

Commit

Permalink
Merge pull request #196 from Drazzilb08/master
Browse files Browse the repository at this point in the history
Merge to Dev
  • Loading branch information
Drazzilb08 authored Nov 19, 2024
2 parents 013fc3e + 6ee1a3a commit ce2bc8e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/config.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ poster_renamerr:
log_level: info
dry_run: false
sync_posters: true # <- This will run sync_gdrive before renaming
action_type: copy # <- Options: copy, move
action_type: copy # <- Options: copy, move, hardlink, symlink (Note: 'hardlink' and 'symlink' require "source_dirs" and "destination_dir" to be on the same filesystem)
asset_folders: false # <- This will copy the folder structure of the source_dir to the destination_dir, this MUST be the same as you use in Plex-Meta-Manager
print_only_renames: false # <- This will print the renames to the log, but will not actually rename anything
# This will integrate border_replacer with poster_renamerr, set this to true if you want to use them at the same time (no need to schedule border_replacer)
Expand Down
4 changes: 3 additions & 1 deletion extra-scripts/exclude-file.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ com.plexapp.plugins.library.db-*
*/logs
*/Cache/Transcode/*
*/Cache/PhotoTranscoder/*
.DS_Store
.DS_Store
*/@eaDir
Thumbs.db
26 changes: 17 additions & 9 deletions modules/poster_renamerr.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,18 +313,26 @@ def rename_files(matched_assets, script_config, logger):
new_file_path = os.path.join(dest_dir, new_file_name)

# Check if the new file path already exists
if os.path.isfile(new_file_path):
if os.path.lexists(new_file_path):
existing_file = os.path.join(dest_dir, new_file_name)
# Check if the existing file is the same as the new file True = same, False = different
if not filecmp.cmp(file, existing_file):
if file_name != new_file_name:
messages.append(f"{file_name} -renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
else:
if not print_only_renames:
messages.append(f"{file_name} -not-renamed-> {new_file_name}")
try:
# Check if the existing file is the same as the new file True = same, False = different
if not filecmp.cmp(file, existing_file):
if file_name != new_file_name:
messages.append(f"{file_name} -renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
else:
if not print_only_renames:
messages.append(f"{file_name} -not-renamed-> {new_file_name}")
discord_messages.append(f"{new_file_name}")
if not dry_run:
if action_type in ["hardlink", "symlink"]:
os.remove(new_file_path)
process_file(file, new_file_path, action_type, logger)
except FileNotFoundError:
# Handle the case where existing_file is a broken symlink
if not dry_run:
os.remove(new_file_path)
process_file(file, new_file_path, action_type, logger)
else:
if file_name != new_file_name:
Expand Down
10 changes: 7 additions & 3 deletions schemas/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
},
"action_type": {
"type": "string",
"pattern": "^copy|move$"
"pattern": "^copy|move|hardlink|symlink$"
},
"asset_folders": {
"type": "boolean"
Expand Down Expand Up @@ -512,12 +512,16 @@
"tag_name": {
"type": "string"
},
"ignore_tag":
{
"ignore_tag": {
"type": "string"
},
"unattended": {
"type": "boolean"
},
"season_monitored_threshold": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
Expand Down

0 comments on commit ce2bc8e

Please sign in to comment.