[11] fix parental labels (#2300)

file-stuff
meisnate12 4 weeks ago committed by GitHub Action
parent ca485c472c
commit 4fe23ef787

@ -56,7 +56,7 @@ jobs:
done done
- name: Run Spellcheck - name: Run Spellcheck
uses: rojopolis/spellcheck-github-actions@0.43.1 uses: rojopolis/spellcheck-github-actions@0.44.0
docker-build-pull: docker-build-pull:
runs-on: ubuntu-latest runs-on: ubuntu-latest

@ -1,7 +1,7 @@
# Requirements Update (requirements will need to be reinstalled) # Requirements Update (requirements will need to be reinstalled)
Update pillow requirement to 11.0.0 Update pillow requirement to 11.0.0
Update psutil requirement to 6.1.0 Update psutil requirement to 6.1.0
Update setuptools requirement to 75.2.0 Update setuptools requirement to 75.3.0
# New Features # New Features
Added the `character` search option to the `imdb_search` builder Added the `character` search option to the `imdb_search` builder
@ -9,6 +9,7 @@ Added the `character` search option to the `imdb_search` builder
# Defaults # Defaults
Fixed incorrect content rating mappings in various Default files Fixed incorrect content rating mappings in various Default files
Fixes an issue where Prime Video overlays/collections would not be built when the `watch_region` is set to AU Fixes an issue where Prime Video overlays/collections would not be built when the `watch_region` is set to AU
fixes an issue where Rotten Tomatoes Verified Hot wasn't working
# Bug Fixes # Bug Fixes
Fixed the `cast` search option for the `imdb_search` builder Fixed the `cast` search option for the `imdb_search` builder
@ -17,3 +18,5 @@ Fixes `letterboxd_list` rating filter to use a 1-10 rating vs 1-100 to reflect h
Fixes #2274 Enhance handling of smart collections in deletion Fixes #2274 Enhance handling of smart collections in deletion
Fixed the `ids_to_anidb` lookup for anime movies and shows Fixed the `ids_to_anidb` lookup for anime movies and shows
Fixes an issue where episode overlays sometimes wouldn't be added Fixes an issue where episode overlays sometimes wouldn't be added
Fixes an issue with IMDb Parental Labels not working
Fixes an issue where OMDb returned `N/A` as the content rating

@ -1 +1 @@
2.1.0-build10 2.1.0-build11

@ -124,7 +124,7 @@ templates:
image_extra: image_extra:
default: "" default: ""
conditions: conditions:
- rating<<rating_num>>_image: [imdb, rt_tomato, metacritic] - rating<<rating_num>>_image: [imdb, rt_popcorn, rt_tomato, metacritic]
image_level: Top image_level: Top
value: Top value: Top
- rating<<rating_num>>_image: [rt_popcorn, rt_tomato] - rating<<rating_num>>_image: [rt_popcorn, rt_tomato]

@ -1035,11 +1035,11 @@ class Cache:
cursor.execute("SELECT * FROM imdb_parental WHERE imdb_id = ?", (imdb_id,)) cursor.execute("SELECT * FROM imdb_parental WHERE imdb_id = ?", (imdb_id,))
row = cursor.fetchone() row = cursor.fetchone()
if row: if row:
imdb_dict["nudity"] = row["nudity"] if row["nudity"] else "None" imdb_dict["Nudity"] = row["nudity"] if row["nudity"] else "None"
imdb_dict["violence"] = row["violence"] if row["violence"] else "None" imdb_dict["Violence"] = row["violence"] if row["violence"] else "None"
imdb_dict["profanity"] = row["profanity"] if row["profanity"] else "None" imdb_dict["Profanity"] = row["profanity"] if row["profanity"] else "None"
imdb_dict["alcohol"] = row["alcohol"] if row["alcohol"] else "None" imdb_dict["Alcohol"] = row["alcohol"] if row["alcohol"] else "None"
imdb_dict["frightening"] = row["frightening"] if row["frightening"] else "None" imdb_dict["Frightening"] = row["frightening"] if row["frightening"] else "None"
datetime_object = datetime.strptime(row["expiration_date"], "%Y-%m-%d") datetime_object = datetime.strptime(row["expiration_date"], "%Y-%m-%d")
time_between_insertion = datetime.now() - datetime_object time_between_insertion = datetime.now() - datetime_object
expired = time_between_insertion.days > expiration expired = time_between_insertion.days > expiration
@ -1053,8 +1053,8 @@ class Cache:
cursor.execute("INSERT OR IGNORE INTO imdb_parental(imdb_id) VALUES(?)", (imdb_id,)) cursor.execute("INSERT OR IGNORE INTO imdb_parental(imdb_id) VALUES(?)", (imdb_id,))
update_sql = "UPDATE imdb_parental SET nudity = ?, violence = ?, profanity = ?, alcohol = ?, " \ update_sql = "UPDATE imdb_parental SET nudity = ?, violence = ?, profanity = ?, alcohol = ?, " \
"frightening = ?, expiration_date = ? WHERE imdb_id = ?" "frightening = ?, expiration_date = ? WHERE imdb_id = ?"
cursor.execute(update_sql, (parental["nudity"], parental["violence"], parental["profanity"], parental["alcohol"], cursor.execute(update_sql, (parental["Nudity"], parental["Violence"], parental["Profanity"], parental["Alcohol"],
parental["frightening"], expiration_date.strftime("%Y-%m-%d"), imdb_id)) parental["Frightening"], expiration_date.strftime("%Y-%m-%d"), imdb_id))
def query_ergast(self, year, expiration): def query_ergast(self, year, expiration):
ergast_list = [] ergast_list = []

@ -523,13 +523,14 @@ class IMDb:
parental_dict, expired = self.cache.query_imdb_parental(imdb_id, self.cache.expiration) parental_dict, expired = self.cache.query_imdb_parental(imdb_id, self.cache.expiration)
if parental_dict and expired is False: if parental_dict and expired is False:
return parental_dict return parental_dict
response = self._request(f"{base_url}/title/{imdb_id}/parentalguide") for e in self._request(f"{base_url}/title/{imdb_id}/parentalguide", xpath="//li[contains(@class, 'ipc-metadata-list-item--link')]"):
for ptype in util.parental_types: parental_dict[util.parental_types[e.xpath("a/text()")[0][:-1]]] = e.xpath("div/div/div/text()")[0]
results = response.xpath(f"//section[@id='advisory-{ptype}']//span[contains(@class,'ipl-status-pill')]/text()") if parental_dict:
if results: for _, v in util.parental_types.items():
parental_dict[ptype] = results[0].strip() if v not in parental_dict:
parental_dict[v] = None
else: else:
raise Failed(f"IMDb Error: No Item Found for IMDb ID: {imdb_id}") raise Failed(f"IMDb Error: No Parental Guide Found for IMDb ID: {imdb_id}")
if self.cache and not ignore_cache: if self.cache and not ignore_cache:
self.cache.update_imdb_parental(expired, imdb_id, parental_dict, self.cache.expiration) self.cache.update_imdb_parental(expired, imdb_id, parental_dict, self.cache.expiration)
return parental_dict return parental_dict

@ -23,6 +23,8 @@ class OMDbObj:
return float(value) return float(value)
elif is_date: elif is_date:
return datetime.strptime(value, "%d %b %Y") return datetime.strptime(value, "%d %b %Y")
elif value == "N/A":
return None
else: else:
return value return value
except (ValueError, TypeError, KeyError): except (ValueError, TypeError, KeyError):

@ -163,7 +163,7 @@ class Operations:
parental_labels = [] parental_labels = []
else: else:
parental_guide = self.config.IMDb.parental_guide(imdb_id) parental_guide = self.config.IMDb.parental_guide(imdb_id)
parental_labels = [f"{k.capitalize()}:{v}" for k, v in parental_guide.items() if v not in util.parental_levels[self.library.mass_imdb_parental_labels]] parental_labels = [f"{k}:{v}" for k, v in parental_guide.items() if v and v not in util.parental_levels[self.library.mass_imdb_parental_labels]]
add_labels = [la for la in parental_labels if la not in current_labels] add_labels = [la for la in parental_labels if la not in current_labels]
remove_labels = [la for la in current_labels if la in util.parental_labels and la not in parental_labels] remove_labels = [la for la in current_labels if la in util.parental_labels and la not in parental_labels]
for label_list, edit_type in [(add_labels, "add"), (remove_labels, "remove")]: for label_list, edit_type in [(add_labels, "add"), (remove_labels, "remove")]:

@ -111,10 +111,10 @@ collection_mode_options = {
"show_items": "showItems", "showitems": "showItems" "show_items": "showItems", "showitems": "showItems"
} }
image_content_types = ["image/png", "image/jpeg", "image/webp"] image_content_types = ["image/png", "image/jpeg", "image/webp"]
parental_types = ["nudity", "violence", "profanity", "alcohol", "frightening"] parental_types = {"Sex & Nudity": "Nudity", "Violence & Gore": "Violence", "Profanity": "Profanity", "Alcohol, Drugs & Smoking": "Alcohol", "Frightening & Intense Scenes": "Frightening"}
parental_values = ["None", "Mild", "Moderate", "Severe"] parental_values = ["None", "Mild", "Moderate", "Severe"]
parental_levels = {"none": [], "mild": ["None"], "moderate": ["None", "Mild"], "severe": ["None", "Mild", "Moderate"]} parental_levels = {"none": [], "mild": ["None"], "moderate": ["None", "Mild"], "severe": ["None", "Mild", "Moderate"]}
parental_labels = [f"{t.capitalize()}:{v}" for t in parental_types for v in parental_values] parental_labels = [f"{t}:{v}" for t in parental_types.values() for v in parental_values]
previous_time = None previous_time = None
start_time = None start_time = None

@ -12,5 +12,5 @@ requests==2.32.3
tenacity==9.0.0 tenacity==9.0.0
ruamel.yaml==0.18.6 ruamel.yaml==0.18.6
schedule==1.2.2 schedule==1.2.2
setuptools==75.2.0 setuptools==75.3.0
tmdbapis==1.2.21 tmdbapis==1.2.21
Loading…
Cancel
Save