renamed arms

pull/240/head
meisnate12 4 years ago
parent d27cb1896a
commit b6e58a3482

@ -61,7 +61,7 @@ class AniDBAPI:
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.Arms.anidb_to_ids(anidb_ids, language)
movie_ids, show_ids = self.config.Convert.anidb_to_ids(anidb_ids, language)
if status_message:
logger.debug(f"AniDB IDs Found: {anidb_ids}")
logger.debug(f"TMDb IDs Found: {movie_ids}")

@ -249,7 +249,7 @@ class AniListAPI:
logger.info(f"Processing {pretty}: ({data}) {name} ({len(anilist_ids)} Anime)")
else:
raise Failed(f"AniList Error: Method {method} not supported")
movie_ids, show_ids = self.config.Arms.anilist_to_ids(anilist_ids, language)
movie_ids, show_ids = self.config.Convert.anilist_to_ids(anilist_ids, language)
if status_message:
logger.debug(f"AniList IDs Found: {anilist_ids}")
logger.debug(f"Shows Found: {show_ids}")

@ -1308,7 +1308,7 @@ class CollectionBuilder:
continue
match = True
if arr_filters:
show = self.config.TMDb.get_show(self.config.TMDb.convert_tvdb_to_tmdb(missing_id))
show = self.config.TMDb.get_show(self.config.Convert.tvdb_to_tmdb(missing_id))
for filter_method, filter_data in arr_filters:
if (filter_method == "tmdb_vote_count.gte" and show.vote_count < filter_data) \
or (filter_method == "tmdb_vote_count.lte" and show.vote_count > filter_data):

@ -2,8 +2,8 @@ import logging, os
from modules import util
from modules.anidb import AniDBAPI
from modules.anilist import AniListAPI
from modules.arms import ArmsAPI
from modules.cache import Cache
from modules.convert import Convert
from modules.imdb import IMDbAPI
from modules.letterboxd import LetterboxdAPI
from modules.mal import MyAnimeListAPI
@ -262,7 +262,7 @@ class Config:
self.TVDb = TVDbAPI(self)
self.IMDb = IMDbAPI(self)
self.AniDB = AniDBAPI(self)
self.Arms = ArmsAPI(self)
self.Convert = Convert(self)
self.AniList = AniListAPI(self)
self.Letterboxd = LetterboxdAPI(self)

