[53] add anidb_all option to mass genre

pull/1300/head
meisnate12 2 years ago
parent 77415bf7bc
commit 944b161715

@ -1 +1 @@
1.18.3-develop52 1.18.3-develop53

@ -86,12 +86,13 @@ Updates every item's genres in the library to the chosen site's genres.
**Values:** **Values:**
| Value | Description | | Value | Description |
|:---------|:-----------------------------------| |:------------|:-----------------------------------|
| `tmdb` | Use TMDb for Genres | | `tmdb` | Use TMDb for Genres |
| `tvdb` | Use TVDb for Genres | | `tvdb` | Use TVDb for Genres |
| `imdb` | Use IMDb for Genres | | `imdb` | Use IMDb for Genres |
| `omdb` | Use IMDb through OMDb for Genres | | `omdb` | Use IMDb through OMDb for Genres |
| `anidb` | Use AniDB Tags for Genres | | `anidb` | Use AniDB Main Tags for Genres |
| `anidb_all` | Use All AniDB Tags for Genres |
| `mal` | Use MyAnimeList for Genres | | `mal` | Use MyAnimeList for Genres |
| `lock` | Lock Genre Field | | `lock` | Lock Genre Field |
| `unlock` | Unlock Genre Field | | `unlock` | Unlock Genre Field |

@ -69,6 +69,7 @@ class AniDBObj:
self.score = _parse("score", "//anime/ratings/review/text()", is_float=True) self.score = _parse("score", "//anime/ratings/review/text()", is_float=True)
self.released = _parse("released", "//anime/startdate/text()", is_date=True) self.released = _parse("released", "//anime/startdate/text()", is_date=True)
self.tags = _parse("tags", "//anime/tags/tag[@infobox='true']/name/text()", is_list=True) self.tags = _parse("tags", "//anime/tags/tag[@infobox='true']/name/text()", is_list=True)
self.all_tags = _parse("all_tags", "//anime/tags/tag/name/text()", is_list=True)
self.mal_id = _parse("mal_id", "//anime/resources/resource[@type='2']/externalentity/identifier/text()", is_int=True) self.mal_id = _parse("mal_id", "//anime/resources/resource[@type='2']/externalentity/identifier/text()", is_int=True)
self.imdb_id = _parse("imdb_id", "//anime/resources/resource[@type='43']/externalentity/identifier/text()") self.imdb_id = _parse("imdb_id", "//anime/resources/resource[@type='43']/externalentity/identifier/text()")
if isinstance(data, dict): if isinstance(data, dict):

