removed status_message

pull/240/head
meisnate12 4 years ago
parent adcf83b980
commit 3f992d0f5c

@ -47,23 +47,20 @@ class AniDBAPI:
return anidb_values return anidb_values
raise Failed(f"AniDB Error: No valid AniDB IDs in {anidb_list}") raise Failed(f"AniDB Error: No valid AniDB IDs in {anidb_list}")
def get_items(self, method, data, language, status_message=True): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
anidb_ids = [] anidb_ids = []
if method == "anidb_popular": if method == "anidb_popular":
if status_message: logger.info(f"Processing {pretty}: {data} Anime")
logger.info(f"Processing {pretty}: {data} Anime")
anidb_ids.extend(self._popular(language)[:data]) anidb_ids.extend(self._popular(language)[:data])
else: else:
if status_message: logger.info(f"Processing {pretty}: {data}") logger.info(f"Processing {pretty}: {data}")
if method == "anidb_id": anidb_ids.append(data) if method == "anidb_id": anidb_ids.append(data)
elif method == "anidb_relation": anidb_ids.extend(self._relations(data, language)) elif method == "anidb_relation": anidb_ids.extend(self._relations(data, language))
else: raise Failed(f"AniDB Error: Method {method} not supported") else: raise Failed(f"AniDB Error: Method {method} not supported")
movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids) movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids)
if status_message: logger.debug(f"AniDB IDs Found: {anidb_ids}")
logger.debug(f"AniDB IDs Found: {anidb_ids}") logger.debug(f"TMDb IDs Found: {movie_ids}")
logger.debug(f"TMDb IDs Found: {movie_ids}") logger.debug(f"TVDb IDs Found: {show_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -217,41 +217,33 @@ class AniListAPI:
return anilist_values return anilist_values
raise Failed(f"AniList Error: No valid AniList IDs in {anilist_ids}") raise Failed(f"AniList Error: No valid AniList IDs in {anilist_ids}")
def get_items(self, method, data, language, status_message=True): def get_items(self, method, data):
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
if method == "anilist_id": if method == "anilist_id":
anilist_id, name = self._validate(data) anilist_id, name = self._validate(data)
anilist_ids = [anilist_id] anilist_ids = [anilist_id]
if status_message: logger.info(f"Processing {pretty}: ({data}) {name}")
logger.info(f"Processing {pretty}: ({data}) {name}")
elif method in ["anilist_popular", "anilist_top_rated"]: elif method in ["anilist_popular", "anilist_top_rated"]:
anilist_ids = self._popular(data) if method == "anilist_popular" else self._top_rated(data) anilist_ids = self._popular(data) if method == "anilist_popular" else self._top_rated(data)
if status_message: logger.info(f"Processing {pretty}: {data} Anime")
logger.info(f"Processing {pretty}: {data} Anime")
elif method == "anilist_season": elif method == "anilist_season":
anilist_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"]) anilist_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"])
if status_message: logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}")
logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}")
elif method == "anilist_genre": elif method == "anilist_genre":
anilist_ids = self._genre(data["genre"], data["sort_by"], data["limit"]) anilist_ids = self._genre(data["genre"], data["sort_by"], data["limit"])
if status_message: logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Genre: {data['genre']} sorted by {pretty_names[data['sort_by']]}")
logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Genre: {data['genre']} sorted by {pretty_names[data['sort_by']]}")
elif method == "anilist_tag": elif method == "anilist_tag":
anilist_ids = self._tag(data["tag"], data["sort_by"], data["limit"]) anilist_ids = self._tag(data["tag"], data["sort_by"], data["limit"])
if status_message: logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Tag: {data['tag']} sorted by {pretty_names[data['sort_by']]}")
logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Tag: {data['tag']} sorted by {pretty_names[data['sort_by']]}")
elif method in ["anilist_studio", "anilist_relations"]: elif method in ["anilist_studio", "anilist_relations"]:
if method == "anilist_studio": anilist_ids, name = self._studio(data) if method == "anilist_studio": anilist_ids, name = self._studio(data)
else: anilist_ids, _, name = self._relations(data) else: anilist_ids, _, name = self._relations(data)
if status_message: logger.info(f"Processing {pretty}: ({data}) {name} ({len(anilist_ids)} Anime)")
logger.info(f"Processing {pretty}: ({data}) {name} ({len(anilist_ids)} Anime)")
else: else:
raise Failed(f"AniList Error: Method {method} not supported") raise Failed(f"AniList Error: Method {method} not supported")
movie_ids, show_ids = self.config.Convert.anilist_to_ids(anilist_ids) movie_ids, show_ids = self.config.Convert.anilist_to_ids(anilist_ids)
if status_message: logger.debug(f"AniList IDs Found: {anilist_ids}")
logger.debug(f"AniList IDs Found: {anilist_ids}") logger.debug(f"Shows Found: {show_ids}")
logger.debug(f"Shows Found: {show_ids}") logger.debug(f"Movies Found: {movie_ids}")
logger.debug(f"Movies Found: {movie_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -1243,8 +1243,8 @@ class CollectionBuilder:
items = self.library.Tautulli.get_items(self.library, time_range=value["list_days"], stats_count=value["list_size"], list_type=value["list_type"], stats_count_buffer=value["list_buffer"]) items = self.library.Tautulli.get_items(self.library, time_range=value["list_days"], stats_count=value["list_size"], list_type=value["list_type"], stats_count_buffer=value["list_buffer"])
items_found += len(items) items_found += len(items)
elif "anidb" in method: items_found += check_map(self.config.AniDB.get_items(method, value, self.library.Plex.language)) elif "anidb" in method: items_found += check_map(self.config.AniDB.get_items(method, value, self.library.Plex.language))
elif "anilist" in method: items_found += check_map(self.config.AniList.get_items(method, value, self.library.Plex.language)) elif "anilist" in method: items_found += check_map(self.config.AniList.get_items(method, value))
elif "mal" in method: items_found += check_map(self.config.MyAnimeList.get_items(method, value, self.library.Plex.language)) elif "mal" in method: items_found += check_map(self.config.MyAnimeList.get_items(method, value))
elif "tvdb" in method: items_found += check_map(self.config.TVDb.get_items(method, value, self.library.Plex.language)) elif "tvdb" in method: items_found += check_map(self.config.TVDb.get_items(method, value, self.library.Plex.language))
elif "imdb" in method: items_found += check_map(self.config.IMDb.get_items(method, value, self.library.Plex.language)) elif "imdb" in method: items_found += check_map(self.config.IMDb.get_items(method, value, self.library.Plex.language))
elif "letterboxd" in method: items_found += check_map(self.config.Letterboxd.get_items(method, value, self.library.Plex.language)) elif "letterboxd" in method: items_found += check_map(self.config.Letterboxd.get_items(method, value, self.library.Plex.language))

@ -91,15 +91,13 @@ class IMDbAPI:
def _request(self, url, header): def _request(self, url, header):
return html.fromstring(requests.get(url, headers=header).content) return html.fromstring(requests.get(url, headers=header).content)
def get_items(self, method, data, language, status_message=True): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
show_ids = [] show_ids = []
movie_ids = [] movie_ids = []
if method == "imdb_id": if method == "imdb_id":
if status_message: logger.info(f"Processing {pretty}: {data}")
logger.info(f"Processing {pretty}: {data}")
tmdb_id = self.config.Convert.imdb_to_tmdb(data) tmdb_id = self.config.Convert.imdb_to_tmdb(data)
tvdb_id = self.config.Convert.imdb_to_tvdb(data) tvdb_id = self.config.Convert.imdb_to_tvdb(data)
if not tmdb_id and not tvdb_id: if not tmdb_id and not tvdb_id:
@ -107,9 +105,8 @@ class IMDbAPI:
if tmdb_id: movie_ids.append(tmdb_id) if tmdb_id: movie_ids.append(tmdb_id)
if tvdb_id: show_ids.append(tvdb_id) if tvdb_id: show_ids.append(tvdb_id)
elif method == "imdb_list": elif method == "imdb_list":
if status_message: status = f"{data['limit']} Items at " if data['limit'] > 0 else ''
status = f"{data['limit']} Items at " if data['limit'] > 0 else '' logger.info(f"Processing {pretty}: {status}{data['url']}")
logger.info(f"Processing {pretty}: {status}{data['url']}")
imdb_ids = self._ids_from_url(data["url"], language, data["limit"]) imdb_ids = self._ids_from_url(data["url"], language, data["limit"])
total_ids = len(imdb_ids) total_ids = len(imdb_ids)
length = 0 length = 0
@ -124,7 +121,6 @@ class IMDbAPI:
util.print_end(length, f"Processed {total_ids} IMDb IDs") util.print_end(length, f"Processed {total_ids} IMDb IDs")
else: else:
raise Failed(f"IMDb Error: Method {method} not supported") raise Failed(f"IMDb Error: Method {method} not supported")
if status_message: logger.debug(f"TMDb IDs Found: {movie_ids}")
logger.debug(f"TMDb IDs Found: {movie_ids}") logger.debug(f"TVDb IDs Found: {show_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -193,35 +193,28 @@ class MyAnimeListAPI:
url = f"{self.urls['user']}/{username}/animelist?{final_status}sort={sort_by}&limit={limit}" url = f"{self.urls['user']}/{username}/animelist?{final_status}sort={sort_by}&limit={limit}"
return self._parse_request(url) return self._parse_request(url)
def get_items(self, method, data, language, status_message=True): def get_items(self, method, data):
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
if method == "mal_id": if method == "mal_id":
mal_ids = [data] mal_ids = [data]
if status_message: logger.info(f"Processing {pretty}: {data}")
logger.info(f"Processing {pretty}: {data}")
elif method in mal_ranked_name: elif method in mal_ranked_name:
mal_ids = self._ranked(mal_ranked_name[method], data) mal_ids = self._ranked(mal_ranked_name[method], data)
if status_message: logger.info(f"Processing {pretty}: {data} Anime")
logger.info(f"Processing {pretty}: {data} Anime")
elif method == "mal_season": elif method == "mal_season":
mal_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"]) mal_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"])
if status_message: logger.info(f"Processing {pretty}: {data['limit']} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}")
logger.info(f"Processing {pretty}: {data['limit']} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}")
elif method == "mal_suggested": elif method == "mal_suggested":
mal_ids = self._suggestions(data) mal_ids = self._suggestions(data)
if status_message: logger.info(f"Processing {pretty}: {data} Anime")
logger.info(f"Processing {pretty}: {data} Anime")
elif method == "mal_userlist": elif method == "mal_userlist":
mal_ids = self._userlist(data["username"], data["status"], data["sort_by"], data["limit"]) mal_ids = self._userlist(data["username"], data["status"], data["sort_by"], data["limit"])
if status_message: logger.info(f"Processing {pretty}: {data['limit']} Anime from {self._username() if data['username'] == '@me' else data['username']}'s {pretty_names[data['status']]} list sorted by {pretty_names[data['sort_by']]}")
logger.info(f"Processing {pretty}: {data['limit']} Anime from {self._username() if data['username'] == '@me' else data['username']}'s {pretty_names[data['status']]} list sorted by {pretty_names[data['sort_by']]}")
else: else:
raise Failed(f"MyAnimeList Error: Method {method} not supported") raise Failed(f"MyAnimeList Error: Method {method} not supported")
movie_ids, show_ids = self.config.Convert.myanimelist_to_ids(mal_ids) movie_ids, show_ids = self.config.Convert.myanimelist_to_ids(mal_ids)
if status_message: logger.debug(f"MyAnimeList IDs Found: {mal_ids}")
logger.debug(f"MyAnimeList IDs Found: {mal_ids}") logger.debug(f"Shows Found: {show_ids}")
logger.debug(f"Shows Found: {show_ids}") logger.debug(f"Movies Found: {movie_ids}")
logger.debug(f"Movies Found: {movie_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -515,19 +515,16 @@ class PlexAPI:
raise Failed(f"Collection Error: No valid Plex Collections in {collections}") raise Failed(f"Collection Error: No valid Plex Collections in {collections}")
return valid_collections return valid_collections
def get_items(self, method, data, status_message=True): def get_items(self, method, data):
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
media_type = "Movie" if self.is_movie else "Show" media_type = "Movie" if self.is_movie else "Show"
items = [] items = []
if method == "plex_all": if method == "plex_all":
if status_message: logger.info(f"Processing {pretty} {media_type}s")
logger.info(f"Processing {pretty} {media_type}s")
items = self.get_all() items = self.get_all()
elif method == "plex_collection": elif method == "plex_collection":
if status_message: logger.info(f"Processing {pretty} {data}")
logger.info(f"Processing {pretty} {data}")
items = data.items() items = data.items()
elif method == "plex_search": elif method == "plex_search":
search_terms = {} search_terms = {}
@ -561,54 +558,48 @@ class PlexAPI:
else: else:
search_terms[final_method] = search_data search_terms[final_method] = search_data
if status_message: if search in ["added", "originally_available"] or modifier in [".gt", ".gte", ".lt", ".lte", ".before", ".after"]:
if search in ["added", "originally_available"] or modifier in [".gt", ".gte", ".lt", ".lte", ".before", ".after"]: ors = f"{search_method}({search_data}"
ors = f"{search_method}({search_data}" else:
else: ors = ""
ors = "" conjunction = " AND " if final_mod == "&" else " OR "
conjunction = " AND " if final_mod == "&" else " OR " for o, param in enumerate(search_data):
for o, param in enumerate(search_data): or_des = conjunction if o > 0 else f"{search_method}("
or_des = conjunction if o > 0 else f"{search_method}(" ors += f"{or_des}{param}"
ors += f"{or_des}{param}" if has_processed:
if has_processed: logger.info(f"\t\t AND {ors})")
logger.info(f"\t\t AND {ors})") else:
else: logger.info(f"Processing {pretty}: {ors})")
logger.info(f"Processing {pretty}: {ors})") has_processed = True
has_processed = True if search_sort:
if status_message: logger.info(f"\t\t SORT BY {search_sort})")
if search_sort: if search_limit:
logger.info(f"\t\t SORT BY {search_sort})") logger.info(f"\t\t LIMIT {search_limit})")
if search_limit: logger.debug(f"Search: {search_terms}")
logger.info(f"\t\t LIMIT {search_limit})")
logger.debug(f"Search: {search_terms}")
return self.search(sort=sorts[search_sort], maxresults=search_limit, **search_terms) return self.search(sort=sorts[search_sort], maxresults=search_limit, **search_terms)
elif method == "plex_collectionless": elif method == "plex_collectionless":
good_collections = [] good_collections = []
if status_message: logger.info("Collections Excluded")
logger.info("Collections Excluded")
for col in self.get_all_collections(): for col in self.get_all_collections():
keep_collection = True keep_collection = True
for pre in data["exclude_prefix"]: for pre in data["exclude_prefix"]:
if col.title.startswith(pre) or (col.titleSort and col.titleSort.startswith(pre)): if col.title.startswith(pre) or (col.titleSort and col.titleSort.startswith(pre)):
keep_collection = False keep_collection = False
if status_message: logger.info(f"{col.title} excluded by prefix match {pre}")
logger.info(f"{col.title} excluded by prefix match {pre}")
break break
if keep_collection: if keep_collection:
for ext in data["exclude"]: for ext in data["exclude"]:
if col.title == ext or (col.titleSort and col.titleSort == ext): if col.title == ext or (col.titleSort and col.titleSort == ext):
keep_collection = False keep_collection = False
if status_message: logger.info(f"{col.title} excluded by exact match")
logger.info(f"{col.title} excluded by exact match")
break break
if keep_collection: if keep_collection:
logger.info(f"Collection Passed: {col.title}") logger.info(f"Collection Passed: {col.title}")
good_collections.append(col) good_collections.append(col)
if status_message: logger.info("")
logger.info("") logger.info("Collections Not Excluded (Items in these collections are not added to Collectionless)")
logger.info("Collections Not Excluded (Items in these collections are not added to Collectionless)") for col in good_collections:
for col in good_collections: logger.info(col.title)
logger.info(col.title)
collection_indexes = [c.index for c in good_collections] collection_indexes = [c.index for c in good_collections]
all_items = self.get_all() all_items = self.get_all()
length = 0 length = 0

@ -19,9 +19,8 @@ class TautulliAPI:
self.url = params["url"] self.url = params["url"]
self.apikey = params["apikey"] self.apikey = params["apikey"]
def get_items(self, library, time_range=30, stats_count=20, list_type="popular", stats_count_buffer=20, status_message=True): def get_items(self, library, time_range=30, stats_count=20, list_type="popular", stats_count_buffer=20):
if status_message: logger.info(f"Processing Tautulli Most {'Popular' if list_type == 'popular' else 'Watched'}: {stats_count} {'Movies' if library.is_movie else 'Shows'}")
logger.info(f"Processing Tautulli Most {'Popular' if list_type == 'popular' else 'Watched'}: {stats_count} {'Movies' if library.is_movie else 'Shows'}")
response = self._request(f"{self.url}/api/v2?apikey={self.apikey}&cmd=get_home_stats&time_range={time_range}&stats_count={int(stats_count) + int(stats_count_buffer)}") response = self._request(f"{self.url}/api/v2?apikey={self.apikey}&cmd=get_home_stats&time_range={time_range}&stats_count={int(stats_count) + int(stats_count_buffer)}")
stat_id = f"{'popular' if list_type == 'popular' else 'top'}_{'movies' if library.is_movie else 'tv'}" stat_id = f"{'popular' if list_type == 'popular' else 'top'}_{'movies' if library.is_movie else 'tv'}"

@ -290,9 +290,8 @@ class TMDbAPI:
elif tmdb_type == "List": self.get_list(tmdb_id) elif tmdb_type == "List": self.get_list(tmdb_id)
return tmdb_id return tmdb_id
def get_items(self, method, data, is_movie, status_message=True): def get_items(self, method, data, is_movie):
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
media_type = "Movie" if is_movie else "Show" media_type = "Movie" if is_movie else "Show"
movie_ids = [] movie_ids = []
@ -318,18 +317,16 @@ class TMDbAPI:
limit = int(attrs.pop("limit")) limit = int(attrs.pop("limit"))
if is_movie: movie_ids, amount = self._discover(attrs, limit, is_movie) if is_movie: movie_ids, amount = self._discover(attrs, limit, is_movie)
else: show_ids, amount = self._discover(attrs, limit, is_movie) else: show_ids, amount = self._discover(attrs, limit, is_movie)
if status_message: if method in ["tmdb_company", "tmdb_network", "tmdb_keyword"]:
if method in ["tmdb_company", "tmdb_network", "tmdb_keyword"]: logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({amount} {media_type}{'' if amount == 1 else 's'})")
logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({amount} {media_type}{'' if amount == 1 else 's'})") elif method == "tmdb_discover":
elif method == "tmdb_discover": logger.info(f"Processing {pretty}: {amount} {media_type}{'' if amount == 1 else 's'}")
logger.info(f"Processing {pretty}: {amount} {media_type}{'' if amount == 1 else 's'}") for attr, value in attrs.items():
for attr, value in attrs.items(): logger.info(f" {attr}: {value}")
logger.info(f" {attr}: {value}")
elif method in ["tmdb_popular", "tmdb_top_rated", "tmdb_now_playing", "tmdb_trending_daily", "tmdb_trending_weekly"]: elif method in ["tmdb_popular", "tmdb_top_rated", "tmdb_now_playing", "tmdb_trending_daily", "tmdb_trending_weekly"]:
if is_movie: movie_ids = self._pagenation(method, data, is_movie) if is_movie: movie_ids = self._pagenation(method, data, is_movie)
else: show_ids = self._pagenation(method, data, is_movie) else: show_ids = self._pagenation(method, data, is_movie)
if status_message: logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}")
logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}")
else: else:
tmdb_id = int(data) tmdb_id = int(data)
if method == "tmdb_list": if method == "tmdb_list":
@ -360,11 +357,10 @@ class TMDbAPI:
elif method == "tmdb_writer": movie_ids, show_ids = self._credits(tmdb_id, writer=True) elif method == "tmdb_writer": movie_ids, show_ids = self._credits(tmdb_id, writer=True)
elif method == "tmdb_crew": movie_ids, show_ids = self._credits(tmdb_id, crew=True) elif method == "tmdb_crew": movie_ids, show_ids = self._credits(tmdb_id, crew=True)
else: raise Failed(f"TMDb Error: Method {method} not supported") else: raise Failed(f"TMDb Error: Method {method} not supported")
if status_message and len(movie_ids) > 0: if len(movie_ids) > 0:
logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({len(movie_ids)} Movie{'' if len(movie_ids) == 1 else 's'})") logger.info(f"Processing {pretty}: ({tmdb_id}) {tmdb_name} ({len(movie_ids)} Movie{'' if len(movie_ids) == 1 else 's'})")
if status_message and not is_movie and len(show_ids) > 0: if 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'})") 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}")
logger.debug(f"TMDb IDs Found: {movie_ids}") logger.debug(f"TVDb IDs Found: {show_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -156,26 +156,23 @@ class TraktAPI:
raise Failed(f"Trakt Error: No valid Trakt Lists in {values}") raise Failed(f"Trakt Error: No valid Trakt Lists in {values}")
return trakt_values return trakt_values
def get_items(self, method, data, is_movie, status_message=True): def get_items(self, method, data, is_movie):
if status_message: logger.debug(f"Data: {data}")
logger.debug(f"Data: {data}")
pretty = self.aliases[method] if method in self.aliases else method pretty = self.aliases[method] if method in self.aliases else method
media_type = "Movie" if is_movie else "Show" media_type = "Movie" if is_movie else "Show"
if method in ["trakt_trending", "trakt_popular", "trakt_recommended", "trakt_watched", "trakt_collected"]: if method in ["trakt_trending", "trakt_popular", "trakt_recommended", "trakt_watched", "trakt_collected"]:
movie_ids, show_ids = self._pagenation(method[6:], data, is_movie) movie_ids, show_ids = self._pagenation(method[6:], data, is_movie)
if status_message: logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}")
logger.info(f"Processing {pretty}: {data} {media_type}{'' if data == 1 else 's'}")
elif method == "trakt_collection": elif method == "trakt_collection":
movie_ids, show_ids = self._collection(data, is_movie) movie_ids, show_ids = self._collection(data, is_movie)
if status_message: logger.info(f"Processing {pretty} {media_type}s for {data}")
logger.info(f"Processing {pretty} {media_type}s for {data}")
else: else:
show_ids = [] show_ids = []
movie_ids = [] movie_ids = []
if method == "trakt_watchlist": trakt_items = self._watchlist(data, is_movie) if method == "trakt_watchlist": trakt_items = self._watchlist(data, is_movie)
elif method == "trakt_list": trakt_items = self.standard_list(data).items() elif method == "trakt_list": trakt_items = self.standard_list(data).items()
else: raise Failed(f"Trakt Error: Method {method} not supported") else: raise Failed(f"Trakt Error: Method {method} not supported")
if status_message: logger.info(f"Processing {pretty}: {data}") logger.info(f"Processing {pretty}: {data}")
for trakt_item in trakt_items: for trakt_item in trakt_items:
if isinstance(trakt_item, Movie): if isinstance(trakt_item, Movie):
movie_ids.append(int(trakt_item.get_key("tmdb"))) movie_ids.append(int(trakt_item.get_key("tmdb")))
@ -183,9 +180,7 @@ class TraktAPI:
show_ids.append(int(trakt_item.pk[1])) show_ids.append(int(trakt_item.pk[1]))
elif (isinstance(trakt_item, (Season, Episode))) and trakt_item.show.pk[1] not in show_ids: elif (isinstance(trakt_item, (Season, Episode))) and trakt_item.show.pk[1] not in show_ids:
show_ids.append(int(trakt_item.show.pk[1])) show_ids.append(int(trakt_item.show.pk[1]))
if status_message: logger.debug(f"Trakt {media_type} Found: {trakt_items}")
logger.debug(f"Trakt {media_type} Found: {trakt_items}") logger.debug(f"TMDb IDs Found: {movie_ids}")
if status_message: logger.debug(f"TVDb IDs Found: {show_ids}")
logger.debug(f"TMDb IDs Found: {movie_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids return movie_ids, show_ids

@ -57,15 +57,17 @@ class TVDbObj:
if len(results) > 0: if len(results) > 0:
try: try:
tmdb_id = util.regex_first_int(results[0], "TMDb ID") tmdb_id = util.regex_first_int(results[0], "TMDb ID")
except Failed as e: except Failed:
logger.error(e) pass
if not tmdb_id: if tmdb_id is None:
results = response.xpath("//*[text()='IMDB']/@href") results = response.xpath("//*[text()='IMDB']/@href")
if len(results) > 0: if len(results) > 0:
try: try:
tmdb_id = TVDb.config.Convert.imdb_to_tmdb(util.get_id_from_imdb_url(results[0]), fail=True) tmdb_id = TVDb.config.Convert.imdb_to_tmdb(util.get_id_from_imdb_url(results[0]), fail=True)
except Failed as e: except Failed:
logger.error(e) pass
if tmdb_id is None:
raise Failed(f"TVDB Error: No TMDb ID found for {self.title}")
self.tmdb_id = tmdb_id self.tmdb_id = tmdb_id
self.tvdb_url = tvdb_url self.tvdb_url = tvdb_url
self.language = language self.language = language
@ -146,23 +148,21 @@ class TVDbAPI:
def _request(self, url, language): def _request(self, url, language):
return html.fromstring(requests.get(url, headers={"Accept-Language": language}).content) return html.fromstring(requests.get(url, headers={"Accept-Language": language}).content)
def get_items(self, method, data, language, status_message=True): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method pretty = util.pretty_names[method] if method in util.pretty_names else method
show_ids = [] show_ids = []
movie_ids = [] movie_ids = []
if status_message: logger.info(f"Processing {pretty}: {data}")
logger.info(f"Processing {pretty}: {data}")
if method == "tvdb_show": if method == "tvdb_show":
show_ids.append(self.get_series(language, data).id) show_ids.append(self.get_series(language, data).id)
elif method == "tvdb_movie": elif method == "tvdb_movie":
movie_ids.append(self.get_movie(language, data).id) movie_ids.append(self.get_movie(language, data).tmdb_id)
elif method == "tvdb_list": elif method == "tvdb_list":
tmdb_ids, tvdb_ids = self._ids_from_url(data, language) tmdb_ids, tvdb_ids = self._ids_from_url(data, language)
movie_ids.extend(tmdb_ids) movie_ids.extend(tmdb_ids)
show_ids.extend(tvdb_ids) show_ids.extend(tvdb_ids)
else: else:
raise Failed(f"TVDb Error: Method {method} not supported") raise Failed(f"TVDb Error: Method {method} not supported")
if status_message: logger.debug(f"TMDb IDs Found: {movie_ids}")
logger.debug(f"TMDb IDs Found: {movie_ids}") logger.debug(f"TVDb IDs Found: {show_ids}")
logger.debug(f"TVDb IDs Found: {show_ids}")
return movie_ids, show_ids return movie_ids, show_ids

Loading…
Cancel
Save