mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 20:43:07 +00:00
added country, network, mood, and style to auto collections
This commit is contained in:
parent
c5383f6993
commit
ace81d02a0
4 changed files with 50 additions and 38 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
1.15.1
|
1.15.1-develop220128
|
|
@ -9,6 +9,15 @@ logger = logging.getLogger("Plex Meta Manager")
|
||||||
|
|
||||||
github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/"
|
github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/"
|
||||||
|
|
||||||
|
all_auto = ["genre"]
|
||||||
|
|
||||||
|
auto = {
|
||||||
|
"Movie": ["tmdb_collection", "country"] + all_auto,
|
||||||
|
"Show": ["network"] + all_auto,
|
||||||
|
"Artist": ["mood", "style", "country"] + all_auto,
|
||||||
|
"Video": ["country"] + all_auto
|
||||||
|
}
|
||||||
|
|
||||||
def get_dict(attribute, attr_data, check_list=None):
|
def get_dict(attribute, attr_data, check_list=None):
|
||||||
if check_list is None:
|
if check_list is None:
|
||||||
check_list = []
|
check_list = []
|
||||||
|
@ -237,31 +246,38 @@ class MetadataFile(DataFile):
|
||||||
raise Failed(f"Config Error: {auto_name}'s auto_list attribute not found")
|
raise Failed(f"Config Error: {auto_name}'s auto_list attribute not found")
|
||||||
elif not auto_data[auto_methods["auto_list"]]:
|
elif not auto_data[auto_methods["auto_list"]]:
|
||||||
raise Failed(f"Config Error: {auto_name}'s auto_list attribute is blank")
|
raise Failed(f"Config Error: {auto_name}'s auto_list attribute is blank")
|
||||||
elif auto_data[auto_methods["auto_list"]] not in ["genre", "tmdb_collection"]:
|
elif auto_data[auto_methods["auto_list"]].lower() not in auto[library.type]:
|
||||||
raise Failed(f"Config Error: {auto_name}'s auto_list attribute {auto_data[auto_methods['auto_list']]} invalid")
|
raise Failed(f"Config Error: auto_list attribute {auto_data[auto_methods['auto_list']].lower()} invalid Options: {auto[library.type]}")
|
||||||
|
elif auto_data[auto_methods["auto_list"]].lower() == "network" and library.agent not in plex.new_plex_agents:
|
||||||
|
raise Failed(f"Config Error: network auto_list only works with the New Plex TV Agent")
|
||||||
else:
|
else:
|
||||||
auto_type = auto_data[auto_methods["auto_list"]]
|
auto_type = auto_data[auto_methods["auto_list"]].lower()
|
||||||
exclude = util.parse("Config", "exclude", auto_data, methods=auto_methods, datatype="list") if "exclude" in auto_methods else []
|
exclude = util.parse("Config", "exclude", auto_data, methods=auto_methods, datatype="list") if "exclude" in auto_methods else []
|
||||||
if auto_type == "genre":
|
if auto_type in ["genre", "mood", "style", "country", "network"]:
|
||||||
auto_list = {genre: genre for genre in library.get_genres() if genre not in exclude}
|
auto_list = {i.title: i.title for i in library.get_tags(auto_type) if i.title not in exclude}
|
||||||
default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "all": {"genre": "<<genre>>"}}}
|
if library.is_music:
|
||||||
default_title_format = "Top <<title>> <<library_type>>s"
|
use_filter = f"artist_{auto_type}"
|
||||||
elif auto_type == "tmdb_collection":
|
else:
|
||||||
auto_list = {}
|
use_filter = auto_type
|
||||||
items = library.get_all()
|
default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "all": {use_filter: f"<<{auto_type}>>"}}}
|
||||||
for i, item in enumerate(items, 1):
|
default_title_format = "Top <<title>> <<library_type>>s"
|
||||||
util.print_return(f"Processing: {i}/{len(items)} {item.title}")
|
elif auto_type == "tmdb_collection":
|
||||||
tmdb_id, tvdb_id, imdb_id = library.get_ids(item)
|
auto_list = {}
|
||||||
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=True)
|
items = library.get_all()
|
||||||
if tmdb_item and tmdb_item.collection and tmdb_item.collection.id not in exclude and tmdb_item.collection.name not in exclude:
|
for i, item in enumerate(items, 1):
|
||||||
auto_list[tmdb_item.collection.id] = tmdb_item.collection.name
|
util.print_return(f"Processing: {i}/{len(items)} {item.title}")
|
||||||
util.print_end()
|
tmdb_id, tvdb_id, imdb_id = library.get_ids(item)
|
||||||
default_template = {"tmdb_collection_details": "<<tmdb_collection>>"}
|
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=True)
|
||||||
default_title_format = "<<title>>"
|
if tmdb_item and tmdb_item.collection and tmdb_item.collection.id not in exclude and tmdb_item.collection.name not in exclude:
|
||||||
else:
|
auto_list[tmdb_item.collection.id] = tmdb_item.collection.name
|
||||||
raise Failed
|
util.print_end()
|
||||||
title_format = util.parse("Config", "title_format", auto_data, methods=auto_methods, default=default_title_format)
|
default_template = {"tmdb_collection_details": "<<tmdb_collection>>"}
|
||||||
|
default_title_format = "<<title>>"
|
||||||
|
else:
|
||||||
|
raise Failed(f"Config Error: {auto_name}'s auto_list attribute {auto_data[auto_methods['auto_list']]} invalid")
|
||||||
|
title_format = default_title_format
|
||||||
|
if "title_format" in auto_methods:
|
||||||
|
title_format = util.parse("Config", "title_format", auto_data, methods=auto_methods, default=default_title_format)
|
||||||
if "<<title>>" not in title_format:
|
if "<<title>>" not in title_format:
|
||||||
logger.error(f"Config Error: <<title>> not in title_format: {title_format} using default: {default_title_format}")
|
logger.error(f"Config Error: <<title>> not in title_format: {title_format} using default: {default_title_format}")
|
||||||
title_format = default_title_format
|
title_format = default_title_format
|
||||||
|
|
|
@ -542,10 +542,6 @@ class Plex(Library):
|
||||||
item.uploadPoster(filepath=image)
|
item.uploadPoster(filepath=image)
|
||||||
self.reload(item)
|
self.reload(item)
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
|
||||||
def get_genres(self):
|
|
||||||
return [genre.title for genre in self.Plex.listFilterChoices("genre")]
|
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
|
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
|
||||||
def get_search_choices(self, search_name, title=True):
|
def get_search_choices(self, search_name, title=True):
|
||||||
final_search = search_translation[search_name] if search_name in search_translation else search_name
|
final_search = search_translation[search_name] if search_name in search_translation else search_name
|
||||||
|
@ -569,8 +565,8 @@ class Plex(Library):
|
||||||
raise Failed(f"Plex Error: plex_search attribute: {search_name} not supported")
|
raise Failed(f"Plex Error: plex_search attribute: {search_name} not supported")
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
||||||
def get_labels(self):
|
def get_tags(self, tag):
|
||||||
return {label.title: label.key for label in self.Plex.listFilterChoices(field="label")}
|
return self.Plex.listFilterChoices(field=tag)
|
||||||
|
|
||||||
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
|
||||||
def _query(self, key, post=False, put=False):
|
def _query(self, key, post=False, put=False):
|
||||||
|
@ -606,7 +602,7 @@ class Plex(Library):
|
||||||
self._query(key, put=True)
|
self._query(key, put=True)
|
||||||
|
|
||||||
def smart_label_url(self, title, sort):
|
def smart_label_url(self, title, sort):
|
||||||
labels = self.get_labels()
|
labels = {l.title: l.key for l in self.get_tags("label")}
|
||||||
if title not in labels:
|
if title not in labels:
|
||||||
raise Failed(f"Plex Error: Label: {title} does not exist")
|
raise Failed(f"Plex Error: Label: {title} does not exist")
|
||||||
smart_type = 1 if self.is_movie else 2
|
smart_type = 1 if self.is_movie else 2
|
||||||
|
|
|
@ -626,14 +626,14 @@ def library_operations(config, library):
|
||||||
|
|
||||||
if library.genre_collections:
|
if library.genre_collections:
|
||||||
templates["Genre Collection"] = library.genre_collections["template"]
|
templates["Genre Collection"] = library.genre_collections["template"]
|
||||||
for genre in library.get_genres():
|
for genre in library.get_tags("genre"):
|
||||||
if genre not in library.genre_collections["exclude_genres"]:
|
if genre.title not in library.genre_collections["exclude_genres"]:
|
||||||
template = {"name": "Genre Collection", "genre": genre}
|
template = {"name": "Genre Collection", "genre": genre.title}
|
||||||
for k, v in library.genre_collections["dictionary_variables"].items():
|
for k, v in library.genre_collections["dictionary_variables"].items():
|
||||||
if genre in v:
|
if genre.title in v:
|
||||||
template[k] = v[genre]
|
template[k] = v[genre.title]
|
||||||
title = library.genre_collections["title_format"]
|
title = library.genre_collections["title_format"]
|
||||||
title = title.replace("<<genre>>", genre)
|
title = title.replace("<<genre>>", genre.title)
|
||||||
if "<<library_type>>" in title:
|
if "<<library_type>>" in title:
|
||||||
title = title.replace("<<library_type>>", library.type)
|
title = title.replace("<<library_type>>", library.type)
|
||||||
new_collections[title] = {"template": template}
|
new_collections[title] = {"template": template}
|
||||||
|
|
Loading…
Reference in a new issue