added tmdb_person

This commit is contained in:
meisnate12 2021-01-26 16:47:46 -05:00
parent e17ba7945c
commit c5c1ee25dc
3 changed files with 1010 additions and 397 deletions

File diff suppressed because it is too large Load diff

View file

@ -408,8 +408,16 @@ class Config:
logger.info("")
util.seperator("{} Collection".format(c))
logger.info("")
map = {}
details = {}
methods = []
filters = []
posters_found = []
backgrounds_found = []
collectionless = "plex_collectionless" in collections[c]
skip_collection = True
if "schedule" not in collections[c]:
skip_collection = False
elif not collections[c]["schedule"]:
@ -464,18 +472,10 @@ class Config:
logger.error("Collection Error: failed to parse schedule: {}".format(schedule))
else:
logger.error("Collection Error: schedule attribute {} invalid".format(schedule))
if skip_collection:
logger.info("Skipping Collection {}".format(c))
continue
map = {}
details = {}
methods = []
filters = []
posters_found = []
backgrounds_found = []
try:
collection_obj = library.get_collection(c)
collection_name = collection_obj.title
@ -483,7 +483,6 @@ class Config:
collection_obj = None
collection_name = c
sync_collection = library.sync_mode == "sync"
if "sync_mode" in collections[c]:
if not collections[c]["sync_mode"]: logger.warning("Collection Warning: sync_mode attribute is blank using general: {}".format(library.sync_mode))
@ -497,6 +496,25 @@ class Config:
else:
logger.info("Sync Mode: append")
if "tmdb_person" in collections[c]:
if collections[c]["tmdb_person"]:
valid_names = []
for tmdb_id in util.get_int_list(collections[c]["tmdb_person"], "TMDb Person ID"):
try:
person = self.TMDb.get_person(tmdb_id)
valid_names.append(person.name)
if "summary" not in details and hasattr(person, "biography") and person.biography:
details["summary"] = person.biography
if "poster" not in details and hasattr(person, "profile_path") and person.profile_path:
details["poster"] = ("url", "{}{}".format(self.TMDb.image_url, person.profile_path), "tmdb_person")
except Failed as e:
util.print_stacktrace()
logger.error(e)
if len(valid_names) > 0: details["tmdb_person"] = valid_names
else: logger.error("Collection Error: No valid TMDb Person IDs in {}".format(collections[c]["tmdb_person"]))
else:
logger.error("Collection Error: tmdb_person attribute is blank")
for m in collections[c]:
try:
if "tmdb" in m and not self.TMDb:
@ -508,7 +526,7 @@ class Config:
elif "imdb" in m and not self.IMDb:
logger.info("Collection Error: {} skipped. TMDb or Trakt must be configured".format(m))
map = {}
elif m == "tautulli" and not library.Tautulli:
elif "tautulli" in m and not library.Tautulli:
logger.info("Collection Error: {} skipped. Tautulli must be configured".format(m))
map = {}
elif "mal" in m and not self.MyAnimeList:
@ -537,8 +555,8 @@ class Config:
if collections[c][m] in ["release", "alpha"]: details[method_name] = collections[c][m]
else: raise Failed("Collection Error: {} collection_order Invalid\n| \trelease (Order Collection by release dates)\n| \talpha (Order Collection Alphabetically)".format(collections[c][m]))
elif method_name == "url_poster": posters_found.append(("url", collections[c][m], method_name))
elif method_name == "tmdb_poster": posters_found.append(("url", "{}{}".format(self.TMDb.image_url, self.get_movie_show_or_collection(util.regex_first_int(collections[c][m], "TMDb ID"), library.is_movie).poster_path), method_name))
elif method_name == "tmdb_profile": posters_found.append(("url", "{}{}".format(self.TMDb.image_url, self.get_person(util.regex_first_int(collections[c][m], "TMDb Person ID")).profile_path), method_name))
elif method_name == "tmdb_poster": posters_found.append(("url", "{}{}".format(self.TMDb.image_url, self.TMDb.get_movie_show_or_collection(util.regex_first_int(collections[c][m], "TMDb ID"), library.is_movie).poster_path), method_name))
elif method_name == "tmdb_profile": posters_found.append(("url", "{}{}".format(self.TMDb.image_url, self.TMDb.get_person(util.regex_first_int(collections[c][m], "TMDb Person ID")).profile_path), method_name))
elif method_name == "file_poster":
if os.path.exists(collections[c][m]): posters_found.append(("file", os.path.abspath(collections[c][m]), method_name))
else: raise Failed("Collection Error: Poster Path Does Not Exist: {}".format(os.path.abspath(collections[c][m])))
@ -553,22 +571,15 @@ class Config:
elif method_name in util.all_details: details[method_name] = collections[c][m]
elif method_name in ["year", "year.not"]: methods.append(("plex_search", [[(method_name, util.get_year_list(collections[c][m], method_name))]]))
elif method_name in ["decade", "decade.not"]: methods.append(("plex_search", [[(method_name, util.get_int_list(collections[c][m], util.remove_not(method_name)))]]))
elif method_name in ["actor_details_tmdb", "director_details_tmdb", "writer_details_tmdb"]:
valid_ids = []
for tmdb_id in util.get_int_list(collections[c][m], "TMDb Person ID"):
try:
person = self.TMDb.get_person(tmdb_id)
valid_ids.append(person.name)
if "summary" not in details and hasattr(person, "biography") and person.biography:
details["summary"] = person.biography
if "poster" not in details and hasattr(person, "profile_path") and person.profile_path:
details["poster"] = ("url", "{}{}".format(self.TMDb.image_url, person.profile_path), method_name)
except Failed as e:
util.print_stacktrace()
logger.error(e)
if len(valid_ids) == 0:
raise Failed("Collection Error: No valid TMDb Person IDs in {}".format(collections[c][m]))
methods.append(("plex_search", [[(method_name[:-13], valid_ids)]]))
elif method_name in util.tmdb_searches:
final_values = []
for value in util.get_list(collections[c][m]):
if value.lower() == "tmdb" and "tmdb_person" in details:
for name in details["tmdb_person"]:
final_values.append(name)
else:
final_values.append(value)
methods.append(("plex_search", [[(method_name, final_values)]]))
elif method_name in util.plex_searches: methods.append(("plex_search", [[(method_name, util.get_list(collections[c][m]))]]))
elif method_name == "plex_all": methods.append((method_name, [""]))
elif method_name == "plex_collection": methods.append((method_name, library.validate_collections(collections[c][m] if isinstance(collections[c][m], list) else [collections[c][m]])))
@ -810,7 +821,7 @@ class Config:
else:
methods.append((method_name, values))
elif method_name in util.all_lists: methods.append((method_name, util.get_list(collections[c][m])))
elif method_name not in ["sync_mode", "schedule"]: logger.error("Collection Error: {} attribute not supported".format(method_name))
elif method_name not in ["sync_mode", "schedule", "tmdb_person"]: logger.error("Collection Error: {} attribute not supported".format(method_name))
else:
logger.error("Collection Error: {} attribute is blank".format(m))
except Failed as e:

