Skip to content

Commit

Permalink
[42] add reset_overlays option
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Jul 19, 2022
1 parent 11415b9 commit 9111f77
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.1-develop41
1.17.1-develop42
30 changes: 28 additions & 2 deletions docs/config/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ libraries:

#### Remove Overlays

You can remove overlays from a library by adding `remove_overlays: true` to `overlay_path`.
You can remove overlays from a library by adding `remove_overlays: true` to `overlay_path`. This will remove all overlays when run and not generate new ones.

```yaml
libraries:
Expand All @@ -166,7 +166,33 @@ libraries:
- file: config/Overlays.yml
```

* This will remove all overlays when run and not generate new ones.
#### Reapply Overlays

You can reapply overlays from a library by adding `reapply_overlays: true` to `overlay_path`. This will reapply overlays to every item in your library.

```yaml
libraries:
TV Shows:
metadata_path:
- file: config/TV Shows.yml
overlay_path:
- reapply_overlays: true
- file: config/Overlays.yml
```

#### Reset Overlays

You can reset overlays from a library by adding `reset_overlays` to `overlay_path` and setting it to either `tmdb` or `plex` depending on where you want to source the images from. This will use the reset image when overlaying items in your library.

```yaml
libraries:
TV Shows:
metadata_path:
- file: config/TV Shows.yml
overlay_path:
- reset_overlays: plex
- file: config/Overlays.yml
```

### Report Path

Expand Down
5 changes: 2 additions & 3 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test", "suppress_overlays",
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level", "overlay",
"validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection",
"allowed_library_types", "delete_playlist"
"allowed_library_types", "delete_playlist", "ignore_blank_results"
]
details = [
"ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme",
Expand Down Expand Up @@ -157,8 +157,7 @@
episode_parts_only = ["plex_pilots"]
overlay_only = ["overlay", "suppress_overlays"]
overlay_attributes = [
"filters", "limit", "show_missing", "save_report", "missing_only_released", "minimum_items", "cache_builders",
"tmdb_region", "default_percent", "ignore_blank_results"
"filters", "limit", "show_missing", "save_report", "missing_only_released", "minimum_items", "cache_builders", "tmdb_region", "default_percent"
] + all_builders + overlay_only
parts_collection_valid = [
"filters", "plex_all", "plex_search", "trakt_list", "trakt_list_details", "collection_filtering", "collection_mode", "label", "visible_library", "limit",
Expand Down
11 changes: 11 additions & 0 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"anidb_rating": "Use AniDB Rating",
"anidb_average": "Use AniDB Average"
}
reset_overlay_options = {"tmdb": "Reset to TMDb poster", "plex": "Reset to Plex Poster"}

class ConfigFile:
def __init__(self, default_dir, attrs):
Expand Down Expand Up @@ -783,6 +784,7 @@ def error_check(attr, service):
params["overlay_path"] = []
params["remove_overlays"] = False
params["reapply_overlays"] = False
params["reset_overlays"] = None
if lib and "overlay_path" in lib:
try:
if not lib["overlay_path"]:
Expand All @@ -799,6 +801,15 @@ def error_check(attr, service):
if ("reapply_overlays" in file and file["reapply_overlays"] is True) \
or ("reapply_overlay" in file and file["reapply_overlay"] is True):
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]
else:
final_text = f"Config Error: reset_overlays attribute {file[attr]} invalid. Options: "
for option, description in reset_overlay_options.items():
final_text = f"{final_text}\n {option} ({description})"
logger.error(final_text)
if "schedule" in file and file["schedule"]:
logger.debug(f"Value: {file['schedule']}")
err = None
Expand Down
1 change: 1 addition & 0 deletions modules/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, config, params):
self.remove_title_parentheses = params["remove_title_parentheses"]
self.remove_overlays = params["remove_overlays"]
self.reapply_overlays = params["reapply_overlays"]
self.reset_overlays = params["reset_overlays"]
self.mass_collection_mode = params["mass_collection_mode"]
self.metadata_backup = params["metadata_backup"]
self.genre_mapper = params["genre_mapper"]
Expand Down
2 changes: 1 addition & 1 deletion modules/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def update_metadata(self):
item = self.library.search_item(alt_title)

if item is None:
logger.error(f"Skipping {mapping_name}: Item {mapping_name} not found")
logger.error(f"Skipping {mapping_name}: Item {title} not found")
continue
if not isinstance(item, list):
item = [item]
Expand Down
11 changes: 8 additions & 3 deletions modules/overlays.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,19 @@ def run_overlays(self):
if image_compare and str(poster.compare) != str(image_compare):
changed_image = True
elif has_overlay:
if os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")):
if self.library.reset_overlays is not None:
if self.library.reset_overlays == "tmdb":
new_backup = self.find_poster_url(item)
else:
posters = item.posters()
if posters:
new_backup = posters[0]
elif os.path.exists(os.path.join(self.library.overlay_backup, f"{item.ratingKey}.png")):
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")
else:
new_backup = self.find_poster_url(item)
if new_backup is None:
new_backup = item.posterUrl
else:
new_backup = item.posterUrl
if new_backup:
Expand Down

0 comments on commit 9111f77

Please sign in to comment.