mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[30] add file to overlay_path
This commit is contained in:
parent
8d1725d397
commit
e962d56e4e
9 changed files with 44 additions and 36 deletions
2
.github/workflows/develop.yml
vendored
2
.github/workflows/develop.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
webhook_id: ${{ secrets.DEVELOP_WEBHOOK_ID }}
|
webhook_id: ${{ secrets.DEVELOP_WEBHOOK_ID }}
|
||||||
webhook_token: ${{ secrets.DEVELOP_WEBHOOK_TOKEN }}
|
webhook_token: ${{ secrets.DEVELOP_WEBHOOK_TOKEN }}
|
||||||
title: Plex Meta Manager Develop Commits
|
title: Plex Meta Manager Develop Commits
|
||||||
message: "@Develop Notifications"
|
message: "<@&954835263731949623>"
|
||||||
commits: "true"
|
commits: "true"
|
||||||
username: Metabot
|
username: Metabot
|
||||||
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/develop/.github/pmm.png
|
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/develop/.github/pmm.png
|
||||||
|
|
2
.github/workflows/nightly.yml
vendored
2
.github/workflows/nightly.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
webhook_id: ${{ secrets.NIGHTLY_WEBHOOK_ID }}
|
webhook_id: ${{ secrets.NIGHTLY_WEBHOOK_ID }}
|
||||||
webhook_token: ${{ secrets.NIGHTLY_WEBHOOK_TOKEN }}
|
webhook_token: ${{ secrets.NIGHTLY_WEBHOOK_TOKEN }}
|
||||||
title: Nightly Commits
|
title: Nightly Commits
|
||||||
message: "@Nightly Notifications"
|
message: "<@&967002147520675840>"
|
||||||
commits: "true"
|
commits: "true"
|
||||||
username: Metabot
|
username: Metabot
|
||||||
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/nightly/.github/pmm.png
|
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/nightly/.github/pmm.png
|
||||||
|
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
@ -18,6 +18,6 @@ jobs:
|
||||||
webhook_token: ${{ secrets.RELEASE_WEBHOOK_TOKEN }}
|
webhook_token: ${{ secrets.RELEASE_WEBHOOK_TOKEN }}
|
||||||
release: true
|
release: true
|
||||||
title: Plex Meta Manager Release VERSION
|
title: Plex Meta Manager Release VERSION
|
||||||
message: "@Master Notifications"
|
message: "<@&967002324646113290>"
|
||||||
username: Metabot
|
username: Metabot
|
||||||
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/master/.github/pmm.png
|
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/master/.github/pmm.png
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.16.5-develop29
|
1.16.5-develop30
|
||||||
|
|
|
@ -1628,15 +1628,17 @@ For example, when using `type: tmdb_collection` and you want to define a poster
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
templates:
|
templates:
|
||||||
optional:
|
my_template:
|
||||||
- my_collection_poster
|
optional:
|
||||||
tmdb_collection_details: <<value>>
|
- my_collection_poster
|
||||||
collection_order: release
|
tmdb_collection_details: <<value>>
|
||||||
url_poster: <<my_collection_poster>>
|
collection_order: release
|
||||||
|
url_poster: <<my_collection_poster>>
|
||||||
dynamic_collections:
|
dynamic_collections:
|
||||||
TMDb Collections: # This name is the mapping name
|
TMDb Collections: # This name is the mapping name
|
||||||
type: tmdb_collection
|
type: tmdb_collection
|
||||||
remove_suffix: "Collection"
|
remove_suffix: "Collection"
|
||||||
|
template: my_template
|
||||||
template_variables:
|
template_variables:
|
||||||
my_collection_poster:
|
my_collection_poster:
|
||||||
119: https://www.themoviedb.org/t/p/original/oENY593nKRVL2PnxXsMtlh8izb4.jpg
|
119: https://www.themoviedb.org/t/p/original/oENY593nKRVL2PnxXsMtlh8izb4.jpg
|
||||||
|
|
|
@ -59,7 +59,8 @@ You can specify the Overlay Name in 3 ways.
|
||||||
| Attribute | Description | Required |
|
| Attribute | Description | Required |
|
||||||
|:----------|:--------------------------------------------------------------------------------------------------------------|:--------:|
|
|:----------|:--------------------------------------------------------------------------------------------------------------|:--------:|
|
||||||
| `name` | Name of the overlay. Each overlay name should be unique. | ✅ |
|
| `name` | Name of the overlay. Each overlay name should be unique. | ✅ |
|
||||||
| `url` | URL of Overlay Image Onlin. | ❌ |
|
| `file` | Local location of the Overlay Image. | ❌ |
|
||||||
|
| `url` | URL of Overlay Image Online. | ❌ |
|
||||||
| `git` | Location in the [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs) of the Overlay Image. | ❌ |
|
| `git` | Location in the [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs) of the Overlay Image. | ❌ |
|
||||||
| `repo` | Location in the [Custom Repo](../config/settings.md#custom-repo) of the Overlay Image. | ❌ |
|
| `repo` | Location in the [Custom Repo](../config/settings.md#custom-repo) of the Overlay Image. | ❌ |
|
||||||
| `group` | Name of the Grouping for this overlay. **`weight` is required when using `group`** | ❌ |
|
| `group` | Name of the Grouping for this overlay. **`weight` is required when using `group`** | ❌ |
|
||||||
|
|
|
@ -271,6 +271,7 @@ class CollectionBuilder:
|
||||||
self.suppress_overlays = []
|
self.suppress_overlays = []
|
||||||
self.overlay_group = None
|
self.overlay_group = None
|
||||||
self.overlay_weight = None
|
self.overlay_weight = None
|
||||||
|
self.overlay_path = None
|
||||||
if self.overlay:
|
if self.overlay:
|
||||||
if "overlay" in methods:
|
if "overlay" in methods:
|
||||||
logger.debug("")
|
logger.debug("")
|
||||||
|
@ -289,31 +290,33 @@ class CollectionBuilder:
|
||||||
self.overlay_weight = pri
|
self.overlay_weight = pri
|
||||||
else:
|
else:
|
||||||
raise Failed(f"{self.Type} Error: overlay group and overlay weight must be used together")
|
raise Failed(f"{self.Type} Error: overlay group and overlay weight must be used together")
|
||||||
if "git" in data[methods["overlay"]] and data[methods["overlay"]]["git"]:
|
def get_and_save_image(image_url):
|
||||||
url = f"{util.github_base}{data[methods['overlay']]['git']}.png"
|
response = self.config.get(image_url)
|
||||||
elif "repo" in data[methods["overlay"]] and data[methods["overlay"]]["repo"]:
|
|
||||||
url = f"{self.config.custom_repo}{data[methods['overlay']]['git']}.png"
|
|
||||||
elif "url" in data[methods["overlay"]] and data[methods["overlay"]]["url"]:
|
|
||||||
url = data[methods["overlay"]]["url"]
|
|
||||||
else:
|
|
||||||
url = None
|
|
||||||
if url:
|
|
||||||
response = self.config.get(url)
|
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
raise Failed(f"{self.Type} Error: Overlay Image not found at: {url}")
|
raise Failed(f"{self.Type} Error: Overlay Image not found at: {image_url}")
|
||||||
if "Content-Type" not in response.headers or response.headers["Content-Type"] != "image/png":
|
if "Content-Type" not in response.headers or response.headers["Content-Type"] != "image/png":
|
||||||
raise Failed(f"{self.Type} Error: Overlay Image not a png: {url}")
|
raise Failed(f"{self.Type} Error: Overlay Image not a png: {url}")
|
||||||
if not os.path.exists(library.overlay_folder) or not os.path.isdir(library.overlay_folder):
|
if not os.path.exists(library.overlay_folder) or not os.path.isdir(library.overlay_folder):
|
||||||
os.makedirs(library.overlay_folder, exist_ok=False)
|
os.makedirs(library.overlay_folder, exist_ok=False)
|
||||||
logger.info(f"Creating Overlay Folder found at: {library.overlay_folder}")
|
logger.info(f"Creating Overlay Folder found at: {library.overlay_folder}")
|
||||||
clean_name, _ = util.validate_filename(self.overlay)
|
clean_image_name, _ = util.validate_filename(self.overlay)
|
||||||
overlay_path = os.path.join(library.overlay_folder, f"{clean_name}.png")
|
image_path = os.path.join(library.overlay_folder, f"{clean_image_name}.png")
|
||||||
if os.path.exists(overlay_path):
|
if os.path.exists(image_path):
|
||||||
os.remove(overlay_path)
|
os.remove(image_path)
|
||||||
with open(overlay_path, "wb") as handler:
|
with open(image_path, "wb") as handler:
|
||||||
handler.write(response.content)
|
handler.write(response.content)
|
||||||
while util.is_locked(overlay_path):
|
while util.is_locked(image_path):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
return image_path
|
||||||
|
|
||||||
|
if "file" in data[methods["overlay"]] and data[methods["overlay"]]["file"]:
|
||||||
|
self.overlay_path = data[methods["overlay"]]["file"]
|
||||||
|
elif "git" in data[methods["overlay"]] and data[methods["overlay"]]["git"]:
|
||||||
|
self.overlay_path = get_and_save_image(f"{util.github_base}{data[methods['overlay']]['git']}.png")
|
||||||
|
elif "repo" in data[methods["overlay"]] and data[methods["overlay"]]["repo"]:
|
||||||
|
self.overlay_path = get_and_save_image(f"{self.config.custom_repo}{data[methods['overlay']]['repo']}.png")
|
||||||
|
elif "url" in data[methods["overlay"]] and data[methods["overlay"]]["url"]:
|
||||||
|
self.overlay_path = get_and_save_image(data[methods["overlay"]]["url"])
|
||||||
else:
|
else:
|
||||||
self.overlay = str(data[methods["overlay"]])
|
self.overlay = str(data[methods["overlay"]])
|
||||||
else:
|
else:
|
||||||
|
@ -328,10 +331,12 @@ class CollectionBuilder:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.error(f"Overlay Error: failed to parse overlay blur name: {self.overlay} defaulting to blur(50)")
|
logger.error(f"Overlay Error: failed to parse overlay blur name: {self.overlay} defaulting to blur(50)")
|
||||||
self.overlay = "blur(50)"
|
self.overlay = "blur(50)"
|
||||||
|
else:
|
||||||
overlay_path = os.path.join(library.overlay_folder, f"{self.overlay}.png")
|
if not self.overlay_path:
|
||||||
if not self.overlay.startswith("blur") and not os.path.exists(overlay_path):
|
clean_name, _ = util.validate_filename(self.overlay)
|
||||||
raise Failed(f"{self.Type} Error: Overlay Image not found at: {overlay_path}")
|
self.overlay_path = os.path.join(library.overlay_folder, f"{clean_name}.png")
|
||||||
|
if not os.path.exists(self.overlay_path):
|
||||||
|
raise Failed(f"{self.Type} Error: Overlay Image not found at: {self.overlay_path}")
|
||||||
|
|
||||||
if "suppress_overlays" in methods:
|
if "suppress_overlays" in methods:
|
||||||
logger.debug("")
|
logger.debug("")
|
||||||
|
|
|
@ -92,6 +92,8 @@ class DataFile:
|
||||||
else:
|
else:
|
||||||
raise Failed(f"File Error: File does not exist {os.path.abspath(file_path)}")
|
raise Failed(f"File Error: File does not exist {os.path.abspath(file_path)}")
|
||||||
data, _, _ = yaml.util.load_yaml_guess_indent(content)
|
data, _, _ = yaml.util.load_yaml_guess_indent(content)
|
||||||
|
if not data or not isinstance(data, dict):
|
||||||
|
raise Failed("YAML Error: File is empty")
|
||||||
return data
|
return data
|
||||||
except yaml.scanner.ScannerError as ye:
|
except yaml.scanner.ScannerError as ye:
|
||||||
raise Failed(f"YAML Error: {util.tab_new_lines(ye)}")
|
raise Failed(f"YAML Error: {util.tab_new_lines(ye)}")
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Overlays:
|
||||||
if builder.overlay not in settings:
|
if builder.overlay not in settings:
|
||||||
settings[builder.overlay] = {
|
settings[builder.overlay] = {
|
||||||
"keys": [], "suppress": builder.suppress_overlays, "group": builder.overlay_group,
|
"keys": [], "suppress": builder.suppress_overlays, "group": builder.overlay_group,
|
||||||
"weight": builder.overlay_weight, "updated": False, "image": None
|
"weight": builder.overlay_weight, "path": builder.overlay_path, "updated": False, "image": None
|
||||||
}
|
}
|
||||||
|
|
||||||
for method, value in builder.builders:
|
for method, value in builder.builders:
|
||||||
|
@ -78,14 +78,12 @@ class Overlays:
|
||||||
if suppress_name in settings and rk in settings[suppress_name]["keys"]:
|
if suppress_name in settings and rk in settings[suppress_name]["keys"]:
|
||||||
settings[suppress_name]["keys"].remove(rk)
|
settings[suppress_name]["keys"].remove(rk)
|
||||||
if not overlay_name.startswith("blur"):
|
if not overlay_name.startswith("blur"):
|
||||||
clean_name, _ = util.validate_filename(overlay_name)
|
|
||||||
image_compare = None
|
image_compare = None
|
||||||
if self.config.Cache:
|
if self.config.Cache:
|
||||||
_, image_compare, _ = self.config.Cache.query_image_map(overlay_name, f"{self.library.image_table_name}_overlays")
|
_, image_compare, _ = self.config.Cache.query_image_map(overlay_name, f"{self.library.image_table_name}_overlays")
|
||||||
overlay_file = os.path.join(self.library.overlay_folder, f"{clean_name}.png")
|
overlay_size = os.stat(settings[overlay_name]["path"]).st_size
|
||||||
overlay_size = os.stat(overlay_file).st_size
|
|
||||||
settings[overlay_name]["updated"] = not image_compare or str(overlay_size) != str(image_compare)
|
settings[overlay_name]["updated"] = not image_compare or str(overlay_size) != str(image_compare)
|
||||||
settings[overlay_name]["image"] = Image.open(overlay_file).convert("RGBA")
|
settings[overlay_name]["image"] = Image.open(settings[overlay_name]["path"]).convert("RGBA")
|
||||||
if self.config.Cache:
|
if self.config.Cache:
|
||||||
self.config.Cache.update_image_map(overlay_name, f"{self.library.image_table_name}_overlays", overlay_name, overlay_size)
|
self.config.Cache.update_image_map(overlay_name, f"{self.library.image_table_name}_overlays", overlay_name, overlay_size)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue