pull/351/head
meisnate12 3 years ago
parent 9d89d36c2c
commit 74db60bf17

@ -74,19 +74,21 @@ class AniDB:
return anidb_ids[:limit] return anidb_ids[:limit]
def get_items(self, method, data, language): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method
anidb_ids = [] anidb_ids = []
if method == "anidb_popular": 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]) anidb_ids.extend(self._popular(language)[:data])
elif method == "anidb_tag": 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) 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: else:
logger.info(f"Processing {pretty}: {data}") raise Failed(f"AniDB Error: Method {method} not supported")
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")
movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids) movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids)
logger.debug("") logger.debug("")
logger.debug(f"{len(anidb_ids)} AniDB IDs Found: {anidb_ids}") logger.debug(f"{len(anidb_ids)} AniDB IDs Found: {anidb_ids}")

@ -210,27 +210,31 @@ class AniList:
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): def get_items(self, method, data):
pretty = util.pretty_names[method] if method in util.pretty_names else method
if method == "anilist_id": if method == "anilist_id":
logger.info(f"Processing AniList ID: {data}")
anilist_id, name = self._validate(data) anilist_id, name = self._validate(data)
anilist_ids = [anilist_id] anilist_ids = [anilist_id]
logger.info(f"Processing {pretty}: ({data}) {name}") elif method == "anilist_popular":
elif method in ["anilist_popular", "anilist_top_rated"]: logger.info(f"Processing AniList Popular: {data} Anime")
anilist_ids = self._popular(data) if method == "anilist_popular" else self._top_rated(data) anilist_ids = self._popular(data)
logger.info(f"Processing {pretty}: {data} Anime") elif method == "anilist_top_rated":
logger.info(f"Processing AniList Top Rated: {data} Anime")
anilist_ids = self._top_rated(data)
elif method == "anilist_season": 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"]) 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": 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"]) 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": 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"]) 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 == "anilist_studio":
elif method in ["anilist_studio", "anilist_relations"]: anilist_ids, name = self._studio(data)
if method == "anilist_studio": anilist_ids, name = self._studio(data) logger.info(f"Processing AniList Studio: ({data}) {name} ({len(anilist_ids)} Anime)")
else: anilist_ids, _, name = self._relations(data) elif method == "anilist_relations":
logger.info(f"Processing {pretty}: ({data}) {name} ({len(anilist_ids)} Anime)") anilist_ids, _, name = self._relations(data)
logger.info(f"Processing AniList Relations: ({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)

@ -35,10 +35,9 @@ class ICheckMovies:
return valid_lists return valid_lists
def get_items(self, method, data, language): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method
movie_ids = [] movie_ids = []
if method == "icheckmovies_list": if method == "icheckmovies_list":
logger.info(f"Processing {pretty}: {data}") logger.info(f"Processing ICheckMovies List: {data}")
imdb_ids = self._parse_list(data, language) imdb_ids = self._parse_list(data, language)
total_ids = len(imdb_ids) total_ids = len(imdb_ids)
for i, imdb_id in enumerate(imdb_ids, 1): for i, imdb_id in enumerate(imdb_ids, 1):

@ -96,7 +96,6 @@ class IMDb:
raise ValueError(f"IMDb Error: No IMDb IDs Found at {imdb_url}") raise ValueError(f"IMDb Error: No IMDb IDs Found at {imdb_url}")
def get_items(self, method, data, language, is_movie): def get_items(self, method, data, language, is_movie):
pretty = util.pretty_names[method] if method in util.pretty_names else method
show_ids = [] show_ids = []
movie_ids = [] movie_ids = []
fail_ids = [] fail_ids = []
@ -110,11 +109,11 @@ class IMDb:
fail_ids.append(imdb_id) fail_ids.append(imdb_id)
if method == "imdb_id": if method == "imdb_id":
logger.info(f"Processing {pretty}: {data}") logger.info(f"Processing IMDb ID: {data}")
run_convert(data) run_convert(data)
elif method == "imdb_list": elif method == "imdb_list":
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 IMDb List: {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)
for i, imdb in enumerate(imdb_ids, 1): for i, imdb in enumerate(imdb_ids, 1):

@ -51,31 +51,33 @@ class Letterboxd:
return valid_lists return valid_lists
def get_items(self, method, data, language): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method
movie_ids = [] movie_ids = []
logger.info(f"Processing {pretty}: {data}") if method == "letterboxd_list":
items = self._parse_list(data, language) logger.info(f"Processing Letterboxd List: {data}")
total_items = len(items) items = self._parse_list(data, language)
if total_items > 0: total_items = len(items)
for i, item in enumerate(items, 1): if total_items > 0:
letterboxd_id, slug = item for i, item in enumerate(items, 1):
util.print_return(f"Finding TMDb ID {i}/{total_items}") letterboxd_id, slug = item
tmdb_id = None util.print_return(f"Finding TMDb ID {i}/{total_items}")
expired = None tmdb_id = None
if self.config.Cache: expired = None
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: if self.config.Cache:
self.config.Cache.update_letterboxd_map(expired, letterboxd_id, tmdb_id) tmdb_id, expired = self.config.Cache.query_letterboxd_map(letterboxd_id)
movie_ids.append(tmdb_id) if not tmdb_id or expired is not False:
logger.info(util.adjust_space(f"Processed {total_items} TMDb IDs")) 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: 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("")
logger.debug(f"{len(movie_ids)} TMDb IDs Found: {movie_ids}") logger.debug(f"{len(movie_ids)} TMDb IDs Found: {movie_ids}")
return movie_ids, [] return movie_ids, []

@ -13,6 +13,12 @@ mal_ranked_name = {
"mal_all": "all", "mal_airing": "airing", "mal_upcoming": "upcoming", "mal_tv": "tv", "mal_ova": "ova", "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_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_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"] season_sort_options = ["score", "members"]
pretty_names = { pretty_names = {
@ -150,22 +156,21 @@ class MyAnimeList:
return self._parse_request(url) return self._parse_request(url)
def get_items(self, method, data): def get_items(self, method, data):
pretty = util.pretty_names[method] if method in util.pretty_names else method
if method == "mal_id": if method == "mal_id":
logger.info(f"Processing MyAnimeList ID: {data}")
mal_ids = [data] mal_ids = [data]
logger.info(f"Processing {pretty}: {data}")
elif method in mal_ranked_name: 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) mal_ids = self._ranked(mal_ranked_name[method], data)
logger.info(f"Processing {pretty}: {data} Anime")
elif method == "mal_season": 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"]) 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": elif method == "mal_suggested":
logger.info(f"Processing MyAnimeList Suggested: {data} Anime")
mal_ids = self._suggestions(data) mal_ids = self._suggestions(data)
logger.info(f"Processing {pretty}: {data} Anime")
elif method == "mal_userlist": 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"]) 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: 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)

@ -579,17 +579,17 @@ class Plex:
return valid_collections return valid_collections
def get_items(self, method, data): 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" media_type = "Movie" if self.is_movie else "Show"
items = [] items = []
if method == "plex_all": 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() items = self.get_all()
elif method == "plex_search": elif method == "plex_search":
util.print_multiline(data[1], info=True) util.print_multiline(data[1], info=True)
items = self.get_filter_items(data[2]) items = self.get_filter_items(data[2])
elif method == "plex_collectionless": elif method == "plex_collectionless":
good_collections = [] good_collections = []
logger.info(f"Processing Plex Collectionless")
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

@ -1,5 +1,4 @@
import logging import logging
from modules import util
from modules.util import Failed from modules.util import Failed
logger = logging.getLogger("Plex Meta Manager") logger = logging.getLogger("Plex Meta Manager")
@ -12,11 +11,10 @@ class StevenLu:
self.config = config self.config = config
def get_items(self, method): def get_items(self, method):
pretty = util.pretty_names[method] if method in util.pretty_names else method
movie_ids = [] movie_ids = []
fail_ids = [] fail_ids = []
if method == "stevenlu_popular": 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): for i in self.config.get_json(base_url):
tmdb_id = self.config.Convert.imdb_to_tmdb(i["imdb_id"]) tmdb_id = self.config.Convert.imdb_to_tmdb(i["imdb_id"])
if tmdb_id: if tmdb_id:

@ -232,7 +232,7 @@ class TMDb:
return tmdb_id return tmdb_id
def get_items(self, method, data, is_movie): 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" media_type = "Movie" if is_movie else "Show"
movie_ids = [] movie_ids = []
show_ids = [] show_ids = []

@ -162,7 +162,7 @@ class Trakt:
return trakt_values return trakt_values
def get_items(self, method, data, is_movie): 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" 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)

@ -136,18 +136,17 @@ class TVDb:
raise Failed(f"TVDb Error: {tvdb_url} must begin with {urls['list']}") raise Failed(f"TVDb Error: {tvdb_url} must begin with {urls['list']}")
def get_items(self, method, data, language): def get_items(self, method, data, language):
pretty = util.pretty_names[method] if method in util.pretty_names else method
show_ids = [] show_ids = []
movie_ids = [] movie_ids = []
logger.info(f"Processing {pretty}: {data}")
if method == "tvdb_show": if method == "tvdb_show":
logger.info(f"Processing TVDb Show: {data}")
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":
logger.info(f"Processing TVDb Movie: {data}")
movie_ids.append(self.get_movie(language, data).tmdb_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) logger.info(f"Processing TVDb List: {data}")
movie_ids.extend(tmdb_ids) movie_ids, show_ids = self._ids_from_url(data, language)
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")
logger.debug("") logger.debug("")

@ -53,40 +53,6 @@ pretty_months = {
7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December" 7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December"
} }
pretty_seasons = {"winter": "Winter", "spring": "Spring", "summer": "Summer", "fall": "Fall"} 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"} pretty_ids = {"anidbid": "AniDB", "imdbid": "IMDb", "mal_id": "MyAnimeList", "themoviedb_id": "TMDb", "thetvdb_id": "TVDb", "tvdbid": "TVDb"}
def tab_new_lines(data): def tab_new_lines(data):

Loading…
Cancel
Save