mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 12:33:10 +00:00
[5] allow list for overlay_reset
This commit is contained in:
parent
a35fbd1877
commit
3d870805d1
3 changed files with 36 additions and 16 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.18.2-develop4
|
||||
1.18.2-develop5
|
||||
|
|
|
@ -816,10 +816,23 @@ class ConfigFile:
|
|||
params["reapply_overlays"] = True
|
||||
if "reset_overlays" in file or "reset_overlay" in file:
|
||||
attr = f"reset_overlay{'s' if 'reset_overlays' in file else ''}"
|
||||
if file[attr] and file[attr] in reset_overlay_options:
|
||||
params["reset_overlays"] = file[attr]
|
||||
if file[attr] and not isinstance(file[attr], list):
|
||||
test_list = [file[attr]]
|
||||
else:
|
||||
final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: "
|
||||
test_list = file[attr]
|
||||
final_list = []
|
||||
for test_item in test_list:
|
||||
if test_item and test_item in reset_overlay_options:
|
||||
final_list.append(test_item)
|
||||
else:
|
||||
final_text = f"Config Error: reset_overlays attribute {test_item} invalid. Options: "
|
||||
for option, description in reset_overlay_options.items():
|
||||
final_text = f"{final_text}\n {option} ({description})"
|
||||
logger.error(final_text)
|
||||
if final_list:
|
||||
params["reset_overlays"] = final_list
|
||||
else:
|
||||
final_text = f"Config Error: No proper reset_overlays option found. {file[attr]}. Options: "
|
||||
for option, description in reset_overlay_options.items():
|
||||
final_text = f"{final_text}\n {option} ({description})"
|
||||
logger.error(final_text)
|
||||
|
|
|
@ -159,18 +159,25 @@ class Overlays:
|
|||
has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")
|
||||
elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")):
|
||||
has_original = os.path.join(self.library.overlay_backup, f"{item.ratingKey}.jpg")
|
||||
if self.library.reset_overlays == "plex" or (has_original is None and self.library.reset_overlays is None):
|
||||
temp_poster = next((p for p in item.posters() if p.provider == "local"), None)
|
||||
if temp_poster:
|
||||
new_backup = f"{self.library.url}{temp_poster.key}&X-Plex-Token={self.library.token}"
|
||||
else:
|
||||
logger.trace("Plex Error: Plex Poster Download Failed")
|
||||
if self.library.reset_overlays == "tmdb" or (has_original is None and new_backup is None and self.library.reset_overlays is None):
|
||||
try:
|
||||
new_backup = self.find_poster_url(item)
|
||||
except Failed as e:
|
||||
logger.trace(e)
|
||||
if not new_backup and self.library.reset_overlays is not None:
|
||||
if self.library.reset_overlays:
|
||||
reset_list = self.library.reset_overlays
|
||||
elif has_original is None and not self.library.reset_overlays:
|
||||
reset_list = ["plex", "tmdb"]
|
||||
else:
|
||||
reset_list = []
|
||||
for reset in reset_list:
|
||||
if reset == "plex":
|
||||
temp_poster = next((p for p in item.posters() if p.provider == "local"), None)
|
||||
if temp_poster:
|
||||
new_backup = f"{self.library.url}{temp_poster.key}&X-Plex-Token={self.library.token}"
|
||||
else:
|
||||
logger.trace("Plex Error: Plex Poster Download Failed")
|
||||
if reset == "tmdb":
|
||||
try:
|
||||
new_backup = self.find_poster_url(item)
|
||||
except Failed as e:
|
||||
logger.trace(e)
|
||||
if not new_backup and not self.library.reset_overlays:
|
||||
logger.error("Overlay Error: Reset Failed")
|
||||
else:
|
||||
new_backup = item.posterUrl
|
||||
|
|
Loading…
Reference in a new issue