[126] fix downloading image sets

pull/1340/head
meisnate12 2 years ago
parent 48696d0ebf
commit e889f4ab9b

@ -1 +1 @@
1.18.3-develop125
1.18.3-develop126

@ -1259,7 +1259,8 @@ class MetadataFile(DataFile):
if not files:
raise Failed(f"{self.type_str} Error: No Path Found for image_set")
file_type, set_file, _, _ = files[0]
temp_data = self.load_file(file_type, set_file, images=True, folder=f"{'movies' if self.library.is_movie else 'shows'}-sets/")
folder_name = os.path.splitext(os.path.basename(set_file))[0]
temp_data = self.load_file(file_type, set_file, images=True, folder=f"{folder_name}-sets/")
if "set" not in temp_data:
raise Failed('Image Set Error: Image sets must use the base attribute "set"')
if not isinstance(temp_data, dict):

@ -104,38 +104,35 @@ class Overlays:
else:
applied_names.append(over_name)
change_reason = ""
overlay_change = False if has_overlay else True
overlay_change = "" if has_overlay else "No Overlay Label"
if not overlay_change:
for oc in overlay_compare:
if oc not in compare_names:
change_reason = f"{oc} not in {compare_names}"
overlay_change = True
overlay_change = f"{oc} not in {compare_names}"
if not overlay_change:
for compare_name, original_name in compare_names.items():
if compare_name not in overlay_compare or properties[original_name].updated:
change_reason = f"{compare_name} not in {overlay_compare} or {properties[original_name].updated}"
overlay_change = True
overlay_change = f"{compare_name} not in {overlay_compare} or {properties[original_name].updated}"
if self.config.Cache:
for over_name in over_names:
current_overlay = properties[over_name]
if current_overlay.name.startswith("text"):
if properties[over_name].name.startswith("text"):
for cache_key, cache_value in self.config.Cache.query_overlay_special_text(item.ratingKey).items():
actual = plex.attribute_translation[cache_key] if cache_key in plex.attribute_translation else cache_key
if cache_value is None or not hasattr(item, actual) or getattr(item, actual) is None:
if not hasattr(item, actual):
continue
actual_value = getattr(item, actual)
if cache_value is None or actual_value is None:
continue
if cache_key in overlay.float_vars:
cache_value = float(cache_value)
if cache_key in overlay.int_vars:
cache_value = int(cache_value)
if cache_key in overlay.date_vars:
if getattr(item, actual).strftime("%Y-%m-%d") != cache_value:
overlay_change = True
elif getattr(item, actual) != cache_value:
overlay_change = True
actual_value = actual_value.strftime("%Y-%m-%d")
if actual_value != cache_value:
overlay_change = f"Special Text Changed from {cache_value} to {actual_value}"
try:
poster, background, item_dir, name = self.library.find_item_assets(item)
if not poster and self.library.assets_for_all:
@ -153,7 +150,6 @@ class Overlays:
logger.warning(e)
has_original = None
changed_image = False
new_backup = None
if poster:
if image_compare and str(poster.compare) != str(image_compare):
@ -182,7 +178,6 @@ class Overlays:
new_backup = item.posterUrl
logger.info(f"\n{item_title}")
if new_backup:
changed_image = True
try:
has_original = self.library.check_image_for_overlay(new_backup, os.path.join(self.library.overlay_backup, f"{item.ratingKey}"))
except Failed as e:
@ -190,12 +185,12 @@ class Overlays:
poster_compare = None
if poster is None and has_original is None:
logger.error(f" Overlay Error: No poster found")
elif self.library.reapply_overlays or changed_image or overlay_change:
elif self.library.reapply_overlays or new_backup or overlay_change:
try:
if not self.library.reapply_overlays and changed_image:
logger.trace(" Overlay applied because new image was detected")
if not self.library.reapply_overlays and new_backup:
logger.trace(" Overlay Reason: New image detected")
elif not self.library.reapply_overlays and overlay_change:
logger.trace(f" Overlay applied because overlay changed {change_reason}")
logger.trace(f" Overlay Reason: Overlay changed {overlay_change}")
canvas_width, canvas_height = overlay.get_canvas_size(item)
with Image.open(poster.location if poster else has_original) as new_poster:
exif_tags = new_poster.getexif()

