added more tmdb person searches #70

pull/76/head
meisnate12 4 years ago
parent c20459421f
commit 9070ea8cfc

2
.gitignore vendored

@ -9,7 +9,7 @@ __pycache__/
# Distribution / packaging
.idea
.Python
/modules/test.py
/test.py
logs/
config/*
!config/*.template

@ -80,6 +80,11 @@ class TMDbAPI:
try: return self.Person.details(tmdb_id)
except TMDbException as e: raise Failed(f"TMDb Error: No Person found for TMDb ID {tmdb_id}: {e}")
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
def get_person_credits(self, tmdb_id):
try: return self.Person.combined_credits(tmdb_id)
except TMDbException as e: raise Failed(f"TMDb Error: No Person found for TMDb ID {tmdb_id}: {e}")
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
def get_company(self, tmdb_id):
try: return self.Company.details(tmdb_id)
@ -100,6 +105,27 @@ class TMDbAPI:
try: return self.List.details(tmdb_id, all_details=True)
except TMDbException as e: raise Failed(f"TMDb Error: No List found for TMDb ID {tmdb_id}: {e}")
def get_credits(self, tmdb_id, actor=False, crew=False, director=False, producer=False, writer=False):
movie_ids = []
show_ids = []
actor_credits = self.get_person_credits(tmdb_id)
if actor:
for credit in actor_credits.cast:
if credit.media_type == "movie":
movie_ids.append(credit.id)
elif credit.media_type == "tv":
show_ids.append(credit.id)
for credit in actor_credits.crew:
if crew or \
(director and credit.department == "Directing") or \
(producer and credit.department == "Production") or \
(writer and credit.department == "Writing"):
if credit.media_type == "movie":
movie_ids.append(credit.id)
elif credit.media_type == "tv":
show_ids.append(credit.id)
return movie_ids, show_ids
def get_pagenation(self, method, amount, is_movie):
ids = []
count = 0
@ -201,13 +227,18 @@ class TMDbAPI:
movie_ids.append(tmdb_item["id"])
elif method == "tmdb_show":
tmdb_name = str(self.get_show(tmdb_id).name)
try: show_ids.append(self.convert_tmdb_to_tvdb(tmdb_id))
except Failed: pass
show_ids.append(self.convert_tmdb_to_tvdb(tmdb_id))
else:
raise Failed(f"TMDb Error: Method {method} not supported")
tmdb_name = str(self.get_person(tmdb_id).name)
if method == "tmdb_actor": movie_ids, show_ids = self.get_credits(tmdb_id, actor=True)
elif method == "tmdb_director": movie_ids, show_ids = self.get_credits(tmdb_id, director=True)
elif method == "tmdb_producer": movie_ids, show_ids = self.get_credits(tmdb_id, producer=True)
elif method == "tmdb_writer": movie_ids, show_ids = self.get_credits(tmdb_id, writer=True)
elif method == "tmdb_crew": movie_ids, show_ids = self.get_credits(tmdb_id, crew=True)
else: raise Failed(f"TMDb Error: Method {method} not supported")
if status_message and len(movie_ids) > 0:
logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({len(movie_ids)} Movie{'' if len(movie_ids) == 1 else 's'})")
if status_message and len(show_ids) > 0:
if status_message and not is_movie and len(show_ids) > 0:
logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({len(show_ids)} Show{'' if len(show_ids) == 1 else 's'})")
if status_message:
logger.debug(f"TMDb IDs Found: {movie_ids}")

@ -114,9 +114,12 @@ pretty_names = {
"plex_search": "Plex Search",
"tautulli_popular": "Tautulli Popular",
"tautulli_watched": "Tautulli Watched",
"tmdb_actor": "TMDb Actor",
"tmdb_collection": "TMDb Collection",
"tmdb_collection_details": "TMDb Collection",
"tmdb_company": "TMDb Company",
"tmdb_crew": "TMDb Crew",
"tmdb_director": "TMDb Director",
"tmdb_discover": "TMDb Discover",
"tmdb_keyword": "TMDb Keyword",
"tmdb_list": "TMDb List",
@ -127,11 +130,13 @@ pretty_names = {
"tmdb_now_playing": "TMDb Now Playing",
"tmdb_person": "TMDb Person",
"tmdb_popular": "TMDb Popular",
"tmdb_producer": "TMDb Producer",
"tmdb_show": "TMDb Show",
"tmdb_show_details": "TMDb Show",
"tmdb_top_rated": "TMDb Top Rated",
"tmdb_trending_daily": "TMDb Trending Daily",
"tmdb_trending_weekly": "TMDb Trending Weekly",
"tmdb_writer": "TMDb Writer",
"trakt_list": "Trakt List",
"trakt_trending": "Trakt Trending",
"trakt_watchlist": "Trakt Watchlist",
@ -220,9 +225,12 @@ all_lists = [
"plex_search",
"tautulli_popular",
"tautulli_watched",
"tmdb_actor",
"tmdb_collection",
"tmdb_collection_details",
"tmdb_company",
"tmdb_crew",
"tmdb_director",
"tmdb_discover",
"tmdb_keyword",
"tmdb_list",
@ -232,11 +240,13 @@ all_lists = [
"tmdb_network",
"tmdb_now_playing",
"tmdb_popular",
"tmdb_producer",
"tmdb_show",
"tmdb_show_details",
"tmdb_top_rated",
"tmdb_trending_daily",
"tmdb_trending_weekly",
"tmdb_writer",
"trakt_list",
"trakt_trending",
"trakt_watchlist",
@ -328,9 +338,12 @@ count_lists = [
"trakt_trending"
]
tmdb_lists = [
"tmdb_actor",
"tmdb_collection",
"tmdb_collection_details",
"tmdb_company",
"tmdb_crew",
"tmdb_director",
"tmdb_discover",
"tmdb_keyword",
"tmdb_list",
@ -340,16 +353,21 @@ tmdb_lists = [
"tmdb_network",
"tmdb_now_playing",
"tmdb_popular",
"tmdb_producer",
"tmdb_show",
"tmdb_show_details",
"tmdb_top_rated",
"tmdb_trending_daily",
"tmdb_trending_weekly"
"tmdb_trending_weekly",
"tmdb_writer"
]
tmdb_type = {
"tmdb_actor": "Person",
"tmdb_collection": "Collection",
"tmdb_collection_details": "Collection",
"tmdb_company": "Company",
"tmdb_crew": "Person",
"tmdb_director": "Person",
"tmdb_keyword": "Keyword",
"tmdb_list": "List",
"tmdb_list_details": "List",
@ -357,8 +375,10 @@ tmdb_type = {
"tmdb_movie_details": "Movie",
"tmdb_network": "Network",
"tmdb_person": "Person",
"tmdb_producer": "Person",
"tmdb_show": "Show",
"tmdb_show_details": "Show"
"tmdb_show_details": "Show",
"tmdb_writer": "Person"
}
all_filters = [
"actor", "actor.not",

@ -1,7 +1,7 @@
# Remove
# Less common, pinned
tmdbv3api==1.7.3
PlexAPI==4.4.0
tmdbv3api==1.7.5
trakt.py==4.2.0
# More common, flexible
lxml

Loading…
Cancel
Save