[35] add font_style and fixed assets

pull/935/head
meisnate12 3 years ago
parent 7eb8bc4e6b
commit bd89058ceb

@ -1 +1 @@
1.17.0-develop34
1.17.0-develop35

@ -82,6 +82,7 @@ There are many attributes available when using overlays to edit how they work.
| `vertical_offset` | Vertical Offset of this overlay. Can be a %.<br>**`horizontal_offset` is required when using `vertical_offset`**<br>**Value:** Integer 0 or greater or 0%-100% | &#10060; |
| `vertical_align` | Vertical Alignment of the overlay.<br>**Values:** `top`, `center`, `bottom` | &#10060; |
| `font` | System Font Filename or path to font file for the Text Overlay.<br>**Value:** System Font Filename or path to font file | &#10060; |
| `font_style` | Font style for Variable Fonts. Only needed when using a Variable Font.<br>**Value:** Variable Font Style | &#10060; |
| `font_size` | Font Size for the Text Overlay.<br>**Value:** Integer greater than 0 | &#10060; |
| `font_color` | Font Color for the Text Overlay.<br>**Value:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA`. | &#10060; |
| `back_color` | Backdrop Color for the Text Overlay.<br>**Value:** Color Hex Code in format `#RGB`, `#RGBA`, `#RRGGBB` or `#RRGGBBAA`. | &#10060; |

@ -782,7 +782,7 @@ class ConfigFile:
raise Failed("Config Error: overlay_path attribute is blank")
files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars)
if not files:
raise Failed("Config Error: No Paths Found for overlay_path")
logger.error("Config Error: No Paths Found for overlay_path")
for file in util.get_list(lib["overlay_path"], split=False):
if isinstance(file, dict):
if ("remove_overlays" in file and file["remove_overlays"] is True) \

