add mass_content_rating_update

pull/707/head
meisnate12 3 years ago
parent d4749eda9b
commit 910738549a

@ -1 +1 @@
1.15.1-develop51 1.15.1-develop52

@ -106,6 +106,7 @@ class Cache:
tmdb_rating INTEGER, tmdb_rating INTEGER,
letterboxd_rating REAL, letterboxd_rating REAL,
commonsense TEXT, commonsense TEXT,
certification TEXT,
expiration_date TEXT)""" expiration_date TEXT)"""
) )
cursor.execute( cursor.execute(
@ -327,6 +328,7 @@ class Cache:
mdb_dict["tmdbid"] = row["tmdbid"] if row["tmdbid"] else None mdb_dict["tmdbid"] = row["tmdbid"] if row["tmdbid"] else None
mdb_dict["score"] = row["score"] if row["score"] else None mdb_dict["score"] = row["score"] if row["score"] else None
mdb_dict["commonsense"] = row["commonsense"] if row["commonsense"] else None mdb_dict["commonsense"] = row["commonsense"] if row["commonsense"] else None
mdb_dict["certification"] = row["certification"] if row["certification"] else None
mdb_dict["ratings"] = [ mdb_dict["ratings"] = [
{"source": "imdb", "value": row["imdb_rating"] if row["imdb_rating"] else None}, {"source": "imdb", "value": row["imdb_rating"] if row["imdb_rating"] else None},
{"source": "metacritic", "value": row["metacritic_rating"] if row["metacritic_rating"] else None}, {"source": "metacritic", "value": row["metacritic_rating"] if row["metacritic_rating"] else None},
@ -351,12 +353,12 @@ class Cache:
update_sql = "UPDATE mdb_data SET title = ?, year = ?, type = ?, imdbid = ?, traktid = ?, " \ update_sql = "UPDATE mdb_data SET title = ?, year = ?, type = ?, imdbid = ?, traktid = ?, " \
"tmdbid = ?, score = ?, imdb_rating = ?, metacritic_rating = ?, metacriticuser_rating = ?, " \ "tmdbid = ?, score = ?, imdb_rating = ?, metacritic_rating = ?, metacriticuser_rating = ?, " \
"trakt_rating = ?, tomatoes_rating = ?, tomatoesaudience_rating = ?, tmdb_rating = ?, " \ "trakt_rating = ?, tomatoes_rating = ?, tomatoesaudience_rating = ?, tmdb_rating = ?, " \
"letterboxd_rating = ?, commonsense = ?, expiration_date = ? WHERE key_id = ?" "letterboxd_rating = ?, certification = ?, commonsense = ?, expiration_date = ? WHERE key_id = ?"
cursor.execute(update_sql, ( cursor.execute(update_sql, (
mdb.title, mdb.year, mdb.type, mdb.imdbid, mdb.traktid, mdb.tmdbid, mdb.score, mdb.imdb_rating, mdb.title, mdb.year, mdb.type, mdb.imdbid, mdb.traktid, mdb.tmdbid, mdb.score, mdb.imdb_rating,
mdb.metacritic_rating, mdb.metacriticuser_rating, mdb.trakt_rating, mdb.tomatoes_rating, mdb.metacritic_rating, mdb.metacriticuser_rating, mdb.trakt_rating, mdb.tomatoes_rating,
mdb.tomatoesaudience_rating, mdb.tmdb_rating, mdb.letterboxd_rating, mdb.commonsense, mdb.tomatoesaudience_rating, mdb.tmdb_rating, mdb.letterboxd_rating, mdb.content_rating,
expiration_date.strftime("%Y-%m-%d"), key_id mdb.commonsense, expiration_date.strftime("%Y-%m-%d"), key_id
)) ))
def query_anime_map(self, anime_id, id_type): def query_anime_map(self, anime_id, id_type):

@ -32,6 +32,7 @@ logger = logging.getLogger("Plex Meta Manager")
sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"} sync_modes = {"append": "Only Add Items to the Collection or Playlist", "sync": "Add & Remove Items from the Collection or Playlist"}
mass_update_options = {"tmdb": "Use TMDb Metadata", "omdb": "Use IMDb Metadata through OMDb"} mass_update_options = {"tmdb": "Use TMDb Metadata", "omdb": "Use IMDb Metadata through OMDb"}
mass_content_options = {"omdb": "Use IMDb Metadata through OMDb", "mdb": "Use MdbList Metadata", "mdb_commonsense": "Use Commonsense Rating through MDbList"}
mass_rating_options = { mass_rating_options = {
"tmdb": "Use TMDb Rating", "tmdb": "Use TMDb Rating",
"omdb": "Use IMDb Rating through OMDb", "omdb": "Use IMDb Rating through OMDb",
@ -655,6 +656,8 @@ class ConfigFile:
params["mass_audience_rating_update"] = check_for_attribute(lib["operations"], "mass_audience_rating_update", test_list=mass_rating_options, default_is_none=True, save=False) params["mass_audience_rating_update"] = check_for_attribute(lib["operations"], "mass_audience_rating_update", test_list=mass_rating_options, default_is_none=True, save=False)
if "mass_critic_rating_update" in lib["operations"]: if "mass_critic_rating_update" in lib["operations"]:
params["mass_critic_rating_update"] = check_for_attribute(lib["operations"], "mass_critic_rating_update", test_list=mass_rating_options, default_is_none=True, save=False) params["mass_critic_rating_update"] = check_for_attribute(lib["operations"], "mass_critic_rating_update", test_list=mass_rating_options, default_is_none=True, save=False)
if "mass_content_rating_update" in lib["operations"]:
params["mass_content_rating_update"] = check_for_attribute(lib["operations"], "mass_content_rating_update", test_list=mass_content_options, default_is_none=True, save=False)
if "mass_trakt_rating_update" in lib["operations"]: if "mass_trakt_rating_update" in lib["operations"]:
params["mass_trakt_rating_update"] = check_for_attribute(lib["operations"], "mass_trakt_rating_update", var_type="bool", default=False, save=False) params["mass_trakt_rating_update"] = check_for_attribute(lib["operations"], "mass_trakt_rating_update", var_type="bool", default=False, save=False)
if "split_duplicates" in lib["operations"]: if "split_duplicates" in lib["operations"]:
@ -763,10 +766,14 @@ class ConfigFile:
error_check("mass_audience_rating_update", "OMDb") error_check("mass_audience_rating_update", "OMDb")
if self.OMDb is None and params["mass_critic_rating_update"] == "omdb": if self.OMDb is None and params["mass_critic_rating_update"] == "omdb":
error_check("mass_critic_rating_update", "OMDb") error_check("mass_critic_rating_update", "OMDb")
if self.OMDb is None and params["mass_content_rating_update"] == "omdb":
error_check("mass_content_rating_update", "OMDb")
if not self.Mdblist.has_key and params["mass_audience_rating_update"] in util.mdb_types: if not self.Mdblist.has_key and params["mass_audience_rating_update"] in util.mdb_types:
error_check("mass_audience_rating_update", "MdbList API") error_check("mass_audience_rating_update", "MdbList API")
if not self.Mdblist.has_key and params["mass_critic_rating_update"] in util.mdb_types: if not self.Mdblist.has_key and params["mass_critic_rating_update"] in util.mdb_types:
error_check("mass_critic_rating_update", "MdbList API") error_check("mass_critic_rating_update", "MdbList API")
if not self.Mdblist.has_key and params["mass_content_rating_update"] in ["mdb", "mdb_commonsense"]:
error_check("mass_content_rating_update", "MdbList API")
if self.Trakt is None and params["mass_trakt_rating_update"]: if self.Trakt is None and params["mass_trakt_rating_update"]:
error_check("mass_trakt_rating_update", "Trakt") error_check("mass_trakt_rating_update", "Trakt")

@ -70,6 +70,7 @@ class Library(ABC):
self.mass_genre_update = params["mass_genre_update"] self.mass_genre_update = params["mass_genre_update"]
self.mass_audience_rating_update = params["mass_audience_rating_update"] self.mass_audience_rating_update = params["mass_audience_rating_update"]
self.mass_critic_rating_update = params["mass_critic_rating_update"] self.mass_critic_rating_update = params["mass_critic_rating_update"]
self.mass_content_rating_update = params["mass_content_rating_update"]
self.mass_trakt_rating_update = params["mass_trakt_rating_update"] self.mass_trakt_rating_update = params["mass_trakt_rating_update"]
self.radarr_add_all_existing = params["radarr_add_all_existing"] self.radarr_add_all_existing = params["radarr_add_all_existing"]
self.radarr_remove_by_tag = params["radarr_remove_by_tag"] self.radarr_remove_by_tag = params["radarr_remove_by_tag"]
@ -90,12 +91,12 @@ class Library(ABC):
self.stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0} self.stats = {"created": 0, "modified": 0, "deleted": 0, "added": 0, "unchanged": 0, "removed": 0, "radarr": 0, "sonarr": 0}
self.status = {} self.status = {}
self.items_library_operation = self.assets_for_all or self.mass_genre_update or self.mass_audience_rating_update \ self.items_library_operation = True if self.assets_for_all or self.mass_genre_update or self.mass_audience_rating_update \
or self.mass_critic_rating_update or self.mass_trakt_rating_update or self.genre_mapper \ or self.mass_critic_rating_update or self.mass_content_rating_update or self.mass_trakt_rating_update \
or self.tmdb_collections or self.radarr_add_all_existing or self.sonarr_add_all_existing or self.genre_mapper or self.tmdb_collections or self.radarr_add_all_existing or self.sonarr_add_all_existing else False
self.library_operation = self.items_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \ self.library_operation = True if self.items_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \
or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \ or self.radarr_remove_by_tag or self.sonarr_remove_by_tag or self.mass_collection_mode \
or self.genre_collections or self.show_unmanaged or self.metadata_backup or self.update_blank_track_titles or self.genre_collections or self.show_unmanaged or self.metadata_backup or self.update_blank_track_titles else False
if self.asset_directory: if self.asset_directory:
logger.info("") logger.info("")

@ -47,6 +47,7 @@ class MDbObj:
self.tmdb_rating = util.check_num(rating["value"]) self.tmdb_rating = util.check_num(rating["value"])
elif rating["source"] == "letterboxd": elif rating["source"] == "letterboxd":
self.letterboxd_rating = util.check_num(rating["value"], is_int=False) self.letterboxd_rating = util.check_num(rating["value"], is_int=False)
self.content_rating = data["certification"]
self.commonsense = data["commonsense"] self.commonsense = data["commonsense"]

@ -436,6 +436,7 @@ def library_operations(config, library):
logger.debug(f"Mass Genre Update: {library.mass_genre_update}") logger.debug(f"Mass Genre Update: {library.mass_genre_update}")
logger.debug(f"Mass Audience Rating Update: {library.mass_audience_rating_update}") logger.debug(f"Mass Audience Rating Update: {library.mass_audience_rating_update}")
logger.debug(f"Mass Critic Rating Update: {library.mass_critic_rating_update}") logger.debug(f"Mass Critic Rating Update: {library.mass_critic_rating_update}")
logger.debug(f"Mass Content Rating Update: {library.mass_content_rating_update}")
logger.debug(f"Mass Trakt Rating Update: {library.mass_trakt_rating_update}") logger.debug(f"Mass Trakt Rating Update: {library.mass_trakt_rating_update}")
logger.debug(f"Mass Collection Mode Update: {library.mass_collection_mode}") logger.debug(f"Mass Collection Mode Update: {library.mass_collection_mode}")
logger.debug(f"Split Duplicates: {library.split_duplicates}") logger.debug(f"Split Duplicates: {library.split_duplicates}")
@ -509,7 +510,8 @@ def library_operations(config, library):
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=library.is_movie) tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=library.is_movie)
omdb_item = None omdb_item = None
if library.mass_genre_update in ["omdb", "imdb"] or library.mass_audience_rating_update in ["omdb", "imdb"] or library.mass_critic_rating_update in ["omdb", "imdb"]: if library.mass_genre_update == "omdb" or library.mass_audience_rating_update == "omdb" \
or library.mass_critic_rating_update == "omdb" or library.mass_content_rating_update == "omdb":
if config.OMDb.limit is False: if config.OMDb.limit is False:
if tmdb_id and not imdb_id: if tmdb_id and not imdb_id:
imdb_id = config.Convert.tmdb_to_imdb(tmdb_id) imdb_id = config.Convert.tmdb_to_imdb(tmdb_id)
@ -537,7 +539,8 @@ def library_operations(config, library):
logger.info(util.adjust_space(f"{item.title[:25]:<25} | No TVDb ID for Guid: {item.guid}")) logger.info(util.adjust_space(f"{item.title[:25]:<25} | No TVDb ID for Guid: {item.guid}"))
mdb_item = None mdb_item = None
if library.mass_audience_rating_update in util.mdb_types or library.mass_critic_rating_update in util.mdb_types: if library.mass_audience_rating_update in util.mdb_types or library.mass_critic_rating_update in util.mdb_types \
or library.mass_content_rating_update in ["mdb", "mdb_commonsense"]:
if config.Mdblist.limit is False: if config.Mdblist.limit is False:
if tmdb_id and not imdb_id: if tmdb_id and not imdb_id:
imdb_id = config.Convert.tmdb_to_imdb(tmdb_id) imdb_id = config.Convert.tmdb_to_imdb(tmdb_id)
@ -560,7 +563,7 @@ def library_operations(config, library):
def get_rating(attribute): def get_rating(attribute):
if tmdb_item and attribute == "tmdb": if tmdb_item and attribute == "tmdb":
return tmdb_item.vote_average return tmdb_item.vote_average
elif omdb_item and attribute in ["omdb", "imdb"]: elif omdb_item and attribute == "omdb":
return omdb_item.imdb_rating return omdb_item.imdb_rating
elif mdb_item and attribute == "mdb": elif mdb_item and attribute == "mdb":
return mdb_item.score / 10 if mdb_item.score else None return mdb_item.score / 10 if mdb_item.score else None
@ -587,7 +590,7 @@ def library_operations(config, library):
try: try:
if tmdb_item and library.mass_genre_update == "tmdb": if tmdb_item and library.mass_genre_update == "tmdb":
new_genres = [genre.name for genre in tmdb_item.genres] new_genres = [genre.name for genre in tmdb_item.genres]
elif omdb_item and library.mass_genre_update in ["omdb", "imdb"]: elif omdb_item and library.mass_genre_update == "omdb":
new_genres = omdb_item.genres new_genres = omdb_item.genres
elif tvdb_item and library.mass_genre_update == "tvdb": elif tvdb_item and library.mass_genre_update == "tvdb":
new_genres = tvdb_item.genres new_genres = tvdb_item.genres
@ -616,6 +619,24 @@ def library_operations(config, library):
logger.info(util.adjust_space(f"{item.title[:25]:<25} | Critic Rating | {new_rating}")) logger.info(util.adjust_space(f"{item.title[:25]:<25} | Critic Rating | {new_rating}"))
except Failed: except Failed:
pass pass
if library.mass_content_rating_update:
try:
if omdb_item and library.mass_content_rating_update == "omdb":
new_rating = omdb_item.content_rating
elif mdb_item and library.mass_content_rating_update == "mdb":
new_rating = mdb_item.certification if mdb_item.certification else None
elif mdb_item and library.mass_content_rating_update == "mdb_commonsense":
new_rating = mdb_item.commonsense if mdb_item.commonsense else None
else:
raise Failed
if new_rating is None:
logger.info(util.adjust_space(f"{item.title[:25]:<25} | No Content Rating Found"))
elif str(item.rating) != str(new_rating):
library.edit_query(item, {"contentRating.value": new_rating, "contentRating.locked": 1})
logger.info(util.adjust_space(f"{item.title[:25]:<25} | Content Rating | {new_rating}"))
except Failed:
pass
if library.genre_mapper: if library.genre_mapper:
try: try:
adds = [] adds = []

Loading…
Cancel
Save