mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
add mass_content_rating_update
This commit is contained in:
parent
d4749eda9b
commit
910738549a
6 changed files with 45 additions and 13 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.15.1-develop51
|
||||
1.15.1-develop52
|
||||
|
|
|
@ -106,6 +106,7 @@ class Cache:
|
|||
tmdb_rating INTEGER,
|
||||
letterboxd_rating REAL,
|
||||
commonsense TEXT,
|
||||
certification TEXT,
|
||||
expiration_date TEXT)"""
|
||||
)
|
||||
cursor.execute(
|
||||
|
@ -327,6 +328,7 @@ class Cache:
|
|||
mdb_dict["tmdbid"] = row["tmdbid"] if row["tmdbid"] else None
|
||||
mdb_dict["score"] = row["score"] if row["score"] 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"] = [
|
||||
{"source": "imdb", "value": row["imdb_rating"] if row["imdb_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 = ?, " \
|
||||
"tmdbid = ?, score = ?, imdb_rating = ?, metacritic_rating = ?, metacriticuser_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, (
|
||||
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.tomatoesaudience_rating, mdb.tmdb_rating, mdb.letterboxd_rating, mdb.commonsense,
|
||||
expiration_date.strftime("%Y-%m-%d"), key_id
|
||||
mdb.tomatoesaudience_rating, mdb.tmdb_rating, mdb.letterboxd_rating, mdb.content_rating,
|
||||
mdb.commonsense, expiration_date.strftime("%Y-%m-%d"), key_id
|
||||
))
|
||||
|
||||
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"}
|
||||
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 = {
|
||||
"tmdb": "Use TMDb Rating",
|
||||
"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)
|
||||
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)
|
||||
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"]:
|
||||
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"]:
|
||||
|
@ -763,10 +766,14 @@ class ConfigFile:
|
|||
error_check("mass_audience_rating_update", "OMDb")
|
||||
if self.OMDb is None and params["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:
|
||||
error_check("mass_audience_rating_update", "MdbList API")
|
||||
if not self.Mdblist.has_key and params["mass_critic_rating_update"] in util.mdb_types:
|
||||
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"]:
|
||||
error_check("mass_trakt_rating_update", "Trakt")
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class Library(ABC):
|
|||
self.mass_genre_update = params["mass_genre_update"]
|
||||
self.mass_audience_rating_update = params["mass_audience_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.radarr_add_all_existing = params["radarr_add_all_existing"]
|
||||
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.status = {}
|
||||
|
||||
self.items_library_operation = 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.tmdb_collections or self.radarr_add_all_existing or self.sonarr_add_all_existing
|
||||
self.library_operation = self.items_library_operation or self.delete_unmanaged_collections or self.delete_collections_with_less \
|
||||
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_content_rating_update or self.mass_trakt_rating_update \
|
||||
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 = 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.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:
|
||||
logger.info("")
|
||||
|
|
|
@ -47,6 +47,7 @@ class MDbObj:
|
|||
self.tmdb_rating = util.check_num(rating["value"])
|
||||
elif rating["source"] == "letterboxd":
|
||||
self.letterboxd_rating = util.check_num(rating["value"], is_int=False)
|
||||
self.content_rating = data["certification"]
|
||||
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 Audience Rating Update: {library.mass_audience_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 Collection Mode Update: {library.mass_collection_mode}")
|
||||
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)
|
||||
|
||||
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 tmdb_id and not imdb_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}"))
|
||||
|
||||
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 tmdb_id and not imdb_id:
|
||||
imdb_id = config.Convert.tmdb_to_imdb(tmdb_id)
|
||||
|
@ -560,7 +563,7 @@ def library_operations(config, library):
|
|||
def get_rating(attribute):
|
||||
if tmdb_item and attribute == "tmdb":
|
||||
return tmdb_item.vote_average
|
||||
elif omdb_item and attribute in ["omdb", "imdb"]:
|
||||
elif omdb_item and attribute == "omdb":
|
||||
return omdb_item.imdb_rating
|
||||
elif mdb_item and attribute == "mdb":
|
||||
return mdb_item.score / 10 if mdb_item.score else None
|
||||
|
@ -587,7 +590,7 @@ def library_operations(config, library):
|
|||
try:
|
||||
if tmdb_item and library.mass_genre_update == "tmdb":
|
||||
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
|
||||
elif tvdb_item and library.mass_genre_update == "tvdb":
|
||||
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}"))
|
||||
except Failed:
|
||||
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:
|
||||
try:
|
||||
adds = []
|
||||
|
|
Loading…
Reference in a new issue