@ -31,6 +31,7 @@ class Cache:
cursor.execute("DROP TABLE IF EXISTS tvdb_data2") cursor.execute("DROP TABLE IF EXISTS tvdb_data2")
cursor.execute("DROP TABLE IF EXISTS overlay_ratings") cursor.execute("DROP TABLE IF EXISTS overlay_ratings")
cursor.execute("DROP TABLE IF EXISTS anidb_data") cursor.execute("DROP TABLE IF EXISTS anidb_data")
cursor.execute("DROP TABLE IF EXISTS anidb_data2")
cursor.execute("DROP TABLE IF EXISTS mal_data") cursor.execute("DROP TABLE IF EXISTS mal_data")
cursor.execute( cursor.execute(
"""CREATE TABLE IF NOT EXISTS guids_map ( """CREATE TABLE IF NOT EXISTS guids_map (
@ -123,7 +124,7 @@ class Cache:
expiration_date TEXT)""" expiration_date TEXT)"""
) )
cursor.execute( cursor.execute(
"""CREATE TABLE IF NOT EXISTS anidb_data2 ( """CREATE TABLE IF NOT EXISTS anidb_data3 (
key INTEGER PRIMARY KEY, key INTEGER PRIMARY KEY,
anidb_id INTEGER UNIQUE, anidb_id INTEGER UNIQUE,
main_title TEXT, main_title TEXT,
@ -134,6 +135,7 @@ class Cache:
score REAL, score REAL,
released TEXT, released TEXT,
tags TEXT, tags TEXT,
all_tags TEXT,
mal_id INTEGER, mal_id INTEGER,
imdb_id TEXT, imdb_id TEXT,
tmdb_id INTEGER, tmdb_id INTEGER,
@ -533,7 +535,7 @@ class Cache:
with sqlite3.connect(self.cache_path) as connection: with sqlite3.connect(self.cache_path) as connection:
connection.row_factory = sqlite3.Row connection.row_factory = sqlite3.Row
with closing(connection.cursor()) as cursor: with closing(connection.cursor()) as cursor:
cursor.execute("SELECT * FROM anidb_data2 WHERE anidb_id = ?", (anidb_id,)) cursor.execute("SELECT * FROM anidb_data3 WHERE anidb_id = ?", (anidb_id,))
row = cursor.fetchone() row = cursor.fetchone()
if row: if row:
anidb_dict["main_title"] = row["main_title"] anidb_dict["main_title"] = row["main_title"]
@ -544,6 +546,7 @@ class Cache:
anidb_dict["score"] = row["score"] if row["score"] else None anidb_dict["score"] = row["score"] if row["score"] else None
anidb_dict["released"] = row["released"] if row["released"] else None anidb_dict["released"] = row["released"] if row["released"] else None
anidb_dict["tags"] = row["tags"] if row["tags"] else None anidb_dict["tags"] = row["tags"] if row["tags"] else None
anidb_dict["all_tags"] = row["all_tags"] if row["all_tags"] else None
anidb_dict["mal_id"] = row["mal_id"] if row["mal_id"] else None anidb_dict["mal_id"] = row["mal_id"] if row["mal_id"] else None
anidb_dict["imdb_id"] = row["imdb_id"] if row["imdb_id"] else None anidb_dict["imdb_id"] = row["imdb_id"] if row["imdb_id"] else None
anidb_dict["tmdb_id"] = row["tmdb_id"] if row["tmdb_id"] else None anidb_dict["tmdb_id"] = row["tmdb_id"] if row["tmdb_id"] else None
@ -558,12 +561,12 @@ class Cache:
with sqlite3.connect(self.cache_path) as connection: with sqlite3.connect(self.cache_path) as connection:
connection.row_factory = sqlite3.Row connection.row_factory = sqlite3.Row
with closing(connection.cursor()) as cursor: with closing(connection.cursor()) as cursor:
cursor.execute("INSERT OR IGNORE INTO anidb_data2(anidb_id) VALUES(?)", (anidb_id,)) cursor.execute("INSERT OR IGNORE INTO anidb_data3(anidb_id) VALUES(?)", (anidb_id,))
update_sql = "UPDATE anidb_data2 SET main_title = ?, titles = ?, studio = ?, rating = ?, average = ?, score = ?, " \ update_sql = "UPDATE anidb_data3 SET main_title = ?, titles = ?, studio = ?, rating = ?, average = ?, score = ?, " \
"released = ?, tags = ?, mal_id = ?, imdb_id = ?, tmdb_id = ?, tmdb_type = ?, expiration_date = ? WHERE anidb_id = ?" "released = ?, tags = ?, all_tags = ?, mal_id = ?, imdb_id = ?, tmdb_id = ?, tmdb_type = ?, expiration_date = ? WHERE anidb_id = ?"
cursor.execute(update_sql, ( cursor.execute(update_sql, (
anidb.main_title, str(anidb.titles), anidb.studio, anidb.rating, anidb.average, anidb.score, anidb.main_title, str(anidb.titles), anidb.studio, anidb.rating, anidb.average, anidb.score,
anidb.released.strftime("%Y-%m-%d") if anidb.released else None, "|".join(anidb.tags), anidb.released.strftime("%Y-%m-%d") if anidb.released else None, "|".join(anidb.tags), "|".join(anidb.all_tags),
anidb.mal_id, anidb.imdb_id, anidb.tmdb_id, anidb.tmdb_type, anidb.mal_id, anidb.imdb_id, anidb.tmdb_id, anidb.tmdb_type,
expiration_date.strftime("%Y-%m-%d"), anidb_id expiration_date.strftime("%Y-%m-%d"), anidb_id
)) ))

@ -37,7 +37,7 @@ imdb_label_options = {"with_none": "Add IMDb Parental Labels including None", "w
mass_genre_options = { mass_genre_options = {
"lock": "Unlock Genre", "unlock": "Unlock Genre", "remove": "Remove and Lock Genre", "reset": "Remove and Unlock Genre", "lock": "Unlock Genre", "unlock": "Unlock Genre", "remove": "Remove and Lock Genre", "reset": "Remove and Unlock Genre",
"tmdb": "Use TMDb Genres", "imdb": "Use IMDb Genres", "omdb": "Use IMDb Genres through OMDb", "tvdb": "Use TVDb Genres", "tmdb": "Use TMDb Genres", "imdb": "Use IMDb Genres", "omdb": "Use IMDb Genres through OMDb", "tvdb": "Use TVDb Genres",
"anidb": "Use AniDB Tags", "mal": "Use MyAnimeList Genres" "anidb": "Use AniDB Main Tags", "anidb_all": "Use All AniDB Tags", "mal": "Use MyAnimeList Genres"
} }
mass_content_options = { mass_content_options = {
"lock": "Unlock Rating", "unlock": "Unlock Rating", "remove": "Remove and Lock Rating", "reset": "Remove and Unlock Rating", "lock": "Unlock Rating", "unlock": "Unlock Rating", "remove": "Remove and Lock Rating", "reset": "Remove and Unlock Rating",

@ -323,6 +323,8 @@ class Operations:
new_genres = tvdb_item.genres new_genres = tvdb_item.genres
elif anidb_item and self.library.mass_genre_update == "anidb": elif anidb_item and self.library.mass_genre_update == "anidb":
new_genres = [str(t).title() for t in anidb_item.tags] new_genres = [str(t).title() for t in anidb_item.tags]
elif anidb_item and self.library.mass_genre_update == "anidb_all":
new_genres = [str(t).title() for t in anidb_item.all_tags]
elif mal_item and self.library.mass_genre_update == "mal": elif mal_item and self.library.mass_genre_update == "mal":
new_genres = mal_item.genres new_genres = mal_item.genres
else: else:

Loading…
Cancel
Save