[7] fix mdb_average

This commit is contained in:
meisnate12 2022-11-10 22:52:42 -05:00
parent a1a8455ffc
commit b3059eacfc
5 changed files with 23 additions and 22 deletions

View file

@ -1 +1 @@
1.18.0-develop6
1.18.0-develop7

View file

@ -24,6 +24,7 @@ class Cache:
cursor.execute("DROP TABLE IF EXISTS imdb_map")
cursor.execute("DROP TABLE IF EXISTS mdb_data")
cursor.execute("DROP TABLE IF EXISTS mdb_data2")
cursor.execute("DROP TABLE IF EXISTS mdb_data3")
cursor.execute("DROP TABLE IF EXISTS omdb_data")
cursor.execute("DROP TABLE IF EXISTS omdb_data2")
cursor.execute("DROP TABLE IF EXISTS tvdb_data")
@ -94,7 +95,7 @@ class Cache:
expiration_date TEXT)"""
)
cursor.execute(
"""CREATE TABLE IF NOT EXISTS mdb_data3 (
"""CREATE TABLE IF NOT EXISTS mdb_data4 (
key INTEGER PRIMARY KEY,
key_id TEXT UNIQUE,
title TEXT,
@ -105,6 +106,7 @@ class Cache:
traktid INTEGER,
tmdbid INTEGER,
score INTEGER,
average INTEGER,
imdb_rating REAL,
metacritic_rating INTEGER,
metacriticuser_rating REAL,
@ -462,7 +464,7 @@ class Cache:
with sqlite3.connect(self.cache_path) as connection:
connection.row_factory = sqlite3.Row
with closing(connection.cursor()) as cursor:
cursor.execute("SELECT * FROM mdb_data3 WHERE key_id = ?", (key_id,))
cursor.execute("SELECT * FROM mdb_data4 WHERE key_id = ?", (key_id,))
row = cursor.fetchone()
if row:
mdb_dict["title"] = row["title"] if row["title"] else None
@ -473,6 +475,7 @@ class Cache:
mdb_dict["traktid"] = row["traktid"] if row["traktid"] 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_average"] = row["average"] if row["average"] 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"] = [
@ -498,12 +501,12 @@ class Cache:
with closing(connection.cursor()) as cursor:
cursor.execute("INSERT OR IGNORE INTO mdb_data3(key_id) VALUES(?)", (key_id,))
update_sql = "UPDATE mdb_data3 SET title = ?, year = ?, released = ?, type = ?, imdbid = ?, traktid = ?, " \
"tmdbid = ?, score = ?, imdb_rating = ?, metacritic_rating = ?, metacriticuser_rating = ?, " \
"tmdbid = ?, score = ?, average = ?, imdb_rating = ?, metacritic_rating = ?, metacriticuser_rating = ?, " \
"trakt_rating = ?, tomatoes_rating = ?, tomatoesaudience_rating = ?, tmdb_rating = ?, " \
"letterboxd_rating = ?, myanimelist_rating = ?, certification = ?, commonsense = ?, expiration_date = ? WHERE key_id = ?"
cursor.execute(update_sql, (
mdb.title, mdb.year, mdb.released.strftime("%Y-%m-%d") if mdb.released else None, mdb.type,
mdb.imdbid, mdb.traktid, mdb.tmdbid, mdb.score, mdb.imdb_rating, mdb.metacritic_rating,
mdb.imdbid, mdb.traktid, mdb.tmdbid, mdb.score, mdb.average, 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.myanimelist_rating, mdb.content_rating, mdb.commonsense,
expiration_date.strftime("%Y-%m-%d"), key_id

View file

@ -7,7 +7,10 @@ from urllib.parse import urlparse
logger = util.logger
builders = ["mdblist_list"]
sort_names = ["rank", "score", "score_average", "released", "imdbrating", "imdbvotes", "imdbpopular", "tmdbpopular", "rogerebert", "rtomatoes", "metacritic", "myanimelist", "budget", "revenue", "added"]
sort_names = [
"rank", "score", "score_average", "released", "imdbrating", "imdbvotes", "imdbpopular", "tmdbpopular",
"rogerebert", "rtomatoes", "metacritic", "myanimelist", "budget", "revenue", "added"
]
list_sorts = [f"{s}.asc" for s in sort_names] + [f"{s}.desc" for s in sort_names]
base_url = "https://mdblist.com/lists"
api_url = "https://mdblist.com/api/"
@ -28,6 +31,7 @@ class MDbObj:
self.traktid = util.check_num(data["traktid"])
self.tmdbid = util.check_num(data["tmdbid"])
self.score = util.check_num(data["score"])
self.average = util.check_num(data["score_average"])
self.imdb_rating = None
self.metacritic_rating = None
self.metacriticuser_rating = None
@ -37,7 +41,6 @@ class MDbObj:
self.tmdb_rating = None
self.letterboxd_rating = None
self.myanimelist_rating = None
self.score_average_rating = None
for rating in data["ratings"]:
if rating["source"] == "imdb":
self.imdb_rating = util.check_num(rating["value"], is_int=False)
@ -57,8 +60,6 @@ class MDbObj:
self.letterboxd_rating = util.check_num(rating["value"], is_int=False)
elif rating["source"] == "myanimelist":
self.myanimelist_rating = util.check_num(rating["value"], is_int=False)
elif rating["source"] == "average":
self.score_average_rating = util.check_num(rating["value"], is_int=False)
self.content_rating = data["certification"]
self.commonsense = data["commonsense"]

View file

@ -257,7 +257,7 @@ class Operations:
elif mdb_item and attribute == "mdb":
found_rating = mdb_item.score / 10 if mdb_item.score else None
elif mdb_item and attribute == "mdb_average":
found_rating = mdb_item.average_score_rating / 10 if mdb_item.average_score_rating else None
found_rating = mdb_item.average / 10 if mdb_item.average else None
elif mdb_item and attribute == "mdb_imdb":
found_rating = mdb_item.imdb_rating if mdb_item.imdb_rating else None
elif mdb_item and attribute == "mdb_metacritic":
@ -460,10 +460,10 @@ class Operations:
if self.library.mass_poster_update:
if self.library.mass_poster_update == "lock":
self.library.query(item.lockPoster)
logger.infd(f"Poster | Locked")
logger.info(f"Poster | Locked")
elif self.library.mass_poster_update == "unlock":
self.library.query(item.unlockPoster)
logger.infd(f"Poster | Unlocked")
logger.info(f"Poster | Unlocked")
else:
poster_location = "the Assets Directory" if new_poster else ""
poster_url = False if new_poster else True
@ -479,16 +479,16 @@ class Operations:
poster_location = "Plex"
if new_poster:
self.library.upload_poster(item, new_poster, url=poster_url)
logger.infd(f"Poster | Reset from {poster_location}")
logger.info(f"Poster | Reset from {poster_location}")
else:
logger.infd(f"Poster | No Reset Image Found")
logger.info(f"Poster | No Reset Image Found")
if self.library.mass_background_update:
if self.library.mass_background_update == "lock":
self.library.query(item.lockArt)
logger.infd(f"Background | Locked")
logger.info(f"Background | Locked")
elif self.library.mass_background_update == "unlock":
self.library.query(item.unlockArt)
logger.infd(f"Background | Unlocked")
logger.info(f"Background | Unlocked")
else:
background_location = "the Assets Directory" if new_background else ""
background_url = False if new_background else True
@ -504,9 +504,9 @@ class Operations:
background_location = "Plex"
if new_background:
self.library.upload_background(item, new_background, url=background_url)
logger.infd(f"Background | Reset from {background_location}")
logger.info(f"Background | Reset from {background_location}")
else:
logger.infd(f"Background | No Reset Image Found")
logger.info(f"Background | No Reset Image Found")
episode_ops = [self.library.mass_episode_audience_rating_update, self.library.mass_episode_critic_rating_update, self.library.mass_episode_user_rating_update]

View file

@ -74,11 +74,9 @@ pretty_months = {
7: "July", 8: "August", 9: "September", 10: "October", 11: "November", 12: "December"
}
seasons = ["current", "winter", "spring", "summer", "fall"]
pretty_ids = {"anidbid": "AniDB", "imdbid": "IMDb", "mal_id": "MyAnimeList", "themoviedb_id": "TMDb", "thetvdb_id": "TVDb", "tvdbid": "TVDb"}
advance_tags_to_edit = {
"Movie": ["metadata_language", "use_original_title"],
"Show": ["episode_sorting", "keep_episodes", "delete_episodes", "season_display", "episode_ordering",
"metadata_language", "use_original_title"],
"Show": ["episode_sorting", "keep_episodes", "delete_episodes", "season_display", "episode_ordering", "metadata_language", "use_original_title"],
"Artist": ["album_sorting"]
}
tags_to_edit = {
@ -87,7 +85,6 @@ tags_to_edit = {
"Show": ["genre", "label", "collection"],
"Artist": ["genre", "label", "style", "mood", "country", "collection", "similar_artist"]
}
mdb_types = ["mdb", "mdv_average", "mdb_imdb", "mdb_metacritic", "mdb_metacriticuser", "mdb_trakt", "mdb_tomatoes", "mdb_tomatoesaudience", "mdb_tmdb", "mdb_letterboxd"]
collection_mode_options = {
"default": "default", "hide": "hide",
"hide_items": "hideItems", "hideitems": "hideItems",