[9] add item_genre detail

pull/1020/head
meisnate12 2 years ago
parent 915518fdec
commit 86dc07e895

@ -1 +1 @@
1.17.3-develop8 1.17.3-develop9

@ -52,8 +52,8 @@ collectionless_details = ["collection_order", "plex_collectionless", "label", "l
poster_details + background_details + summary_details + string_details poster_details + background_details + summary_details + string_details
item_false_details = ["item_lock_background", "item_lock_poster", "item_lock_title"] item_false_details = ["item_lock_background", "item_lock_poster", "item_lock_title"]
item_bool_details = ["item_tmdb_season_titles", "revert_overlay", "item_assets", "item_refresh"] + item_false_details item_bool_details = ["item_tmdb_season_titles", "revert_overlay", "item_assets", "item_refresh"] + item_false_details
item_details = ["non_item_remove_label", "item_label", "item_radarr_tag", "item_sonarr_tag", "item_refresh_delay"] + item_bool_details + list(plex.item_advance_keys.keys()) item_details = ["non_item_remove_label", "item_label", "item_genre", "item_radarr_tag", "item_sonarr_tag", "item_refresh_delay"] + item_bool_details + list(plex.item_advance_keys.keys())
none_details = ["label.sync", "item_label.sync", "radarr_taglist", "sonarr_taglist"] none_details = ["label.sync", "item_label.sync", "item_genre.sync", "radarr_taglist", "sonarr_taglist"]
radarr_details = [ radarr_details = [
"radarr_add_missing", "radarr_add_existing", "radarr_upgrade_existing", "radarr_folder", "radarr_monitor", "radarr_add_missing", "radarr_add_existing", "radarr_upgrade_existing", "radarr_folder", "radarr_monitor",
"radarr_search", "radarr_availability", "radarr_quality", "radarr_tag", "item_radarr_tag" "radarr_search", "radarr_availability", "radarr_quality", "radarr_tag", "item_radarr_tag"
@ -930,6 +930,12 @@ class CollectionBuilder:
if "item_label.remove" in methods and "item_label.sync" in methods: if "item_label.remove" in methods and "item_label.sync" in methods:
raise Failed(f"{self.Type} Error: Cannot use item_label.remove and item_label.sync together") raise Failed(f"{self.Type} Error: Cannot use item_label.remove and item_label.sync together")
self.item_details[method_final] = util.get_list(method_data) if method_data else [] self.item_details[method_final] = util.get_list(method_data) if method_data else []
if method_name == "item_genre":
if "item_genre" in methods and "item_genre.sync" in methods:
raise Failed(f"{self.Type} Error: Cannot use item_genre and item_genre.sync together")
if "item_genre.remove" in methods and "item_genre.sync" in methods:
raise Failed(f"{self.Type} Error: Cannot use item_genre.remove and item_genre.sync together")
self.item_details[method_final] = util.get_list(method_data) if method_data else []
elif method_name == "non_item_remove_label": elif method_name == "non_item_remove_label":
if not method_data: if not method_data:
raise Failed(f"{self.Type} Error: non_item_remove_label is blank") raise Failed(f"{self.Type} Error: non_item_remove_label is blank")
@ -2350,6 +2356,10 @@ class CollectionBuilder:
remove_tags = self.item_details["item_label.remove"] if "item_label.remove" in self.item_details else None remove_tags = self.item_details["item_label.remove"] if "item_label.remove" in self.item_details else None
sync_tags = self.item_details["item_label.sync"] if "item_label.sync" in self.item_details else None sync_tags = self.item_details["item_label.sync"] if "item_label.sync" in self.item_details else None
add_genres = self.item_details["item_genres"] if "item_genres" in self.item_details else None
remove_genres = self.item_details["item_genres.remove"] if "item_genres.remove" in self.item_details else None
sync_genres = self.item_details["item_genres.sync"] if "item_genres.sync" in self.item_details else None
if "non_item_remove_label" in self.item_details: if "non_item_remove_label" in self.item_details:
rk_compare = [item.ratingKey for item in self.items] rk_compare = [item.ratingKey for item in self.items]
for non_item in self.library.search(label=self.item_details["non_item_remove_label"], libtype=self.builder_level): for non_item in self.library.search(label=self.item_details["non_item_remove_label"], libtype=self.builder_level):
@ -2363,6 +2373,7 @@ class CollectionBuilder:
if "item_assets" in self.item_details and self.library.asset_directory and "Overlay" not in current_labels: if "item_assets" in self.item_details and self.library.asset_directory and "Overlay" not in current_labels:
self.library.find_and_upload_assets(item, current_labels) self.library.find_and_upload_assets(item, current_labels)
self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags) self.library.edit_tags("label", item, add_tags=add_tags, remove_tags=remove_tags, sync_tags=sync_tags)
self.library.edit_tags("genre", item, add_tags=add_genres, remove_tags=remove_genres, sync_tags=sync_genres)
path = os.path.dirname(str(item.locations[0])) if self.library.is_movie else str(item.locations[0]) path = os.path.dirname(str(item.locations[0])) if self.library.is_movie else str(item.locations[0])
if self.library.Radarr and item.ratingKey in self.library.movie_rating_key_map: if self.library.Radarr and item.ratingKey in self.library.movie_rating_key_map:
path = path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path) path = path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path)

@ -12,29 +12,22 @@ class Letterboxd:
self.config = config self.config = config
def _parse_page(self, list_url, language): def _parse_page(self, list_url, language):
if "ajax" not in list_url:
list_url = list_url.replace("https://letterboxd.com/films", "https://letterboxd.com/films/ajax") list_url = list_url.replace("https://letterboxd.com/films", "https://letterboxd.com/films/ajax")
response = self.config.get_html(list_url, headers=util.header(language)) response = self.config.get_html(list_url, headers=util.header(language))
letterboxd_ids = response.xpath( letterboxd_ids = response.xpath("//li[contains(@class, 'poster-container') or contains(@class, 'film-detail')]/div/@data-film-id")
"//li[contains(@class, 'poster-container') or contains(@class, 'film-detail')]/div/@data-film-id")
items = [] items = []
for letterboxd_id in letterboxd_ids: for letterboxd_id in letterboxd_ids:
slugs = response.xpath(f"//div[@data-film-id='{letterboxd_id}']/@data-film-slug") slugs = response.xpath(f"//div[@data-film-id='{letterboxd_id}']/@data-film-slug")
comments = response.xpath( comments = response.xpath(f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']/div/p/text()")
f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']/div/p/text()") ratings = response.xpath(f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']//span[contains(@class, 'rating')]/@class")
ratings = response.xpath( years = response.xpath(f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']/h2/small/a/text()")
f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']//span[contains(@class, 'rating')]/@class")
years = response.xpath(
f"//div[@data-film-id='{letterboxd_id}']/parent::li/div[@class='film-detail-content']/h2/small/a/text()")
rating = None rating = None
if ratings: if ratings:
match = re.search("rated-(\\d+)", ratings[0]) match = re.search("rated-(\\d+)", ratings[0])
if match: if match:
rating = int(match.group(1)) rating = int(match.group(1))
items.append((letterboxd_id, slugs[0], items.append((letterboxd_id, slugs[0], int(years[0]) if years else None, comments[0] if comments else None, rating))
int(years[0]) if years else None,
comments[0] if comments else None,
rating
))
next_url = response.xpath("//a[@class='next']/@href") next_url = response.xpath("//a[@class='next']/@href")
return items, next_url return items, next_url

Loading…
Cancel
Save