@ -917,7 +917,7 @@ class MetadataFile(DataFile):
logger.info(f"{self.library.type}: {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
asset_location = self.library.item_images(item, meta, methods)
asset_location, folder_name = self.library.item_images(item, meta, methods)
if "seasons" in methods and self.library.is_show:
if not meta[methods["seasons"]]:
@ -948,7 +948,7 @@ class MetadataFile(DataFile):
finish_edit(season, f"Season: {season_id}")
self.library.item_images(season, season_dict, season_methods, asset_location=asset_location,
title=f"{item.title} Season {season.seasonNumber}",
image_name=f"Season{'0' if season.seasonNumber < 10 else ''}{season.seasonNumber}")
image_name=f"Season{'0' if season.seasonNumber < 10 else ''}{season.seasonNumber}", folder_name=folder_name)
logger.info(f"Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
if "episodes" in season_methods and self.library.is_show:
@ -985,7 +985,7 @@ class MetadataFile(DataFile):
finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}")
self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location,
title=f"{item.title} {episode.seasonEpisode.upper()}",
image_name=episode.seasonEpisode.upper())
image_name=episode.seasonEpisode.upper(), folder_name=folder_name)
logger.info(f"Episode {episode_str} in Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
if "episodes" in methods and self.library.is_show:
@ -1025,7 +1025,7 @@ class MetadataFile(DataFile):
finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}")
self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location,
title=f"{item.title} {episode.seasonEpisode.upper()}",
image_name=episode.seasonEpisode.upper())
image_name=episode.seasonEpisode.upper(), folder_name=folder_name)
logger.info(f"Episode S{season_id}E{episode_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
if "albums" in methods and self.library.is_music:
@ -1064,7 +1064,7 @@ class MetadataFile(DataFile):
updated = True
finish_edit(album, f"Album: {title}")
self.library.item_images(album, album_dict, album_methods, asset_location=asset_location,
title=f"{item.title} Album {album.title}", image_name=album.title)
title=f"{item.title} Album {album.title}", image_name=album.title, folder_name=folder_name)
logger.info(f"Album: {title} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
if "tracks" in album_methods:

@ -910,12 +910,12 @@ class Plex(Library):
logger.info(final)
return final
def item_images(self, item, group, alias, asset_location=None, title=None, image_name=None):
def item_images(self, item, group, alias, asset_location=None, title=None, image_name=None, folder_name=None):
if title is None:
title = item.title
posters, backgrounds = util.get_image_dicts(group, alias)
try:
asset_poster, asset_background, item_dir, _ = self.find_item_assets(item, item_asset_directory=asset_location)
asset_poster, asset_background, item_dir, folder_name = self.find_item_assets(item, item_asset_directory=asset_location)
if asset_poster:
posters["asset_directory"] = asset_poster
if asset_background:
@ -929,7 +929,7 @@ class Plex(Library):
is_poster=False, image_name=f"{image_name}_background" if image_name else image_name)
if poster or background:
self.upload_images(item, poster=poster, background=background)
return asset_location
return asset_location, folder_name
def find_and_upload_assets(self, item):
try:
@ -945,7 +945,7 @@ class Plex(Library):
found_season = False
found_episode = False
for season in self.query(item.seasons):
season_poster, season_background, _, _ = self.find_item_assets(season, item_asset_directory=item_dir)
season_poster, season_background, _, _ = self.find_item_assets(season, item_asset_directory=item_dir, folder_name=name)
if season_poster:
found_season = True
elif self.show_missing_season_assets and season.seasonNumber > 0:
@ -954,7 +954,7 @@ class Plex(Library):
self.upload_images(season, poster=season_poster, background=season_background)
for episode in self.query(season.episodes):
if episode.seasonEpisode:
episode_poster, episode_background, _, _ = self.find_item_assets(episode, item_asset_directory=item_dir)
episode_poster, episode_background, _, _ = self.find_item_assets(episode, item_asset_directory=item_dir, folder_name=name)
if episode_poster or episode_background:
found_episode = True
self.upload_images(episode, poster=episode_poster, background=episode_background)
@ -966,7 +966,7 @@ class Plex(Library):
missing_assets = ""
found_album = False
for album in self.query(item.albums):
album_poster, album_background, _, _ = self.find_item_assets(album, item_asset_directory=item_dir)
album_poster, album_background, _, _ = self.find_item_assets(album, item_asset_directory=item_dir, folder_name=name)
if album_poster or album_background:
found_album = True
elif self.show_missing_season_assets:
@ -979,10 +979,9 @@ class Plex(Library):
if self.show_missing_assets:
logger.warning(e)
def find_item_assets(self, item, item_asset_directory=None, asset_directory=None):
def find_item_assets(self, item, item_asset_directory=None, asset_directory=None, folder_name=None):
poster = None
background = None
folder_name = None
if asset_directory is None:
asset_directory = self.asset_directory
@ -1015,9 +1014,10 @@ class Plex(Library):
else:
folder_name, _ = util.validate_filename(item)
if not self.asset_folders:
file_name = folder_name if file_name == "poster" else f"{folder_name}_{file_name}"
if not self.asset_folders:
file_name = folder_name if file_name == "poster" else f"{folder_name}_{file_name}"
if not item_asset_directory:
for ad in asset_directory:
if self.asset_folders:
if os.path.isdir(os.path.join(ad, folder_name)):

@ -1024,7 +1024,16 @@ class Overlay:
if font not in fonts:
raise Failed(f"Overlay Error: font: {font} not found. Options: {', '.join(fonts)}")
self.font_name = font
self.font = ImageFont.truetype(self.font_name, self.font_size)
self.font = ImageFont.truetype(self.font_name, self.font_size)
if "font_style" in self.data and self.data["font_style"]:
try:
variation_names = [n.decode("utf-8") for n in self.font.get_variation_names()]
if self.data["font_style"] in variation_names:
self.font.set_variation_by_name(self.data["font_style"])
else:
raise Failed(f"Overlay Error: Font Style {self.data['font_style']} not found. Options: {','.join(variation_names)}")
except OSError:
logger.warning(f"Overlay Warning: font: {self.font} does not have variations")
self.font_color = None
if "font_color" in self.data and self.data["font_color"]:
try:

Loading…
Cancel
Save