@ -6,7 +6,7 @@ from retrying import retry
logger = logging.getLogger("Plex Meta Manager")
class ArmsAPI:
class Convert:
def __init__(self, config):
self.config = config
self.arms_url = "https://relations.yuna.moe/api/ids"
@ -17,9 +17,7 @@ class ArmsAPI:
def _get_anidb(self):
return html.fromstring(requests.get(self.anidb_url).content)
def anidb_to_tvdb(self, anidb_id): return self._anidb(anidb_id, "tvdbid")
def anidb_to_imdb(self, anidb_id): return self._anidb(anidb_id, "imdbid")
def _anidb(self, input_id, to_id):
def _anidb(self, input_id, to_id, fail=False):
ids = self.AniDBIDs.xpath(f"//anime[contains(@anidbid, '{input_id}')]/@{to_id}")
if len(ids) > 0:
try:
@ -27,61 +25,17 @@ class ArmsAPI:
return ids[0].split(",") if to_id == "imdbid" else int(ids[0])
raise ValueError
except ValueError:
raise Failed(f"Arms Error: No {util.pretty_ids[to_id]} ID found for AniDB ID: {input_id}")
fail_text = f"Convert Error: No {util.pretty_ids[to_id]} ID found for AniDB ID: {input_id}"
else:
raise Failed(f"Arms Error: AniDB ID: {input_id} not found")
fail_text = f"Convert Error: AniDB ID: {input_id} not found"
if fail:
raise Failed(fail_text)
return None
@retry(stop_max_attempt_number=6, wait_fixed=10000)
def _request(self, ids):
return requests.post(self.arms_url, json=ids).json()
def mal_to_anidb(self, mal_id):
anime_ids = self._arms_ids(mal_ids=mal_id)
if anime_ids[0] is None:
raise Failed(f"Arms Error: MyAnimeList ID: {mal_id} does not exist")
if anime_ids[0]["anidb"] is None:
raise Failed(f"Arms Error: No AniDB ID for MyAnimeList ID: {mal_id}")
return anime_ids[0]["anidb"]
def anidb_to_ids(self, anidb_list, language):
show_ids = []
movie_ids = []
for anidb_id in anidb_list:
try:
for imdb_id in self.anidb_to_imdb(anidb_id):
tmdb_id, _ = self.imdb_to_ids(imdb_id, language)
if tmdb_id:
movie_ids.append(tmdb_id)
break
else:
raise Failed
except Failed:
try:
tvdb_id = self.anidb_to_tvdb(anidb_id)
if tvdb_id:
show_ids.append(tvdb_id)
except Failed:
logger.error(f"Arms Error: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
return movie_ids, show_ids
def anilist_to_ids(self, anilist_ids, language):
anidb_ids = []
for id_set in self._arms_ids(anilist_ids=anilist_ids):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Arms Error: AniDB ID not found for AniList ID: {id_set['anilist']}")
return self.anidb_to_ids(anidb_ids, language)
def myanimelist_to_ids(self, mal_ids, language):
anidb_ids = []
for id_set in self._arms_ids(mal_ids=mal_ids):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Arms Error: AniDB ID not found for MyAnimeList ID: {id_set['myanimelist']}")
return self.anidb_to_ids(anidb_ids, language)
def _arms_ids(self, anilist_ids=None, anidb_ids=None, mal_ids=None):
all_ids = []
def collect_ids(ids, id_name):
@ -113,6 +67,41 @@ class ArmsAPI:
converted_ids.append(anime_ids)
return converted_ids
def anidb_to_ids(self, anidb_list, language):
show_ids = []
movie_ids = []
for anidb_id in anidb_list:
try:
for imdb_id in self.anidb_to_imdb(anidb_id, fail=True):
tmdb_id, _ = self.imdb_to_ids(imdb_id, language)
if tmdb_id:
movie_ids.append(tmdb_id)
except Failed:
tvdb_id = self.anidb_to_tvdb(anidb_id)
if tvdb_id:
show_ids.append(tvdb_id)
else:
logger.error(f"Convert Error: No TVDb ID or IMDb ID found for AniDB ID: {anidb_id}")
return movie_ids, show_ids
def anilist_to_ids(self, anilist_ids, language):
anidb_ids = []
for id_set in self._arms_ids(anilist_ids=anilist_ids):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Convert Error: AniDB ID not found for AniList ID: {id_set['anilist']}")
return self.anidb_to_ids(anidb_ids, language)
def myanimelist_to_ids(self, mal_ids, language):
anidb_ids = []
for id_set in self._arms_ids(mal_ids=mal_ids):
if id_set["anidb"] is not None:
anidb_ids.append(id_set["anidb"])
else:
logger.error(f"Convert Error: AniDB ID not found for MyAnimeList ID: {id_set['myanimelist']}")
return self.anidb_to_ids(anidb_ids, language)
def imdb_to_ids(self, imdb_id, language):
update_tmdb = False
update_tvdb = False
@ -133,18 +122,10 @@ class ArmsAPI:
tvdb_id = None
from_cache = tmdb_id is not None or tvdb_id is not None
if not tmdb_id and not tvdb_id and self.config.TMDb:
try: tmdb_id = self.config.TMDb.convert_imdb_to_tmdb(imdb_id)
except Failed: pass
if not tmdb_id and not tvdb_id and self.config.TMDb:
try: tvdb_id = self.config.TMDb.convert_imdb_to_tvdb(imdb_id)
except Failed: pass
if not tmdb_id and not tvdb_id and self.config.Trakt:
try: tmdb_id = self.convert_imdb_to_tmdb(imdb_id)
except Failed: pass
if not tmdb_id and not tvdb_id and self.config.Trakt:
try: tvdb_id = self.convert_imdb_to_tvdb(imdb_id)
except Failed: pass
if not tmdb_id and not tvdb_id:
tmdb_id = self.imdb_to_tmdb(imdb_id)
if not tmdb_id and not tvdb_id:
tvdb_id = self.imdb_to_tvdb(imdb_id)
if tmdb_id and not from_cache:
try: self.config.TMDb.get_movie(tmdb_id)
except Failed: tmdb_id = None
@ -152,7 +133,7 @@ class ArmsAPI:
try: self.config.TVDb.get_series(language, tvdb_id)
except Failed: tvdb_id = None
if not tmdb_id and not tvdb_id:
raise Failed(f"Arms Error: No TMDb ID or TVDb ID found for IMDb: {imdb_id}")
raise Failed(f"Convert Error: No TMDb ID or TVDb ID found for IMDb: {imdb_id}")
if self.config.Cache:
if tmdb_id and update_tmdb is not False:
self.config.Cache.update_imdb("movie", update_tmdb, imdb_id, tmdb_id)
@ -160,7 +141,13 @@ class ArmsAPI:
self.config.Cache.update_imdb("show", update_tvdb, imdb_id, tvdb_id)
return tmdb_id, tvdb_id
def convert_tmdb_to_imdb(self, tmdb_id, is_movie=True, fail=False):
def anidb_to_tvdb(self, anidb_id, fail=False):
return self._anidb(anidb_id, "tvdbid", fail=fail)
def anidb_to_imdb(self, anidb_id, fail=False):
return self._anidb(anidb_id, "imdbid", fail=fail)
def tmdb_to_imdb(self, tmdb_id, is_movie=True, fail=False):
try:
return self.config.TMDb.convert_from(tmdb_id, "imdb_id", is_movie)
except Failed:
@ -170,10 +157,10 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No IMDb ID Found for TMDb ID: {tmdb_id}")
raise Failed(f"Convert Error: No IMDb ID Found for TMDb ID: {tmdb_id}")
return None
def convert_imdb_to_tmdb(self, imdb_id, is_movie=True, fail=False):
def imdb_to_tmdb(self, imdb_id, is_movie=True, fail=False):
try:
return self.config.TMDb.convert_to(imdb_id, "imdb_id", is_movie)
except Failed:
@ -183,10 +170,11 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No TMDb ID Found for IMDb ID: {imdb_id}")
raise Failed(f"Convert Error: No TMDb ID Found for IMDb ID: {imdb_id}")
return None
def convert_tmdb_to_tvdb(self, tmdb_id, fail=False):
# TODO
def tmdb_to_tvdb(self, tmdb_id, fail=False):
try:
return self.config.TMDb.convert_from(tmdb_id, "tvdb_id", False)
except Failed:
@ -196,10 +184,11 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No TVDb ID Found for TMDb ID: {tmdb_id}")
raise Failed(f"Convert Error: No TVDb ID Found for TMDb ID: {tmdb_id}")
return None
def convert_tvdb_to_tmdb(self, tvdb_id, fail=False):
# TODO
def tvdb_to_tmdb(self, tvdb_id, fail=False):
try:
return self.config.TMDb.convert_to(tvdb_id, "tvdb_id", False)
except Failed:
@ -209,12 +198,12 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No TMDb ID Found for TVDb ID: {tvdb_id}")
raise Failed(f"Convert Error: No TMDb ID Found for TVDb ID: {tvdb_id}")
return None
def convert_tvdb_to_imdb(self, tvdb_id, fail=False):
def tvdb_to_imdb(self, tvdb_id, fail=False):
try:
return self.convert_tmdb_to_imdb(self.convert_tvdb_to_tmdb(tvdb_id), False)
return self.tmdb_to_imdb(self.tvdb_to_tmdb(tvdb_id), False)
except Failed:
if self.config.Trakt:
try:
@ -222,12 +211,12 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No IMDb ID Found for TVDb ID: {tvdb_id}")
raise Failed(f"Convert Error: No IMDb ID Found for TVDb ID: {tvdb_id}")
return None
def convert_imdb_to_tvdb(self, imdb_id, fail=False):
def imdb_to_tvdb(self, imdb_id, fail=False):
try:
return self.convert_tmdb_to_tvdb(self.convert_imdb_to_tmdb(imdb_id, False))
return self.tmdb_to_tvdb(self.imdb_to_tmdb(imdb_id, False))
except Failed:
if self.config.Trakt:
try:
@ -235,7 +224,7 @@ class ArmsAPI:
except Failed:
pass
if fail:
raise Failed(f"Arms Error: No TVDb ID Found for IMDb ID: {imdb_id}")
raise Failed(f"Convert Error: No TVDb ID Found for IMDb ID: {imdb_id}")
return None
def get_id(self, item, library, length):
@ -295,37 +284,31 @@ class ArmsAPI:
if not error_message:
if mal_id and not anidb_id:
try: anidb_id = self.mal_to_anidb(mal_id)
except Failed: pass
anime_ids = self._arms_ids(mal_ids=mal_id)
if anime_ids[0] and anime_ids[0]["anidb"]:
anidb_id = anime_ids[0]["anidb"]
if anidb_id and not tvdb_id:
try: tvdb_id = self.anidb_to_tvdb(anidb_id)
except Failed: pass
tvdb_id = self.anidb_to_tvdb(anidb_id)
if anidb_id and not imdb_id:
try: imdb_id = self.anidb_to_imdb(anidb_id)
except Failed: pass
imdb_id = self.anidb_to_imdb(anidb_id)
if not tmdb_id and imdb_id:
if isinstance(imdb_id, list):
tmdb_id = []
new_imdb_id = []
for imdb in imdb_id:
try:
tmdb_id.append(self.convert_imdb_to_tmdb(imdb_id, fail=True))
tmdb_id.append(self.imdb_to_tmdb(imdb_id, fail=True))
new_imdb_id.append(imdb)
except Failed:
continue
imdb_id = new_imdb_id
else:
tmdb_id = self.convert_imdb_to_tmdb(imdb_id)
if not tmdb_id and tvdb_id and library.is_show:
tmdb_id = self.convert_tvdb_to_tmdb(tvdb_id)
if not imdb_id and tmdb_id and library.is_movie:
imdb_id = self.convert_tmdb_to_imdb(tmdb_id)
if not imdb_id and tvdb_id and library.is_show:
imdb_id = self.convert_tvdb_to_imdb(tvdb_id)
if not tvdb_id and tmdb_id and library.is_show:
tvdb_id = self.convert_tmdb_to_tvdb(tmdb_id)
if not tvdb_id and imdb_id and library.is_show:
tvdb_id = self.convert_imdb_to_tvdb(imdb_id)
tmdb_id = self.imdb_to_tmdb(imdb_id)
if not tmdb_id and tvdb_id and library.is_show: tmdb_id = self.tvdb_to_tmdb(tvdb_id)
if not imdb_id and tmdb_id and library.is_movie: imdb_id = self.tmdb_to_imdb(tmdb_id)
if not imdb_id and tvdb_id and library.is_show: imdb_id = self.tvdb_to_imdb(tvdb_id)
if not tvdb_id and tmdb_id and library.is_show: tvdb_id = self.tmdb_to_tvdb(tmdb_id)
if not tvdb_id and imdb_id and library.is_show: tvdb_id = self.imdb_to_tvdb(imdb_id)
if (not tmdb_id and library.is_movie) or (not tvdb_id and not (anidb_id and tmdb_id) and library.is_show):
service_name = "TMDb ID" if library.is_movie else "TVDb ID"

@ -100,7 +100,7 @@ class IMDbAPI:
if method == "imdb_id":
if status_message:
logger.info(f"Processing {pretty}: {data}")
tmdb_id, tvdb_id = self.config.Arms.imdb_to_ids(data, language)
tmdb_id, tvdb_id = self.config.Convert.imdb_to_ids(data, language)
if tmdb_id: movie_ids.append(tmdb_id)
if tvdb_id: show_ids.append(tvdb_id)
elif method == "imdb_list":
@ -113,7 +113,7 @@ class IMDbAPI:
for i, imdb_id in enumerate(imdb_ids, 1):
length = util.print_return(length, f"Converting IMDb ID {i}/{total_ids}")
try:
tmdb_id, tvdb_id = self.config.Arms.imdb_to_ids(imdb_id, language)
tmdb_id, tvdb_id = self.config.Convert.imdb_to_ids(imdb_id, language)
if tmdb_id: movie_ids.append(tmdb_id)
if tvdb_id: show_ids.append(tvdb_id)
except Failed as e: logger.warning(e)

@ -219,7 +219,7 @@ class MyAnimeListAPI:
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.Arms.myanimelist_to_ids(mal_ids, language)
movie_ids, show_ids = self.config.Convert.myanimelist_to_ids(mal_ids, language)
if status_message:
logger.debug(f"MyAnimeList IDs Found: {mal_ids}")
logger.debug(f"Shows Found: {show_ids}")

@ -1,346 +0,0 @@
import logging
from modules import util
from modules.config import Config
from modules.util import Failed
logger = logging.getLogger("Plex Meta Manager")
def run_tests(default_dir):
try:
config = Config(default_dir)
logger.info("")
util.separator("Mapping Tests")
for library in config.libraries:
config.map_guids(library)
anidb_tests(config)
imdb_tests(config)
mal_tests(config)
tautulli_tests(config)
tmdb_tests(config)
trakt_tests(config)
tvdb_tests(config)
util.separator("Finished All Plex Meta Manager Tests")
except KeyboardInterrupt:
util.separator("Canceled Plex Meta Manager Tests")
def anidb_tests(config):
if config.AniDB:
util.separator("AniDB Tests")
try:
config.AniDB.get_items("anidb_id", 69, "en", status_message=False)
logger.info("Success | Get AniDB ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get AniDB ID: {e}")
try:
config.AniDB.get_items("anidb_relation", 69, "en", status_message=False)
logger.info("Success | Get AniDB Relation")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get AniDB Relation: {e}")
try:
config.AniDB.get_items("anidb_popular", 30, "en", status_message=False)
logger.info("Success | Get AniDB Popular")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get AniDB Popular: {e}")
try:
config.AniDB.validate_anidb_list(["69", "112"], "en")
logger.info("Success | Validate AniDB List")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Validate AniDB List: {e}")
else:
util.separator("AniDB Not Configured")
def imdb_tests(config):
if config.IMDb:
util.separator("IMDb Tests")
tmdb_ids, tvdb_ids = config.IMDb.get_items("imdb_list", {"url": "https://www.imdb.com/search/title/?groups=top_1000", "limit": 0}, "en", status_message=False)
if len(tmdb_ids) == 1000: logger.info("Success | IMDb URL get TMDb IDs")
else: logger.error(f"Failure | IMDb URL get TMDb IDs: {len(tmdb_ids)} Should be 1000")
tmdb_ids, tvdb_ids = config.IMDb.get_items("imdb_list", {"url": "https://www.imdb.com/list/ls026173135/", "limit": 0}, "en", status_message=False)
if len(tmdb_ids) == 250: logger.info("Success | IMDb URL get TMDb IDs")
else: logger.error(f"Failure | IMDb URL get TMDb IDs: {len(tmdb_ids)} Should be 250")
tmdb_ids, tvdb_ids = config.IMDb.get_items("imdb_id", "tt0814243", "en", status_message=False)
if len(tmdb_ids) == 1: logger.info("Success | IMDb ID get TMDb IDs")
else: logger.error(f"Failure | IMDb ID get TMDb IDs: {len(tmdb_ids)} Should be 1")
else:
util.separator("IMDb Not Configured")
def mal_tests(config):
if config.MyAnimeList:
util.separator("MyAnimeList Tests")
mal_list_tests = [
("mal_all", 10),
("mal_airing", 10),
("mal_upcoming", 10),
("mal_tv", 10),
("mal_movie", 10),
("mal_ova", 10),
("mal_special", 10),
("mal_popular", 10),
("mal_favorite", 10),
("mal_suggested", 10),
("mal_userlist", {"limit": 10, "username": "@me", "status": "completed", "sort_by": "list_score"}),
("mal_season", {"limit": 10, "season": "fall", "year": 2020, "sort_by": "anime_score"})
]
for mal_list_test in mal_list_tests:
try:
config.MyAnimeList.get_items(mal_list_test[0], mal_list_test[1], status_message=False)
logger.info(f"Success | Get Anime using {util.pretty_names[mal_list_test[0]]}")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Anime using {util.pretty_names[mal_list_test[0]]}: {e}")
else:
util.separator("MyAnimeList Not Configured")
def tautulli_tests(config):
if config.libraries[0].Tautulli:
util.separator("Tautulli Tests")
try:
config.libraries[0].Tautulli.get_section_id(config.libraries[0].name)
logger.info("Success | Get Section ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Section ID: {e}")
try:
config.libraries[0].Tautulli.get_popular(config.libraries[0], status_message=False)
logger.info("Success | Get Popular")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Popular: {e}")
try:
config.libraries[0].Tautulli.get_top(config.libraries[0], status_message=False)
logger.info("Success | Get Top")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Top: {e}")
else:
util.separator("Tautulli Not Configured")
def tmdb_tests(config):
if config.TMDb:
util.separator("TMDb Tests")
try:
config.TMDb.convert_imdb_to_tmdb("tt0076759")
logger.info("Success | Convert IMDb to TMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert IMDb to TMDb: {e}")
try:
config.TMDb.convert_tmdb_to_imdb(11)
logger.info("Success | Convert TMDb to IMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TMDb to IMDb: {e}")
try:
config.TMDb.convert_imdb_to_tvdb("tt0458290")
logger.info("Success | Convert IMDb to TVDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert IMDb to TVDb: {e}")
try:
config.TMDb.convert_tvdb_to_imdb(83268)
logger.info("Success | Convert TVDb to IMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TVDb to IMDb: {e}")
tmdb_list_tests = [
([11], "Movie"),
([4194], "Show"),
([10], "Collection"),
([1], "Person"),
([1], "Company"),
([2739], "Network"),
([8136], "List")
]
for tmdb_list_test in tmdb_list_tests:
try:
config.TMDb.validate_tmdb_list(tmdb_list_test[0], tmdb_type=tmdb_list_test[1])
logger.info(f"Success | Get TMDb {tmdb_list_test[1]}")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get TMDb {tmdb_list_test[1]}: {e}")
tmdb_list_tests = [
("tmdb_discover", {"sort_by": "popularity.desc", "limit": 100}, True),
("tmdb_discover", {"sort_by": "popularity.desc", "limit": 100}, False),
("tmdb_company", 1, True),
("tmdb_company", 1, False),
("tmdb_network", 2739, False),
("tmdb_keyword", 180547, True),
("tmdb_keyword", 180547, False),
("tmdb_now_playing", 10, True),
("tmdb_popular", 10, True),
("tmdb_popular", 10, False),
("tmdb_top_rated", 10, True),
("tmdb_top_rated", 10, False),
("tmdb_trending_daily", 10, True),
("tmdb_trending_daily", 10, False),
("tmdb_trending_weekly", 10, True),
("tmdb_trending_weekly", 10, False),
("tmdb_list", 7068209, True),
("tmdb_list", 7068209, False),
("tmdb_movie", 11, True),
("tmdb_collection", 10, True),
("tmdb_show", 4194, False)
]
for tmdb_list_test in tmdb_list_tests:
try:
config.TMDb.get_items(tmdb_list_test[0], tmdb_list_test[1], tmdb_list_test[2], status_message=False)
logger.info(f"Success | Get {'Movies' if tmdb_list_test[2] else 'Shows'} using {util.pretty_names[tmdb_list_test[0]]}")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get {'Movies' if tmdb_list_test[2] else 'Shows'} using {util.pretty_names[tmdb_list_test[0]]}: {e}")
else:
util.separator("TMDb Not Configured")
def trakt_tests(config):
if config.Trakt:
util.separator("Trakt Tests")
try:
config.Trakt.convert_imdb_to_tmdb("tt0076759")
logger.info("Success | Convert IMDb to TMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert IMDb to TMDb: {e}")
try:
config.Trakt.convert_tmdb_to_imdb(11)
logger.info("Success | Convert TMDb to IMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TMDb to IMDb: {e}")
try:
config.Trakt.convert_imdb_to_tvdb("tt0458290")
logger.info("Success | Convert IMDb to TVDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert IMDb to TVDb: {e}")
try:
config.Trakt.convert_tvdb_to_imdb(83268)
logger.info("Success | Convert TVDb to IMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TVDb to IMDb: {e}")
try:
config.Trakt.convert_tmdb_to_tvdb(11)
logger.info("Success | Convert TMDb to TVDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TMDb to TVDb: {e}")
try:
config.Trakt.convert_tvdb_to_tmdb(83268)
logger.info("Success | Convert TVDb to TMDb")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Convert TVDb to TMDb: {e}")
try:
config.Trakt.validate_trakt_list(["https://trakt.tv/users/movistapp/lists/christmas-movies"])
logger.info("Success | Get List")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get List: {e}")
try:
config.Trakt.validate_trakt_watchlist(["me"], True)
logger.info("Success | Get Watchlist Movies")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Watchlist Movies: {e}")
try:
config.Trakt.validate_trakt_watchlist(["me"], False)
logger.info("Success | Get Watchlist Shows")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get Watchlist Shows: {e}")
trakt_list_tests = [
("trakt_list", "https://trakt.tv/users/movistapp/lists/christmas-movies", True),
("trakt_trending", 10, True),
("trakt_trending", 10, False),
("trakt_watchlist", "me", True),
("trakt_watchlist", "me", False)
]
for trakt_list_test in trakt_list_tests:
try:
config.Trakt.get_items(trakt_list_test[0], trakt_list_test[1], trakt_list_test[2], status_message=False)
logger.info(f"Success | Get {'Movies' if trakt_list_test[2] else 'Shows'} using {util.pretty_names[trakt_list_test[0]]}")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | Get {'Movies' if trakt_list_test[2] else 'Shows'} using {util.pretty_names[trakt_list_test[0]]}: {e}")
else:
util.separator("Trakt Not Configured")
def tvdb_tests(config):
if config.TVDb:
util.separator("TVDb Tests")
tmdb_ids, tvdb_ids = config.TVDb.get_items("tvdb_list", "https://www.thetvdb.com/lists/arrowverse", "en", status_message=False)
if len(tvdb_ids) == 10 and len(tmdb_ids) == 0: logger.info("Success | TVDb URL get TVDb IDs and TMDb IDs")
else: logger.error(f"Failure | TVDb URL get TVDb IDs and TMDb IDs: {len(tvdb_ids)} Should be 10 and {len(tmdb_ids)} Should be 0")
tmdb_ids, tvdb_ids = config.TVDb.get_items("tvdb_list", "https://www.thetvdb.com/lists/6957", "en", status_message=False)
if len(tvdb_ids) == 4 and len(tmdb_ids) == 2: logger.info("Success | TVDb URL get TVDb IDs and TMDb IDs")
else: logger.error(f"Failure | TVDb URL get TVDb IDs and TMDb IDs: {len(tvdb_ids)} Should be 4 and {len(tmdb_ids)} Should be 2")
try:
config.TVDb.get_items("tvdb_show", "https://www.thetvdb.com/series/arrow", "en", status_message=False)
logger.info("Success | TVDb URL get TVDb Series ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | TVDb URL get TVDb Series ID: {e}")
try:
config.TVDb.get_items("tvdb_show", 279121, "en", status_message=False)
logger.info("Success | TVDb ID get TVDb Series ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | TVDb ID get TVDb Series ID: {e}")
try:
config.TVDb.get_items("tvdb_movie", "https://www.thetvdb.com/movies/the-lord-of-the-rings-the-fellowship-of-the-ring", "en", status_message=False)
logger.info("Success | TVDb URL get TVDb Movie ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | TVDb URL get TVDb Movie ID: {e}")
try:
config.TVDb.get_items("tvdb_movie", 107, "en", status_message=False)
logger.info("Success | TVDb ID get TVDb Movie ID")
except Failed as e:
util.print_stacktrace()
logger.error(f"Failure | TVDb ID get TVDb Movie ID: {e}")
else:
util.separator("TVDb Not Configured")

@ -139,7 +139,7 @@ class TMDbAPI:
raise Failed(f"TMDb Error: No {convert_to.upper().replace('B_', 'b ')} found for TMDb ID {tmdb_id}")
return id_to_return
except TMDbException:
raise Failed(f"TMDb Error: {'Movie' if is_movie else 'Show'} TMDb ID: {tmdb_id} not found")
raise Failed(f"TMDb Error: TMDb {'Movie' if is_movie else 'Show'} ID: {tmdb_id} not found")
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
def convert_to(self, external_id, external_source, is_movie):
@ -211,7 +211,7 @@ class TMDbAPI:
movie_ids.append(credit.id)
elif credit.media_type == "tv":
try:
show_ids.append(self.config.Arms.convert_tmdb_to_tvdb(credit.id))
show_ids.append(self.config.Convert.tmdb_to_tvdb(credit.id))
except Failed as e:
logger.warning(e)
for credit in actor_credits.crew:
@ -223,7 +223,7 @@ class TMDbAPI:
movie_ids.append(credit.id)
elif credit.media_type == "tv":
try:
show_ids.append(self.config.Arms.convert_tmdb_to_tvdb(credit.id))
show_ids.append(self.config.Convert.tmdb_to_tvdb(credit.id))
except Failed as e:
logger.warning(e)
return movie_ids, show_ids
@ -240,7 +240,7 @@ class TMDbAPI:
else: raise Failed(f"TMDb Error: {method} method not supported")
for tmdb_item in tmdb_items:
try:
ids.append(tmdb_item.id if is_movie else self.config.Arms.convert_tmdb_to_tvdb(tmdb_item.id))
ids.append(tmdb_item.id if is_movie else self.config.Convert.tmdb_to_tvdb(tmdb_item.id))
count += 1
except Failed:
pass
@ -263,7 +263,7 @@ class TMDbAPI:
tmdb_items = self.Discover.discover_movies(attrs) if is_movie else self.Discover.discover_tv_shows(attrs)
for tmdb_item in tmdb_items:
try:
ids.append(tmdb_item.id if is_movie else self.config.Arms.convert_tmdb_to_tvdb(tmdb_item.id))
ids.append(tmdb_item.id if is_movie else self.config.Convert.tmdb_to_tvdb(tmdb_item.id))
count += 1
except Failed as e:
logger.error(e)
@ -339,7 +339,7 @@ class TMDbAPI:
if tmdb_item.media_type == "movie":
movie_ids.append(tmdb_item.id)
elif tmdb_item.media_type == "tv":
try: show_ids.append(self.config.Arms.convert_tmdb_to_tvdb(tmdb_item.id))
try: show_ids.append(self.config.Convert.tmdb_to_tvdb(tmdb_item.id))
except Failed: pass
elif method == "tmdb_movie":
tmdb_name = str(self.get_movie(tmdb_id).title)
@ -351,7 +351,7 @@ class TMDbAPI:
movie_ids.append(tmdb_item["id"])
elif method == "tmdb_show":
tmdb_name = str(self.get_show(tmdb_id).name)
show_ids.append(self.config.Arms.convert_tmdb_to_tvdb(tmdb_id))
show_ids.append(self.config.Convert.tmdb_to_tvdb(tmdb_id))
else:
tmdb_name = str(self.get_person(tmdb_id).name)
if method == "tmdb_actor": movie_ids, show_ids = self._credits(tmdb_id, actor=True)

@ -97,7 +97,7 @@ class TraktAPI:
lookup = lookup[0] if isinstance(lookup, list) else lookup
if lookup.get_key(to_source):
return lookup.get_key(to_source) if to_source == "imdb" else int(lookup.get_key(to_source))
raise Failed(f"No {to_source.upper().replace('B', 'b')} ID found for {from_source.upper().replace('B', 'b')} ID {external_id}")
raise Failed(f"Trakt Error: No {to_source.upper().replace('B', 'b')} ID found for {from_source.upper().replace('B', 'b')} ID: {external_id}")
def collection(self, data, is_movie):
return self._user_list("collection", data, is_movie)

@ -63,7 +63,7 @@ class TVDbObj:
results = response.xpath("//*[text()='IMDB']/@href")
if len(results) > 0:
try:
tmdb_id, _ = TVDb.config.Arms.imdb_to_ids(util.get_id_from_imdb_url(results[0]), language)
tmdb_id, _ = TVDb.config.Convert.imdb_to_ids(util.get_id_from_imdb_url(results[0]), language)
except Failed as e:
logger.error(e)
self.tmdb_id = tmdb_id

@ -12,7 +12,6 @@ except ModuleNotFoundError:
sys.exit(0)
parser = argparse.ArgumentParser()
parser.add_argument("--my-tests", dest="tests", help=argparse.SUPPRESS, action="store_true", default=False)
parser.add_argument("-db", "--debug", dest="debug", help=argparse.SUPPRESS, action="store_true", default=False)
parser.add_argument("-c", "--config", dest="config", help="Run with desired *.yml file", type=str)
parser.add_argument("-t", "--time", dest="time", help="Time to update each day use format HH:MM (Default: 03:00)", default="03:00", type=str)
@ -37,7 +36,6 @@ def check_bool(env_str, default):
else:
return default
my_tests = check_bool("PMM_TESTS", args.tests)
test = check_bool("PMM_TEST", args.test)
debug = check_bool("PMM_DEBUG", args.debug)
run = check_bool("PMM_RUN", args.run)
@ -97,10 +95,6 @@ util.centered("
util.centered(" Version: 1.8.0 ")
util.separator()
if my_tests:
tests.run_tests(default_dir)
sys.exit(0)
def start(config_path, is_test, daily, requested_collections, requested_libraries, resume_from):
if daily: start_type = "Daily "
elif is_test: start_type = "Test "
@ -389,7 +383,7 @@ def map_guids(config, library):
for i, item in enumerate(items, 1):
length = util.print_return(length, f"Processing: {i}/{len(items)} {item.title}")
try:
id_type, main_id = config.Arms.get_id(item, library, length)
id_type, main_id = config.Convert.get_id(item, library, length)
except BadRequest:
util.print_stacktrace()
util.print_end(length, f"{'Cache | ! |' if config.Cache else 'Mapping Error:'} | {item.guid} for {item.title} not found")

Loading…
Cancel
Save