added letterboxd list descriptions

pull/83/head
meisnate12 4 years ago
parent 716d5d4837
commit 1ebaf44576

@ -246,6 +246,8 @@ class CollectionBuilder:
self.summaries[method_name] = config.TVDb.get_list_description(data[m], self.library.Plex.language) self.summaries[method_name] = config.TVDb.get_list_description(data[m], self.library.Plex.language)
elif method_name == "trakt_description": elif method_name == "trakt_description":
self.summaries[method_name] = config.Trakt.standard_list(config.Trakt.validate_trakt_list(util.get_list(data[m]))[0]).description self.summaries[method_name] = config.Trakt.standard_list(config.Trakt.validate_trakt_list(util.get_list(data[m]))[0]).description
elif method_name == "letterboxd_description":
self.summaries[method_name] = config.Letterboxd.get_list_description(data[m], self.library.Plex.language)
elif method_name == "collection_mode": elif method_name == "collection_mode":
if data[m] in ["default", "hide", "hide_items", "show_items", "hideItems", "showItems"]: if data[m] in ["default", "hide", "hide_items", "show_items", "hideItems", "showItems"]:
if data[m] == "hide_items": self.details[method_name] = "hideItems" if data[m] == "hide_items": self.details[method_name] = "hideItems"
@ -347,6 +349,10 @@ class CollectionBuilder:
self.methods.append((method_name, new_list)) self.methods.append((method_name, new_list))
elif method_name == "letterboxd_list": elif method_name == "letterboxd_list":
self.methods.append((method_name, util.get_list(data[m], split=False))) self.methods.append((method_name, util.get_list(data[m], split=False)))
elif method_name == "letterboxd_list_details":
values = util.get_list(data[m], split=False)
self.summaries[method_name] = config.Letterboxd.get_list_description(values[0], self.library.Plex.language)
self.methods.append((method_name[:-8], values))
elif method_name in util.dictionary_lists: elif method_name in util.dictionary_lists:
if isinstance(data[m], dict): if isinstance(data[m], dict):
def get_int(parent, method, data_in, default_in, minimum=1, maximum=None): def get_int(parent, method, data_in, default_in, minimum=1, maximum=None):
@ -803,6 +809,7 @@ class CollectionBuilder:
return summaries[summary_method] return summaries[summary_method]
if "summary" in self.summaries: summary = get_summary("summary", self.summaries) if "summary" in self.summaries: summary = get_summary("summary", self.summaries)
elif "tmdb_description" in self.summaries: summary = get_summary("tmdb_description", self.summaries) elif "tmdb_description" in self.summaries: summary = get_summary("tmdb_description", self.summaries)
elif "letterboxd_description" in self.summaries: summary = get_summary("letterboxd_description", self.summaries)
elif "tmdb_summary" in self.summaries: summary = get_summary("tmdb_summary", self.summaries) elif "tmdb_summary" in self.summaries: summary = get_summary("tmdb_summary", self.summaries)
elif "tvdb_summary" in self.summaries: summary = get_summary("tvdb_summary", self.summaries) elif "tvdb_summary" in self.summaries: summary = get_summary("tvdb_summary", self.summaries)
elif "tmdb_biography" in self.summaries: summary = get_summary("tmdb_biography", self.summaries) elif "tmdb_biography" in self.summaries: summary = get_summary("tmdb_biography", self.summaries)

@ -11,11 +11,15 @@ class LetterboxdAPI:
self.url = "https://letterboxd.com" self.url = "https://letterboxd.com"
@retry(stop_max_attempt_number=6, wait_fixed=10000) @retry(stop_max_attempt_number=6, wait_fixed=10000)
def send_request(self, url, header): def send_request(self, url, language):
return html.fromstring(requests.get(url, headers=header).content) return html.fromstring(requests.get(url, header={"Accept-Language": language, "User-Agent": "Mozilla/5.0 x64"}).content)
def get_list_description(self, list_url, language):
descriptions = self.send_request(list_url, language).xpath("//meta[@property='og:description']/@content")
return descriptions[0] if len(descriptions) > 0 and len(descriptions[0]) > 0 else None
def parse_list_for_slugs(self, list_url, language): def parse_list_for_slugs(self, list_url, language):
response = self.send_request(list_url, header={"Accept-Language": language, "User-Agent": "Mozilla/5.0 x64"}) response = self.send_request(list_url, language)
slugs = response.xpath("//div[@class='poster film-poster really-lazy-load']/@data-film-slug") slugs = response.xpath("//div[@class='poster film-poster really-lazy-load']/@data-film-slug")
next_url = response.xpath("//a[@class='next']/@href") next_url = response.xpath("//a[@class='next']/@href")
if len(next_url) > 0: if len(next_url) > 0:
@ -26,7 +30,7 @@ class LetterboxdAPI:
return self.get_tmdb(f"{self.url}{slug}", language) return self.get_tmdb(f"{self.url}{slug}", language)
def get_tmdb(self, letterboxd_url, language): def get_tmdb(self, letterboxd_url, language):
response = self.send_request(letterboxd_url, header={"Accept-Language": language, "User-Agent": "Mozilla/5.0 x64"}) response = self.send_request(letterboxd_url, language)
ids = response.xpath("//body/@data-tmdb-id") ids = response.xpath("//body/@data-tmdb-id")
if len(ids) > 0: if len(ids) > 0:
return int(ids[0]) return int(ids[0])

@ -98,6 +98,7 @@ pretty_names = {
"imdb_list": "IMDb List", "imdb_list": "IMDb List",
"imdb_id": "IMDb ID", "imdb_id": "IMDb ID",
"letterboxd_list": "Letterboxd List", "letterboxd_list": "Letterboxd List",
"letterboxd_list_details": "Letterboxd List",
"mal_id": "MyAnimeList ID", "mal_id": "MyAnimeList ID",
"mal_all": "MyAnimeList All", "mal_all": "MyAnimeList All",
"mal_airing": "MyAnimeList Airing", "mal_airing": "MyAnimeList Airing",
@ -220,6 +221,7 @@ all_lists = [
"imdb_list", "imdb_list",
"imdb_id", "imdb_id",
"letterboxd_list", "letterboxd_list",
"letterboxd_list_details",
"mal_id", "mal_id",
"mal_all", "mal_all",
"mal_airing", "mal_airing",
@ -322,6 +324,7 @@ show_only_lists = [
] ]
movie_only_lists = [ movie_only_lists = [
"letterboxd_list", "letterboxd_list",
"letterboxd_list_details",
"tmdb_collection", "tmdb_collection",
"tmdb_collection_details", "tmdb_collection_details",
"tmdb_movie", "tmdb_movie",
@ -454,7 +457,7 @@ boolean_details = [
] ]
all_details = [ all_details = [
"sort_title", "content_rating", "sort_title", "content_rating",
"summary", "tmdb_summary", "tmdb_description", "tmdb_biography", "tvdb_summary", "tvdb_description", "trakt_description", "summary", "tmdb_summary", "tmdb_description", "tmdb_biography", "tvdb_summary", "tvdb_description", "trakt_description", "letterboxd_description",
"collection_mode", "collection_order", "collection_mode", "collection_order",
"url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster", "url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster",
"url_background", "tmdb_background", "tvdb_background", "file_background", "url_background", "tmdb_background", "tvdb_background", "file_background",

Loading…
Cancel
Save