Skip to content

Commit 664e8a5

Browse files
committed
fix redacted
1 parent e8e0428 commit 664e8a5

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.10
1+
0.9.11

plex_image_cleanup.py

+25-13
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def not_failed(exception):
7878
base_dir = os.path.dirname(os.path.abspath(__file__))
7979
config_dir = os.path.join(base_dir, "config")
8080
pmmargs = PMMArgs("meisnate12/Plex-Image-Cleanup", os.path.dirname(os.path.abspath(__file__)), options, use_nightly=False)
81-
secrets = [pmmargs["url"], pmmargs["token"], quote(str(pmmargs["url"])), requests.utils.urlparse(pmmargs["url"]).netloc]
8281
logger = logging.PMMLogger(script_name, "plex_image_cleanup", os.path.join(config_dir, "logs"), discord_url=pmmargs["discord"], log_requests=pmmargs["trace"])
82+
logger.secret([pmmargs["url"], pmmargs["token"], quote(str(pmmargs["url"])), requests.utils.urlparse(pmmargs["url"]).netloc])
8383
requests.Session.send = util.update_send(requests.Session.send, pmmargs["timeout"])
8484
plexapi.BASE_HEADERS["X-Plex-Client-Identifier"] = pmmargs.uuid
8585

@@ -94,7 +94,12 @@ def run_plex_image_cleanup(attrs):
9494
do_trash = attrs["empty-trash"] if "empty-trash" in attrs else pmmargs["empty-trash"]
9595
do_bundles = attrs["clean-bundles"] if "clean-bundles" in attrs else pmmargs["clean-bundles"]
9696
do_optimize = attrs["optimize-db"] if "optimize-db" in attrs else pmmargs["optimize-db"]
97-
mode = attrs["mode"].lower() if "mode" in attrs else pmmargs["mode"].lower()
97+
if "mode" in attrs and attrs["mode"]:
98+
mode = str(attrs["mode"]).lower()
99+
elif pmmargs["mode"]:
100+
mode = str(pmmargs["mode"]).lower()
101+
else:
102+
mode = "report"
98103
description = f"Running in {mode.capitalize()} Mode"
99104
extras = []
100105
if do_trash:
@@ -110,17 +115,18 @@ def run_plex_image_cleanup(attrs):
110115
logger.info(description)
111116
report = []
112117
messages = []
118+
kbi = None
113119
try:
114-
try:
115-
logger.info("Script Started", log=False, discord=True)
116-
except Failed as e:
117-
logger.error(e)
118-
119120
# Check Mode
120121
if mode not in modes:
121122
raise Failed(f"Mode Error: {mode} Invalid. Options: \n\t{mode_descriptions}")
122123
logger.info(f"{mode.capitalize()}: {modes[mode]['desc']}")
123124

125+
try:
126+
logger.info("Script Started", log=False, discord=True)
127+
except Failed as e:
128+
logger.error(f"Discord URL Error: {e}")
129+
124130
# Check Plex Path
125131
if not pmmargs["plex"]:
126132
if not os.path.exists(os.path.join(base_dir, "plex")):
@@ -313,8 +319,8 @@ def plex_connect():
313319
logger.info(f"Copying database from {os.path.join(databases_dir, plex_db_name)}", start="database")
314320
util.copy_with_progress(os.path.join(databases_dir, plex_db_name), dbpath, description=f"Copying database file to: {dbpath}")
315321
else:
316-
logger.info("Downloading Database via the API. Plex will This will take some time... To see progress, log into\n"
317-
"Plex and go to Settings | Manage | Console and filter on Database.\n"
322+
logger.info("Downloading Database via the Plex API. First Plex will make a backup of your database.\n"
323+
"To see progress, log into Plex and go to Settings | Manage | Console and filter on Database.\n"
318324
"You can also look at the Plex Dashboard to see the progress of the Database backup.", start="database")
319325
logger.info()
320326

@@ -446,20 +452,26 @@ def plex_connect():
446452
logger.debug(message)
447453
logger.stacktrace()
448454
logger.critical(e, discord=True)
455+
except KeyboardInterrupt:
456+
logger.separator(f"User Exiting {script_name}")
457+
logger.remove_main_handler()
458+
raise
459+
449460
logger.error_report()
450461
logger.switch()
451462
report.append([(f"{script_name} Finished", "")])
452463
report.append([("Total Runtime", f"{logger.runtime()}")])
453464
logger.report(f"{script_name} Summary", description=description, rows=report, discord=True)
465+
logger.remove_main_handler()
454466

455467
if __name__ == "__main__":
456468
try:
457469
if pmmargs["schedule"]:
458470
pmmargs["schedule"] = pmmargs["schedule"].lower().replace(" ", "")
459471
valid_sc = []
460472
schedules = pmmargs["schedule"].split(",")
461-
print()
462-
print("Scheduled Runs: ")
473+
logger.info()
474+
logger.info("Scheduled Runs: ")
463475
for sc in schedules:
464476
run_str = ""
465477
parts = sc.split("|")
@@ -534,11 +546,11 @@ def plex_connect():
534546
run_str += f" at {time_to_run}"
535547
if options:
536548
run_str += f" (Options: {'; '.join([f'{k}={v}' for k, v in options.items()])})"
537-
print(run_str)
549+
logger.info(run_str)
538550
else:
539551
raise Failed(f'Schedule Error: Invalid Schedule: {sc}\nEach Schedule must be in either the "time|frequency" or "time|frequency|options" format')
540552

541-
print()
553+
logger.info()
542554
while True:
543555
schedule.run_pending()
544556
next_run = schedule.next_run()

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ numpy==1.24.2
33
opencv-python==4.7.0.68
44
pillow==9.4.0
55
PlexAPI==4.13.2
6-
pmmutils==0.3.12
6+
pmmutils==0.3.13
77
requests==2.28.2
88
retrying==1.3.4
99
tmdbapis==1.1.0

0 commit comments

Comments
 (0)