View file

@ -29,6 +29,7 @@ method_alias = {
"directors": "director",
"genres": "genre",
"studios": "studio", "network": "studio", "networks": "studio",
"producers": "producer",
"writers": "writer",
"years": "year"
}
@ -122,6 +123,7 @@ pretty_names = {
"tmdb_movie_details": "TMDb Movie",
"tmdb_network": "TMDb Network",
"tmdb_now_playing": "TMDb Now Playing",
"tmdb_person": "TMDb Person",
"tmdb_popular": "TMDb Popular",
"tmdb_show": "TMDb Show",
"tmdb_show_details": "TMDb Show",
@ -259,13 +261,14 @@ dictionary_lists = [
"tmdb_discover"
]
plex_searches = [
"actor", "actor_details_tmdb", #"actor.not", # Waiting on PlexAPI to fix issue
"actor", #"actor.not", # Waiting on PlexAPI to fix issue
"country", #"country.not",
"decade", #"decade.not",
"director", "director_details_tmdb", #"director.not",
"director", #"director.not",
"genre", #"genre.not",
"producer", #"producer.not",
"studio", #"studio.not",
"writer", "writer_details_tmdb", #"writer.not"
"writer", #"writer.not"
"year" #"year.not",
]
show_only_lists = [
@ -275,17 +278,26 @@ show_only_lists = [
"tvdb_show"
]
movie_only_lists = [
"actor_details_tmdb",
"director_details_tmdb",
"tmdb_collection",
"tmdb_collection_details",
"tmdb_movie",
"tmdb_movie_details",
"tmdb_now_playing",
"writer_details_tmdb"
"tvdb_movie"
]
movie_only_searches = [
"actor", "actor_details_tmdb", #"actor.not", # Waiting on PlexAPI to fix issue
"country", #"country.not",
"decade", #"decade.not",
"director", "director_details_tmdb", #"director.not",
"writer", "writer_details_tmdb" #"writer.not"
"actor", "actor.not",
"country", "country.not",
"decade", "decade.not",
"director", "director.not",
"producer", "producer.not",
"writer", "writer.not"
]
tmdb_searches = [
"actor", "actor.not",
"director", "director.not",
"producer", "producer.not",
"writer", "writer.not"
]
count_lists = [
"anidb_popular",
@ -335,6 +347,7 @@ tmdb_type = {
"tmdb_movie": "Movie",
"tmdb_movie_details": "Movie",
"tmdb_network": "Network",
"tmdb_person": "Person",
"tmdb_show": "Show",
"tmdb_show_details": "Show"
}