@ -199,65 +199,23 @@ def pick_image(title, images, prioritize_assets, download_url_assets, item_dir,
logger.debug(f"{len(images)} {image_type}{'s' if len(images) > 1 else ''} found:")
for i in images:
logger.debug(f"Method: {i} {image_type.capitalize()}: {images[i]}")
is_url = True
final_attr = None
if prioritize_assets and "asset_directory" in images:
return images["asset_directory"]
elif "image_set" in images:
final_attr = "image_set"
elif f"url_{image_type}" in images:
if download_url_assets and item_dir:
if "asset_directory" in images:
return images["asset_directory"]
else:
try:
return download_image(title, images[f"url_{image_type}"], item_dir, image_name)
except Failed as e:
logger.error(e)
final_attr = f"url_{image_type}"
elif f"file_{image_type}" in images:
final_attr = f"file_{image_type}"
is_url = False
elif f"tmdb_{image_type}" in images:
final_attr = f"tmdb_{image_type}"
elif "tmdb_profile" in images:
final_attr = "tmdb_profile"
elif "tmdb_list_poster" in images:
final_attr = "tmdb_list_poster"
elif "tvdb_list_poster" in images:
final_attr = "tvdb_list_poster"
elif f"tvdb_{image_type}" in images:
final_attr = f"tvdb_{image_type}"
elif "asset_directory" in images:
return images["asset_directory"]
elif "tmdb_person" in images:
final_attr = "tmdb_person"
elif "tmdb_collection_details" in images:
final_attr = "tmdb_collection_details"
elif "tmdb_actor_details" in images:
final_attr = "tmdb_actor_details"
elif "tmdb_crew_details" in images:
final_attr = "tmdb_crew_details"
elif "tmdb_director_details" in images:
final_attr = "tmdb_director_details"
elif "tmdb_producer_details" in images:
final_attr = "tmdb_producer_details"
elif "tmdb_writer_details" in images:
final_attr = "tmdb_writer_details"
elif "tmdb_movie_details" in images:
final_attr = "tmdb_movie_details"
elif "tmdb_list_details" in images:
final_attr = "tmdb_list_details"
elif "tvdb_list_details" in images:
final_attr = "tvdb_list_details"
elif "tvdb_movie_details" in images:
final_attr = "tvdb_movie_details"
elif "tvdb_show_details" in images:
final_attr = "tvdb_show_details"
elif "tmdb_show_details" in images:
final_attr = "tmdb_show_details"
if final_attr:
return ImageData(final_attr, images[final_attr], is_poster=is_poster, is_url=is_url)
if download_url_assets and item_dir and ("image_set" in images or f"url_{image_type}" in images):
if "asset_directory" in images:
return images["asset_directory"]
else:
try:
return download_image(title, images[f"url_{image_type}"], item_dir, image_name)
except Failed as e:
logger.error(e)
for attr in ["image_set", f"url_{image_type}", f"file_{image_type}", f"tmdb_{image_type}", "tmdb_profile",
"tmdb_list_poster", "tvdb_list_poster", f"tvdb_{image_type}", "asset_directory", "tmdb_person",
"tmdb_collection_details", "tmdb_actor_details", "tmdb_crew_details", "tmdb_director_details",
"tmdb_producer_details", "tmdb_writer_details", "tmdb_movie_details", "tmdb_list_details",
"tvdb_list_details", "tvdb_movie_details", "tvdb_show_details", "tmdb_show_details"]:
if attr in images:
return images[attr] if attr == "asset_directory" else ImageData(attr, images[attr], is_poster=is_poster, is_url=attr != f"file_{image_type}")
def add_dict_list(keys, value, dict_map):
for key in keys:

@ -1,11 +1,15 @@
import argparse, os, platform, psutil, sys, time, uuid
import argparse, os, platform, sys, time, uuid
from collections import Counter
from concurrent.futures import ProcessPoolExecutor
from datetime import datetime
from modules.logs import MyLogger
if sys.version_info[0] != 3 or sys.version_info[1] < 7:
print("Version Error: Version: %s.%s.%s incompatible please use Python 3.7+" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))
sys.exit(0)
try:
import plexapi, requests, schedule
import plexapi, psutil, requests, schedule
from PIL import ImageFile
from plexapi import server
from plexapi.exceptions import NotFound
@ -14,10 +18,6 @@ except (ModuleNotFoundError, ImportError):
print("Requirements Error: Requirements are not installed")
sys.exit(0)
if sys.version_info[0] != 3 or sys.version_info[1] < 7:
print("Version Error: Version: %s.%s.%s incompatible please use Python 3.7+" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))
sys.exit(0)
parser = argparse.ArgumentParser()
parser.add_argument("-db", "--debug", dest="debug", help="Run with Debug Logs Reporting to the Command Window", action="store_true", default=False)
parser.add_argument("-tr", "--trace", dest="trace", help="Run with extra Trace Debug Logs", action="store_true", default=False)

@ -1,4 +1,4 @@
PlexAPI==4.13.2
PlexAPI==4.13.4
tmdbapis==1.1.0
arrapi==1.4.2
lxml==4.9.2

Loading…
Cancel
Save