diff --git a/modules/anidb.py b/modules/anidb.py index 6dbcc212..82ee48cb 100644 --- a/modules/anidb.py +++ b/modules/anidb.py @@ -74,19 +74,21 @@ class AniDB: return anidb_ids[:limit] def get_items(self, method, data, language): - pretty = util.pretty_names[method] if method in util.pretty_names else method anidb_ids = [] if method == "anidb_popular": - logger.info(f"Processing {pretty}: {data} Anime") + logger.info(f"Processing AniDB Popular: {data} Anime") anidb_ids.extend(self._popular(language)[:data]) elif method == "anidb_tag": + logger.info(f"Processing AniDB Tag: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Tag ID: {data['tag']}") anidb_ids = self._tag(data["tag"], data["limit"], language) - logger.info(f"Processing {pretty}: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Tag ID: {data['tag']}") + elif method == "anidb_id": + logger.info(f"Processing AniDB ID: {data}") + anidb_ids.append(data) + elif method == "anidb_relation": + logger.info(f"Processing AniDB Relation: {data}") + anidb_ids.extend(self._relations(data, language)) else: - logger.info(f"Processing {pretty}: {data}") - if method == "anidb_id": anidb_ids.append(data) - elif method == "anidb_relation": anidb_ids.extend(self._relations(data, language)) - else: raise Failed(f"AniDB Error: Method {method} not supported") + raise Failed(f"AniDB Error: Method {method} not supported") movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids) logger.debug("") logger.debug(f"{len(anidb_ids)} AniDB IDs Found: {anidb_ids}") diff --git a/modules/anilist.py b/modules/anilist.py index ae0b4fa2..d1bc31c9 100644 --- a/modules/anilist.py +++ b/modules/anilist.py @@ -210,27 +210,31 @@ class AniList: raise Failed(f"AniList Error: No valid AniList IDs in {anilist_ids}") def get_items(self, method, data): - pretty = util.pretty_names[method] if method in util.pretty_names else method if method == "anilist_id": + logger.info(f"Processing AniList ID: {data}") anilist_id, name = self._validate(data) anilist_ids = [anilist_id] - logger.info(f"Processing {pretty}: ({data}) {name}") - elif method in ["anilist_popular", "anilist_top_rated"]: - anilist_ids = self._popular(data) if method == "anilist_popular" else self._top_rated(data) - logger.info(f"Processing {pretty}: {data} Anime") + elif method == "anilist_popular": + logger.info(f"Processing AniList Popular: {data} Anime") + anilist_ids = self._popular(data) + elif method == "anilist_top_rated": + logger.info(f"Processing AniList Top Rated: {data} Anime") + anilist_ids = self._top_rated(data) elif method == "anilist_season": + logger.info(f"Processing AniList Season: {data['limit'] if data['limit'] > 0 else 'All'} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}") anilist_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"]) - 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": + logger.info(f"Processing AniList Genre: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Genre: {data['genre']} sorted by {pretty_names[data['sort_by']]}") anilist_ids = self._genre(data["genre"], data["sort_by"], data["limit"]) - 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": + logger.info(f"Processing AniList Tag: {data['limit'] if data['limit'] > 0 else 'All'} Anime from the Tag: {data['tag']} sorted by {pretty_names[data['sort_by']]}") anilist_ids = self._tag(data["tag"], data["sort_by"], data["limit"]) - 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"]: - if method == "anilist_studio": anilist_ids, name = self._studio(data) - else: anilist_ids, _, name = self._relations(data) - logger.info(f"Processing {pretty}: ({data}) {name} ({len(anilist_ids)} Anime)") + elif method == "anilist_studio": + anilist_ids, name = self._studio(data) + logger.info(f"Processing AniList Studio: ({data}) {name} ({len(anilist_ids)} Anime)") + elif method == "anilist_relations": + anilist_ids, _, name = self._relations(data) + logger.info(f"Processing AniList Relations: ({data}) {name} ({len(anilist_ids)} Anime)") else: raise Failed(f"AniList Error: Method {method} not supported") movie_ids, show_ids = self.config.Convert.anilist_to_ids(anilist_ids) diff --git a/modules/icheckmovies.py b/modules/icheckmovies.py index 816fcc43..3d183021 100644 --- a/modules/icheckmovies.py +++ b/modules/icheckmovies.py @@ -35,10 +35,9 @@ class ICheckMovies: return valid_lists def get_items(self, method, data, language): - pretty = util.pretty_names[method] if method in util.pretty_names else method movie_ids = [] if method == "icheckmovies_list": - logger.info(f"Processing {pretty}: {data}") + logger.info(f"Processing ICheckMovies List: {data}") imdb_ids = self._parse_list(data, language) total_ids = len(imdb_ids) for i, imdb_id in enumerate(imdb_ids, 1): diff --git a/modules/imdb.py b/modules/imdb.py index 803e6bd5..11205d65 100644 --- a/modules/imdb.py +++ b/modules/imdb.py @@ -96,7 +96,6 @@ class IMDb: raise ValueError(f"IMDb Error: No IMDb IDs Found at {imdb_url}") def get_items(self, method, data, language, is_movie): - pretty = util.pretty_names[method] if method in util.pretty_names else method show_ids = [] movie_ids = [] fail_ids = [] @@ -110,11 +109,11 @@ class IMDb: fail_ids.append(imdb_id) if method == "imdb_id": - logger.info(f"Processing {pretty}: {data}") + logger.info(f"Processing IMDb ID: {data}") run_convert(data) elif method == "imdb_list": status = f"{data['limit']} Items at " if data['limit'] > 0 else '' - logger.info(f"Processing {pretty}: {status}{data['url']}") + logger.info(f"Processing IMDb List: {status}{data['url']}") imdb_ids = self._ids_from_url(data["url"], language, data["limit"]) total_ids = len(imdb_ids) for i, imdb in enumerate(imdb_ids, 1): diff --git a/modules/letterboxd.py b/modules/letterboxd.py index d936546f..0e9f33e7 100644 --- a/modules/letterboxd.py +++ b/modules/letterboxd.py @@ -51,31 +51,33 @@ class Letterboxd: return valid_lists def get_items(self, method, data, language): - pretty = util.pretty_names[method] if method in util.pretty_names else method movie_ids = [] - logger.info(f"Processing {pretty}: {data}") - items = self._parse_list(data, language) - total_items = len(items) - if total_items > 0: - for i, item in enumerate(items, 1): - letterboxd_id, slug = item - util.print_return(f"Finding TMDb ID {i}/{total_items}") - tmdb_id = None - expired = None - if self.config.Cache: - tmdb_id, expired = self.config.Cache.query_letterboxd_map(letterboxd_id) - if not tmdb_id or expired is not False: - try: - tmdb_id = self._tmdb(f"{base_url}{slug}", language) - except Failed as e: - logger.error(e) - continue + if method == "letterboxd_list": + logger.info(f"Processing Letterboxd List: {data}") + items = self._parse_list(data, language) + total_items = len(items) + if total_items > 0: + for i, item in enumerate(items, 1): + letterboxd_id, slug = item + util.print_return(f"Finding TMDb ID {i}/{total_items}") + tmdb_id = None + expired = None if self.config.Cache: - self.config.Cache.update_letterboxd_map(expired, letterboxd_id, tmdb_id) - movie_ids.append(tmdb_id) - logger.info(util.adjust_space(f"Processed {total_items} TMDb IDs")) + tmdb_id, expired = self.config.Cache.query_letterboxd_map(letterboxd_id) + if not tmdb_id or expired is not False: + try: + tmdb_id = self._tmdb(f"{base_url}{slug}", language) + except Failed as e: + logger.error(e) + continue + if self.config.Cache: + self.config.Cache.update_letterboxd_map(expired, letterboxd_id, tmdb_id) + movie_ids.append(tmdb_id) + logger.info(util.adjust_space(f"Processed {total_items} TMDb IDs")) + else: + logger.error(f"Letterboxd Error: No List Items found in {data}") else: - logger.error(f"Letterboxd Error: No List Items found in {data}") + raise Failed(f"Letterboxd Error: Method {method} not supported") logger.debug("") logger.debug(f"{len(movie_ids)} TMDb IDs Found: {movie_ids}") return movie_ids, [] diff --git a/modules/mal.py b/modules/mal.py index 6eecad33..e8ff7d0e 100644 --- a/modules/mal.py +++ b/modules/mal.py @@ -13,6 +13,12 @@ mal_ranked_name = { "mal_all": "all", "mal_airing": "airing", "mal_upcoming": "upcoming", "mal_tv": "tv", "mal_ova": "ova", "mal_movie": "movie", "mal_special": "special", "mal_popular": "bypopularity", "mal_favorite": "favorite" } +mal_ranked_pretty = { + "mal_all": "MyAnimeList All", "mal_airing": "MyAnimeList Airing", + "mal_upcoming": "MyAnimeList Upcoming", "mal_tv": "MyAnimeList TV", "mal_ova": "MyAnimeList OVA", + "mal_movie": "MyAnimeList Movie", "mal_special": "MyAnimeList Special", "mal_popular": "MyAnimeList Popular", + "mal_favorite": "MyAnimeList Favorite" +} season_sort_translation = {"score": "anime_score", "anime_score": "anime_score", "members": "anime_num_list_users", "anime_num_list_users": "anime_num_list_users"} season_sort_options = ["score", "members"] pretty_names = { @@ -150,22 +156,21 @@ class MyAnimeList: return self._parse_request(url) def get_items(self, method, data): - pretty = util.pretty_names[method] if method in util.pretty_names else method if method == "mal_id": + logger.info(f"Processing MyAnimeList ID: {data}") mal_ids = [data] - logger.info(f"Processing {pretty}: {data}") elif method in mal_ranked_name: + logger.info(f"Processing {mal_ranked_pretty[method]}: {data} Anime") mal_ids = self._ranked(mal_ranked_name[method], data) - logger.info(f"Processing {pretty}: {data} Anime") elif method == "mal_season": + logger.info(f"Processing MyAnimeList Season: {data['limit']} Anime from {util.pretty_seasons[data['season']]} {data['year']} sorted by {pretty_names[data['sort_by']]}") mal_ids = self._season(data["season"], data["year"], data["sort_by"], data["limit"]) - 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": + logger.info(f"Processing MyAnimeList Suggested: {data} Anime") mal_ids = self._suggestions(data) - logger.info(f"Processing {pretty}: {data} Anime") elif method == "mal_userlist": + logger.info(f"Processing MyAnimeList Userlist: {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']]}") mal_ids = self._userlist(data["username"], data["status"], data["sort_by"], data["limit"]) - 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: raise Failed(f"MyAnimeList Error: Method {method} not supported") movie_ids, show_ids = self.config.Convert.myanimelist_to_ids(mal_ids) diff --git a/modules/plex.py b/modules/plex.py index 952fffe4..8c019cd8 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -579,17 +579,17 @@ class Plex: return valid_collections def get_items(self, method, data): - pretty = util.pretty_names[method] if method in util.pretty_names else method media_type = "Movie" if self.is_movie else "Show" items = [] if method == "plex_all": - logger.info(f"Processing {pretty} {media_type}s") + logger.info(f"Processing Plex All {media_type}s") items = self.get_all() elif method == "plex_search": util.print_multiline(data[1], info=True) items = self.get_filter_items(data[2]) elif method == "plex_collectionless": good_collections = [] + logger.info(f"Processing Plex Collectionless") logger.info("Collections Excluded") for col in self.get_all_collections(): keep_collection = True diff --git a/modules/stevenlu.py b/modules/stevenlu.py index 85404b5f..7712dcce 100644 --- a/modules/stevenlu.py +++ b/modules/stevenlu.py @@ -1,5 +1,4 @@ import logging -from modules import util from modules.util import Failed logger = logging.getLogger("Plex Meta Manager") @@ -12,11 +11,10 @@ class StevenLu: self.config = config def get_items(self, method): - pretty = util.pretty_names[method] if method in util.pretty_names else method movie_ids = [] fail_ids = [] if method == "stevenlu_popular": - logger.info(f"Processing {pretty} Movies") + logger.info(f"Processing StevenLu Popular Movies") for i in self.config.get_json(base_url): tmdb_id = self.config.Convert.imdb_to_tmdb(i["imdb_id"]) if tmdb_id: diff --git a/modules/tmdb.py b/modules/tmdb.py index e2b82dd6..0e7c44a5 100644 --- a/modules/tmdb.py +++ b/modules/tmdb.py @@ -232,7 +232,7 @@ class TMDb: return tmdb_id def get_items(self, method, data, is_movie): - pretty = util.pretty_names[method] if method in util.pretty_names else method + pretty = method.replace("_", " ").title().replace("Tmdb", "TMDb") media_type = "Movie" if is_movie else "Show" movie_ids = [] show_ids = [] diff --git a/modules/trakt.py b/modules/trakt.py index d8caa89e..4cd5d121 100644 --- a/modules/trakt.py +++ b/modules/trakt.py @@ -162,7 +162,7 @@ class Trakt: return trakt_values def get_items(self, method, data, is_movie): - pretty = util.pretty_names[method] if method in util.pretty_names else method + pretty = method.replace("_", " ").title() media_type = "Movie" if is_movie else "Show" if method in ["trakt_trending", "trakt_popular", "trakt_recommended", "trakt_watched", "trakt_collected"]: movie_ids, show_ids = self._pagenation(method[6:], data, is_movie) diff --git a/modules/tvdb.py b/modules/tvdb.py index 3d6c2e32..7ee1a918 100644 --- a/modules/tvdb.py +++ b/modules/tvdb.py @@ -136,18 +136,17 @@ class TVDb: raise Failed(f"TVDb Error: {tvdb_url} must begin with {urls['list']}") def get_items(self, method, data, language): - pretty = util.pretty_names[method] if method in util.pretty_names else method show_ids = [] movie_ids = [] - logger.info(f"Processing {pretty}: {data}") if method == "tvdb_show": + logger.info(f"Processing TVDb Show: {data}") show_ids.append(self.get_series(language, data).id) elif method == "tvdb_movie": + logger.info(f"Processing TVDb Movie: {data}") movie_ids.append(self.get_movie(language, data).tmdb_id) elif method == "tvdb_list": - tmdb_ids, tvdb_ids = self._ids_from_url(data, language) - movie_ids.extend(tmdb_ids) - show_ids.extend(tvdb_ids) + logger.info(f"Processing TVDb List: {data}") + movie_ids, show_ids = self._ids_from_url(data, language) else: raise Failed(f"TVDb Error: Method {method} not supported") logger.debug("") diff --git a/modules/util.py b/modules/util.py index 19fd322b..8fab6fb3 100644 --- a/modules/util.py +++ b/modules/util.py @@ -53,40 +53,6 @@ pretty_months = { 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" } pretty_seasons = {"winter": "Winter", "spring": "Spring", "summer": "Summer", "fall": "Fall"} -pretty_names = { - "anidb_id": "AniDB ID", "anidb_relation": "AniDB Relation", "anidb_popular": "AniDB Popular", - "anilist_genre": "AniList Genre", "anilist_id": "AniList ID", "anilist_popular": "AniList Popular", - "anilist_relations": "AniList Relations", "anilist_season": "AniList Season", "anilist_studio": "AniList Studio", - "anilist_tag": "AniList Tag", "anilist_top_rated": "AniList Top Rated", - "icheckmovies_list": "I Check Movies List", - "imdb_list": "IMDb List", "imdb_id": "IMDb ID", - "letterboxd_list": "Letterboxd List", "letterboxd_list_details": "Letterboxd List", - "mal_id": "MyAnimeList ID", "mal_all": "MyAnimeList All", "mal_airing": "MyAnimeList Airing", - "mal_upcoming": "MyAnimeList Upcoming", "mal_tv": "MyAnimeList TV", "mal_ova": "MyAnimeList OVA", - "mal_movie": "MyAnimeList Movie", "mal_special": "MyAnimeList Special", "mal_popular": "MyAnimeList Popular", - "mal_favorite": "MyAnimeList Favorite", "mal_season": "MyAnimeList Season", - "mal_suggested": "MyAnimeList Suggested", "mal_userlist": "MyAnimeList Userlist", - "plex_all": "Plex All", "plex_collection": "Plex Collection", "plex_search": "Plex Search", - "stevenlu_popular": "Steven Lu Popular", "tautulli_popular": "Tautulli Popular", "tautulli_watched": "Tautulli Watched", - "tmdb_actor": "TMDb Actor", "tmdb_actor_details": "TMDb Actor", - "tmdb_collection": "TMDb Collection", "tmdb_collection_details": "TMDb Collection", - "tmdb_company": "TMDb Company", "tmdb_crew": "TMDb Crew", "tmdb_crew_details": "TMDb Crew", - "tmdb_director": "TMDb Director", "tmdb_director_details": "TMDb Director", "tmdb_discover": "TMDb Discover", - "tmdb_keyword": "TMDb Keyword", "tmdb_list": "TMDb List", "tmdb_list_details": "TMDb List", - "tmdb_movie": "TMDb Movie", "tmdb_movie_details": "TMDb Movie", "tmdb_network": "TMDb Network", - "tmdb_now_playing": "TMDb Now Playing", "tmdb_person": "TMDb Person", "tmdb_popular": "TMDb Popular", - "tmdb_producer": "TMDb Producer", "tmdb_producer_details": "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", "tmdb_writer_details": "TMDb Writer", - "trakt_collected": "Trakt Collected", "trakt_collection": "Trakt Collection", - "trakt_list": "Trakt List", "trakt_list_details": "Trakt List", - "trakt_popular": "Trakt Popular", "trakt_recommended": "Trakt Recommended", "trakt_trending": "Trakt Trending", - "trakt_watched": "Trakt Watched", "trakt_watchlist": "Trakt Watchlist", - "tvdb_list": "TVDb List", "tvdb_list_details": "TVDb List", - "tvdb_movie": "TVDb Movie", "tvdb_movie_details": "TVDb Movie", - "tvdb_show": "TVDb Show", "tvdb_show_details": "TVDb Show" -} pretty_ids = {"anidbid": "AniDB", "imdbid": "IMDb", "mal_id": "MyAnimeList", "themoviedb_id": "TMDb", "thetvdb_id": "TVDb", "tvdbid": "TVDb"} def tab_new_lines(data):