Plex-Meta-Manager/modules/tests.py

375 lines
15 KiB
Python
Raw Normal View History

2021-01-20 21:37:59 +00:00
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("")
2021-02-24 06:42:58 +00:00
util.separator("Mapping Tests")
2021-02-16 04:54:47 +00:00
for library in config.libraries:
config.map_guids(library)
2021-01-20 21:37:59 +00:00
anidb_tests(config)
imdb_tests(config)
mal_tests(config)
tautulli_tests(config)
tmdb_tests(config)
trakt_tests(config)
tvdb_tests(config)
2021-02-24 06:42:58 +00:00
util.separator("Finished All Plex Meta Manager Tests")
2021-01-20 21:37:59 +00:00
except KeyboardInterrupt:
2021-02-24 06:42:58 +00:00
util.separator("Canceled Plex Meta Manager Tests")
2021-01-20 21:37:59 +00:00
def anidb_tests(config):
if config.AniDB:
2021-02-24 06:42:58 +00:00
util.separator("AniDB Tests")
2021-01-20 21:37:59 +00:00
try:
2021-04-15 20:45:35 +00:00
config.convert_anidb_to_tvdb(69)
2021-01-20 21:37:59 +00:00
logger.info("Success | Convert AniDB to TVDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert AniDB to TVDb: {e}")
2021-01-20 21:37:59 +00:00
try:
2021-04-15 20:45:35 +00:00
config.convert_anidb_to_imdb(112)
2021-01-20 21:37:59 +00:00
logger.info("Success | Convert AniDB to IMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert AniDB to IMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
2021-04-15 20:45:35 +00:00
config.convert_tvdb_to_anidb(81797)
2021-01-20 21:37:59 +00:00
logger.info("Success | Convert TVDb to AniDB")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TVDb to AniDB: {e}")
2021-01-20 21:37:59 +00:00
try:
2021-04-15 20:45:35 +00:00
config.convert_imdb_to_anidb("tt0245429")
2021-01-20 21:37:59 +00:00
logger.info("Success | Convert IMDb to AniDB")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert IMDb to AniDB: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get AniDB ID: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get AniDB Relation: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get AniDB Popular: {e}")
2021-01-20 21:37:59 +00:00
try:
config.AniDB.validate_anidb_list(["69", "112"], "en")
logger.info("Success | Validate AniDB List")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Validate AniDB List: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("AniDB Not Configured")
2021-01-20 21:37:59 +00:00
def imdb_tests(config):
if config.IMDb:
2021-02-24 06:42:58 +00:00
util.separator("IMDb Tests")
2021-01-20 21:37:59 +00:00
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")
2021-02-24 06:44:06 +00:00
else: logger.error(f"Failure | IMDb URL get TMDb IDs: {len(tmdb_ids)} Should be 1000")
2021-01-20 21:37:59 +00:00
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")
2021-02-24 06:44:06 +00:00
else: logger.error(f"Failure | IMDb URL get TMDb IDs: {len(tmdb_ids)} Should be 250")
2021-01-20 21:37:59 +00:00
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")
2021-02-24 06:44:06 +00:00
else: logger.error(f"Failure | IMDb ID get TMDb IDs: {len(tmdb_ids)} Should be 1")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("IMDb Not Configured")
2021-01-20 21:37:59 +00:00
def mal_tests(config):
if config.MyAnimeList:
2021-02-24 06:42:58 +00:00
util.separator("MyAnimeList Tests")
2021-01-20 21:37:59 +00:00
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)
2021-02-24 06:44:06 +00:00
logger.info(f"Success | Get Anime using {util.pretty_names[mal_list_test[0]]}")
2021-01-20 21:37:59 +00:00
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Anime using {util.pretty_names[mal_list_test[0]]}: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("MyAnimeList Not Configured")
2021-01-20 21:37:59 +00:00
def tautulli_tests(config):
if config.libraries[0].Tautulli:
2021-02-24 06:42:58 +00:00
util.separator("Tautulli Tests")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Section ID: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Popular: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Top: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("Tautulli Not Configured")
2021-01-20 21:37:59 +00:00
def tmdb_tests(config):
if config.TMDb:
2021-02-24 06:42:58 +00:00
util.separator("TMDb Tests")
2021-01-20 21:37:59 +00:00
try:
config.TMDb.convert_imdb_to_tmdb("tt0076759")
logger.info("Success | Convert IMDb to TMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert IMDb to TMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.TMDb.convert_tmdb_to_imdb(11)
logger.info("Success | Convert TMDb to IMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TMDb to IMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.TMDb.convert_imdb_to_tvdb("tt0458290")
logger.info("Success | Convert IMDb to TVDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert IMDb to TVDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.TMDb.convert_tvdb_to_imdb(83268)
logger.info("Success | Convert TVDb to IMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TVDb to IMDb: {e}")
2021-01-20 21:37:59 +00:00
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])
2021-02-24 06:44:06 +00:00
logger.info(f"Success | Get TMDb {tmdb_list_test[1]}")
2021-01-20 21:37:59 +00:00
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get TMDb {tmdb_list_test[1]}: {e}")
2021-01-20 21:37:59 +00:00
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)
2021-02-24 06:44:06 +00:00
logger.info(f"Success | Get {'Movies' if tmdb_list_test[2] else 'Shows'} using {util.pretty_names[tmdb_list_test[0]]}")
2021-01-20 21:37:59 +00:00
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get {'Movies' if tmdb_list_test[2] else 'Shows'} using {util.pretty_names[tmdb_list_test[0]]}: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("TMDb Not Configured")
2021-01-20 21:37:59 +00:00
def trakt_tests(config):
if config.Trakt:
2021-02-24 06:42:58 +00:00
util.separator("Trakt Tests")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_imdb_to_tmdb("tt0076759")
logger.info("Success | Convert IMDb to TMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert IMDb to TMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_tmdb_to_imdb(11)
logger.info("Success | Convert TMDb to IMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TMDb to IMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_imdb_to_tvdb("tt0458290")
logger.info("Success | Convert IMDb to TVDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert IMDb to TVDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_tvdb_to_imdb(83268)
logger.info("Success | Convert TVDb to IMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TVDb to IMDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_tmdb_to_tvdb(11)
logger.info("Success | Convert TMDb to TVDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TMDb to TVDb: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.convert_tvdb_to_tmdb(83268)
logger.info("Success | Convert TVDb to TMDb")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Convert TVDb to TMDb: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get List: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.validate_trakt_watchlist(["me"], True)
logger.info("Success | Get Watchlist Movies")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Watchlist Movies: {e}")
2021-01-20 21:37:59 +00:00
try:
config.Trakt.validate_trakt_watchlist(["me"], False)
logger.info("Success | Get Watchlist Shows")
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get Watchlist Shows: {e}")
2021-01-20 21:37:59 +00:00
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)
2021-02-24 06:44:06 +00:00
logger.info(f"Success | Get {'Movies' if trakt_list_test[2] else 'Shows'} using {util.pretty_names[trakt_list_test[0]]}")
2021-01-20 21:37:59 +00:00
except Failed as e:
util.print_stacktrace()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | Get {'Movies' if trakt_list_test[2] else 'Shows'} using {util.pretty_names[trakt_list_test[0]]}: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("Trakt Not Configured")
2021-01-20 21:37:59 +00:00
def tvdb_tests(config):
if config.TVDb:
2021-02-24 06:42:58 +00:00
util.separator("TVDb Tests")
2021-01-20 21:37:59 +00:00
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")
2021-02-24 06:44:06 +00:00
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")
2021-01-20 21:37:59 +00:00
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")
2021-02-24 06:44:06 +00:00
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")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | TVDb URL get TVDb Series ID: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | TVDb ID get TVDb Series ID: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | TVDb URL get TVDb Movie ID: {e}")
2021-01-20 21:37:59 +00:00
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()
2021-02-24 06:44:06 +00:00
logger.error(f"Failure | TVDb ID get TVDb Movie ID: {e}")
2021-01-20 21:37:59 +00:00
else:
2021-02-24 06:42:58 +00:00
util.separator("TVDb Not Configured")