From 6e3571a0de9d18fe0f5b3ef58078143a4896a732 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 13 Mar 2022 23:39:47 -0400 Subject: [PATCH] [11] fix tvdb genres --- VERSION | 2 +- modules/tvdb.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index bdf223de..f0163470 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.1-develop10 +1.16.1-develop11 diff --git a/modules/tvdb.py b/modules/tvdb.py index 54a1cf21..e82db9a4 100644 --- a/modules/tvdb.py +++ b/modules/tvdb.py @@ -66,11 +66,11 @@ class TVDbObj: else: raise Failed(f"TVDb Error: Could not find a TVDb {self.media_type} ID at the URL {self.tvdb_url}") - def parse_page(xpath): + def parse_page(xpath, is_list=False): parse_results = response.xpath(xpath) if len(parse_results) > 0: parse_results = [r.strip() for r in parse_results if len(r) > 0] - return parse_results[0] if len(parse_results) > 0 else None + return parse_results if is_list else parse_results[0] if len(parse_results) > 0 else None def parse_title_summary(lang=None): place = "//div[@class='change_translation_text' and " @@ -85,15 +85,15 @@ class TVDbObj: if not self.title: raise Failed(f"TVDb Error: Name not found from TVDb URL: {self.tvdb_url}") - self.poster_path = parse_page("//div[@class='row hidden-xs hidden-sm']/div/img/@src") + self.poster_path = parse_page("(//h2[@class='mt-4' and text()='Posters']/following::div/a/@href)[1]") self.background_path = parse_page("(//h2[@class='mt-4' and text()='Backgrounds']/following::div/a/@href)[1]") if self.is_movie: - self.directors = parse_page("//strong[text()='Directors']/parent::li/span/a/text()[normalize-space()]") - self.writers = parse_page("//strong[text()='Writers']/parent::li/span/a/text()[normalize-space()]") - self.studios = parse_page("//strong[text()='Studio']/parent::li/span/a/text()[normalize-space()]") + self.directors = parse_page("//strong[text()='Directors']/parent::li/span/a/text()[normalize-space()]", is_list=True) + self.writers = parse_page("//strong[text()='Writers']/parent::li/span/a/text()[normalize-space()]", is_list=True) + self.studios = parse_page("//strong[text()='Studio']/parent::li/span/a/text()[normalize-space()]", is_list=True) else: - self.networks = parse_page("//strong[text()='Networks']/parent::li/span/a/text()[normalize-space()]") - self.genres = parse_page("//strong[text()='Genres']/parent::li/span/a/text()[normalize-space()]") + self.networks = parse_page("//strong[text()='Networks']/parent::li/span/a/text()[normalize-space()]", is_list=True) + self.genres = parse_page("//strong[text()='Genres']/parent::li/span/a/text()[normalize-space()]", is_list=True) tmdb_id = None imdb_id = None