[65] updated tvdb xpaths

pull/1237/head
meisnate12 2 years ago
parent 10435e8e55
commit 1afefd3ab0

@ -50,5 +50,3 @@ body:
description: > description: >
Please share the relevant log file with the error on [Gist](https://gist.github.com). Please share the relevant log file with the error on [Gist](https://gist.github.com).
placeholder: "https://gist.github.com" placeholder: "https://gist.github.com"
validations:
required: true

@ -1 +1 @@
1.18.0-develop64 1.18.0-develop65

@ -23,7 +23,7 @@ You can find items using the features of [TheMovieDb.org](https://www.themoviedb
| Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort | | Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort |
|:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:| |:----------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:|
| [`tmdb_collection_details`](#tmdb-collection) | Finds every item in the TMDb collection and updates the collection with the summary, poster, and background from the TMDb collection | ✅ | ❌ | ❌ | | [`tmdb_collection_details`](#tmdb-collection) | Finds every item in the TMDb collection and updates the collection with the summary, poster, and background from the TMDb collection | ✅ | ❌ | ❌ |
| [`tmdb_list_details`](#tmdb-list) | Finds every item in the TMDb List and updates the collection with the description of the TMDb list | ✅ | ✅ | ❌ | | [`tmdb_list_details`](#tmdb-list) | Finds every item in the TMDb List and updates the collection with the description and poster of the TMDb list | ✅ | ✅ | ❌ |
| [`tmdb_actor_details`](#tmdb-actor) | Finds every item in the TMDb Person's Actor Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ | | [`tmdb_actor_details`](#tmdb-actor) | Finds every item in the TMDb Person's Actor Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ |
| [`tmdb_crew_details`](#tmdb-crew) | Finds every item in the TMDb Person's Crew Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ | | [`tmdb_crew_details`](#tmdb-crew) | Finds every item in the TMDb Person's Crew Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ |
| [`tmdb_director_details`](#tmdb-director) | Finds every item in the TMDb Person's Actor Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ | | [`tmdb_director_details`](#tmdb-director) | Finds every item in the TMDb Person's Actor Credits with the biography and profile from the TMDb person | ✅ | ✅ | ❌ |
@ -116,7 +116,7 @@ collections:
sync_mode: sync sync_mode: sync
``` ```
* You can update the collection details with the TMDb list's description by using `tmdb_list_details`. * You can update the collection details with the TMDb list's description and poster by using `tmdb_list_details`.
* You can specify multiple lists in `tmdb_list_details` but it will only use the first one to update the collection details. * You can specify multiple lists in `tmdb_list_details` but it will only use the first one to update the collection details.
```yaml ```yaml

@ -5,9 +5,9 @@ You can find items using the features of [TheTVDb.com](https://www.thetvdb.com/)
No configuration is required for these builders. No configuration is required for these builders.
| Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort | | Attribute | Description | Works with Movies | Works with Shows | Works with Playlists and Custom Sort |
|:------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:| |:------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------:|:----------------:|:------------------------------------:|
| [`tvdb_list`](#tvdb-list) | Finds every item in a [TVDb List](https://www.thetvdb.com/lists) or [TVDb Userlist](https://www.thetvdb.com/lists/custom) | ✅ | ✅ | ✅ | | [`tvdb_list`](#tvdb-list) | Finds every item in a [TVDb List](https://www.thetvdb.com/lists) or [TVDb Userlist](https://www.thetvdb.com/lists/custom) | ✅ | ✅ | ✅ |
| [`tvdb_list_details`](#tvdb-list) | Finds every item in a [TVDb List](https://www.thetvdb.com/lists) or [TVDb Userlist](https://www.thetvdb.com/lists/custom) and updates the collection summary with the TVDb list description | ✅ | ✅ | ✅ | | [`tvdb_list_details`](#tvdb-list) | Finds every item in a [TVDb List](https://www.thetvdb.com/lists) or [TVDb Userlist](https://www.thetvdb.com/lists/custom) and updates the collection summary and poster with the TVDb list metadata | ✅ | ✅ | ✅ |
| [`tvdb_show`](#tvdb-show) | Finds the series specified | ❌ | ✅ | ❌ | | [`tvdb_show`](#tvdb-show) | Finds the series specified | ❌ | ✅ | ❌ |
| [`tvdb_show_details`](#tvdb-show) | Finds the series specified and updates the collection with the summary, poster, and background from the TVDb series | ❌ | ✅ | ❌ | | [`tvdb_show_details`](#tvdb-show) | Finds the series specified and updates the collection with the summary, poster, and background from the TVDb series | ❌ | ✅ | ❌ |
| [`tvdb_movie`](#tvdb-movie) | Finds the movie specified | ✅ | ❌ | ❌ | | [`tvdb_movie`](#tvdb-movie) | Finds the movie specified | ✅ | ❌ | ❌ |
@ -36,7 +36,7 @@ collections:
sync_mode: sync sync_mode: sync
``` ```
* You can update the collection details with the TVDb list's description by using `tvdb_list_details`. * You can update the collection details with the TVDb list's description and poster by using `tvdb_list_details`.
* You can specify multiple lists in `tvdb_list_details` but it will only use the first one to update the collection details. * You can specify multiple lists in `tvdb_list_details` but it will only use the first one to update the collection details.
```yaml ```yaml

@ -56,6 +56,7 @@ If no poster is specified the script will look in the library's [Image Asset Dir
| `tmdb_list_poster` | **Description:** Changes poster to the TMDb List poster<br>**Values:** TMDb List ID | | `tmdb_list_poster` | **Description:** Changes poster to the TMDb List poster<br>**Values:** TMDb List ID |
| `tmdb_profile` | **Description:** Changes poster to the TMDb Person's profile<br>**Values:** TMDb Person ID | | `tmdb_profile` | **Description:** Changes poster to the TMDb Person's profile<br>**Values:** TMDb Person ID |
| `tvdb_poster` | **Description:** Changes poster to the TVDb Movie poster for a movie library or the TVDb Show poster for a show library<br>**Values:** TVDb Movie/Show ID or URL | | `tvdb_poster` | **Description:** Changes poster to the TVDb Movie poster for a movie library or the TVDb Show poster for a show library<br>**Values:** TVDb Movie/Show ID or URL |
| `tvdb_list_poster` | **Description:** Changes poster to the TVDb List poster<br>**Values:** TVDb List URL |
| `file_poster` | **Description:** Changes poster to the image in the file system<br>**Values:** Path to image in the file system | | `file_poster` | **Description:** Changes poster to the image in the file system<br>**Values:** Path to image in the file system |
## Background Collection/Playlist Metadata Updates ## Background Collection/Playlist Metadata Updates

@ -857,7 +857,9 @@ class CollectionBuilder:
elif method_name == "tvdb_summary": elif method_name == "tvdb_summary":
self.summaries[method_name] = self.config.TVDb.get_tvdb_obj(method_data, is_movie=self.library.is_movie).summary self.summaries[method_name] = self.config.TVDb.get_tvdb_obj(method_data, is_movie=self.library.is_movie).summary
elif method_name == "tvdb_description": elif method_name == "tvdb_description":
self.summaries[method_name] = self.config.TVDb.get_list_description(method_data) summary, _ = self.config.TVDb.get_list_description(method_data)
if summary:
self.summaries[method_name] = summary
elif method_name == "trakt_description": elif method_name == "trakt_description":
self.summaries[method_name] = self.config.Trakt.list_description(self.config.Trakt.validate_list(method_data)[0]) self.summaries[method_name] = self.config.Trakt.list_description(self.config.Trakt.validate_list(method_data)[0])
elif method_name == "letterboxd_description": elif method_name == "letterboxd_description":
@ -874,6 +876,12 @@ class CollectionBuilder:
self.posters[method_name] = method_data self.posters[method_name] = method_data
except ConnectionError: except ConnectionError:
logger.warning(f"{self.Type} Warning: No Poster Found at {method_data}") logger.warning(f"{self.Type} Warning: No Poster Found at {method_data}")
elif method_name == "tmdb_list_poster":
self.posters[method_name] = self.config.TMDb.get_list(util.regex_first_int(method_data, "TMDb List ID")).poster_url
elif method_name == "tvdb_list_poster":
_, poster = self.config.TVDb.get_list_description(method_data)
if poster:
self.posters[method_name] = poster
elif method_name == "tmdb_poster": elif method_name == "tmdb_poster":
self.posters[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).poster_url self.posters[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, 'TMDb ID'), self.library.is_movie).poster_url
elif method_name == "tmdb_profile": elif method_name == "tmdb_profile":
@ -1457,6 +1465,8 @@ class CollectionBuilder:
item = self.config.TMDb.get_list(values[0]) item = self.config.TMDb.get_list(values[0])
if item.description: if item.description:
self.summaries[method_name] = item.description self.summaries[method_name] = item.description
if item.poster_url:
self.posters[method_name] = item.poster_url
for value in values: for value in values:
self.builders.append((method_name[:-8] if method_name in tmdb.details_builders else method_name, value)) self.builders.append((method_name[:-8] if method_name in tmdb.details_builders else method_name, value))
@ -1512,7 +1522,11 @@ class CollectionBuilder:
if item.poster_url: if item.poster_url:
self.posters[method_name] = item.poster_url self.posters[method_name] = item.poster_url
elif method_name.startswith("tvdb_list"): elif method_name.startswith("tvdb_list"):
self.summaries[method_name] = self.config.TVDb.get_list_description(values[0]) description, poster = self.config.TVDb.get_list_description(values[0])
if description:
self.summaries[method_name] = description
if poster:
self.posters[method_name] = poster
for value in values: for value in values:
self.builders.append((method_name[:-8] if method_name.endswith("_details") else method_name, value)) self.builders.append((method_name[:-8] if method_name.endswith("_details") else method_name, value))
@ -2566,6 +2580,7 @@ class CollectionBuilder:
logger.info("") logger.info("")
if "summary" in self.summaries: summary = ("summary", self.summaries["summary"]) if "summary" in self.summaries: summary = ("summary", self.summaries["summary"])
elif "tmdb_description" in self.summaries: summary = ("tmdb_description", self.summaries["tmdb_description"]) elif "tmdb_description" in self.summaries: summary = ("tmdb_description", self.summaries["tmdb_description"])
elif "tvdb_description" in self.summaries: summary = ("tvdb_description", self.summaries["tvdb_description"])
elif "letterboxd_description" in self.summaries: summary = ("letterboxd_description", self.summaries["letterboxd_description"]) elif "letterboxd_description" in self.summaries: summary = ("letterboxd_description", self.summaries["letterboxd_description"])
elif "tmdb_summary" in self.summaries: summary = ("tmdb_summary", self.summaries["tmdb_summary"]) elif "tmdb_summary" in self.summaries: summary = ("tmdb_summary", self.summaries["tmdb_summary"])
elif "tvdb_summary" in self.summaries: summary = ("tvdb_summary", self.summaries["tvdb_summary"]) elif "tvdb_summary" in self.summaries: summary = ("tvdb_summary", self.summaries["tvdb_summary"])
@ -2574,6 +2589,7 @@ class CollectionBuilder:
elif "tmdb_collection_details" in self.summaries: summary = ("tmdb_collection_details", self.summaries["tmdb_collection_details"]) elif "tmdb_collection_details" in self.summaries: summary = ("tmdb_collection_details", self.summaries["tmdb_collection_details"])
elif "trakt_list_details" in self.summaries: summary = ("trakt_list_details", self.summaries["trakt_list_details"]) elif "trakt_list_details" in self.summaries: summary = ("trakt_list_details", self.summaries["trakt_list_details"])
elif "tmdb_list_details" in self.summaries: summary = ("tmdb_list_details", self.summaries["tmdb_list_details"]) elif "tmdb_list_details" in self.summaries: summary = ("tmdb_list_details", self.summaries["tmdb_list_details"])
elif "tvdb_list_details" in self.summaries: summary = ("tvdb_list_details", self.summaries["tvdb_list_details"])
elif "letterboxd_list_details" in self.summaries: summary = ("letterboxd_list_details", self.summaries["letterboxd_list_details"]) elif "letterboxd_list_details" in self.summaries: summary = ("letterboxd_list_details", self.summaries["letterboxd_list_details"])
elif "icheckmovies_list_details" in self.summaries: summary = ("icheckmovies_list_details", self.summaries["icheckmovies_list_details"]) elif "icheckmovies_list_details" in self.summaries: summary = ("icheckmovies_list_details", self.summaries["icheckmovies_list_details"])
elif "tmdb_actor_details" in self.summaries: summary = ("tmdb_actor_details", self.summaries["tmdb_actor_details"]) elif "tmdb_actor_details" in self.summaries: summary = ("tmdb_actor_details", self.summaries["tmdb_actor_details"])

@ -767,6 +767,7 @@ class ConfigFile:
if lib and "template_variables" in lib and lib["template_variables"] and isinstance(lib["template_variables"], dict): if lib and "template_variables" in lib and lib["template_variables"] and isinstance(lib["template_variables"], dict):
lib_vars = lib["template_variables"] lib_vars = lib["template_variables"]
params["metadata_path"] = []
try: try:
if lib and "metadata_path" in lib: if lib and "metadata_path" in lib:
if not lib["metadata_path"]: if not lib["metadata_path"]:
@ -777,8 +778,6 @@ class ConfigFile:
params["metadata_path"] = files params["metadata_path"] = files
elif os.path.exists(os.path.join(default_dir, f"{library_name}.yml")): elif os.path.exists(os.path.join(default_dir, f"{library_name}.yml")):
params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)] params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)]
else:
params["metadata_path"] = []
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
params["default_dir"] = default_dir params["default_dir"] = default_dir

@ -79,8 +79,8 @@ class TVDbObj:
if not self.title: if not self.title:
raise Failed(f"TVDb Error: Name not found from TVDb ID: {self.tvdb_id}") raise Failed(f"TVDb Error: Name not found from TVDb ID: {self.tvdb_id}")
self.poster_url = parse_page("(//h2[@class='mt-4' and text()='Posters']/following::div/a/@href)[1]") self.poster_url = parse_page("//div[@id='artwork-posters']/div/div/a/@href")
self.background_url = parse_page("(//h2[@class='mt-4' and text()='Backgrounds']/following::div/a/@href)[1]") self.background_url = parse_page("//div[@id='artwork-backgrounds']/div/div/a/@href")
if is_movie: if is_movie:
released = parse_page("//strong[text()='Released']/parent::li/span/text()[normalize-space()]") released = parse_page("//strong[text()='Released']/parent::li/span/text()[normalize-space()]")
else: else:
@ -106,10 +106,6 @@ class TVDb:
tvdb_id, _, _ = self.get_id_from_url(tvdb_url, is_movie=is_movie) tvdb_id, _, _ = self.get_id_from_url(tvdb_url, is_movie=is_movie)
return TVDbObj(self, tvdb_id, is_movie=is_movie) return TVDbObj(self, tvdb_id, is_movie=is_movie)
def get_list_description(self, tvdb_url):
response = self.config.get_html(tvdb_url, headers=util.header(self.language))
description = response.xpath("//div[@class='block']/div[not(@style='display:none')]/p/text()")
return description[0] if len(description) > 0 and len(description[0]) > 0 else ""
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_failed)
def get_request(self, tvdb_url): def get_request(self, tvdb_url):
@ -171,6 +167,14 @@ class TVDb:
err_text = f"ID at the URL {tvdb_url}" err_text = f"ID at the URL {tvdb_url}"
raise Failed(f"TVDb Error: Could not find a TVDb {media_type} {err_text}") raise Failed(f"TVDb Error: Could not find a TVDb {media_type} {err_text}")
def get_list_description(self, tvdb_url):
response = self.config.get_html(tvdb_url, headers=util.header(self.language))
description = response.xpath("//div[@class='block']/div[not(@style='display:none')]/p/text()")
description = description[0] if len(description) > 0 and len(description[0]) > 0 else None
poster = response.xpath("//div[@id='artwork']/div/div/a/@href")
poster = poster[0] if len(poster) > 0 and len(poster[0]) > 0 else None
return description, poster
def _ids_from_url(self, tvdb_url): def _ids_from_url(self, tvdb_url):
ids = [] ids = []
tvdb_url = tvdb_url.strip() tvdb_url = tvdb_url.strip()
@ -178,7 +182,7 @@ class TVDb:
if tvdb_url.startswith((urls["list"], urls["alt_list"])): if tvdb_url.startswith((urls["list"], urls["alt_list"])):
try: try:
response = self.config.get_html(tvdb_url, headers=util.header(self.language)) response = self.config.get_html(tvdb_url, headers=util.header(self.language))
items = response.xpath("//div[@class='row']/div/div[@class='row']/div/h3/a") items = response.xpath("//div[@id='general']//div/div/h3/a")
for item in items: for item in items:
title = item.xpath("text()")[0] title = item.xpath("text()")[0]
item_url = item.xpath("@href")[0] item_url = item.xpath("@href")[0]

@ -199,6 +199,10 @@ def pick_image(title, images, prioritize_assets, download_url_assets, item_dir,
final_attr = f"tmdb_{image_type}" final_attr = f"tmdb_{image_type}"
elif "tmdb_profile" in images: elif "tmdb_profile" in images:
final_attr = "tmdb_profile" final_attr = "tmdb_profile"
elif "tmdb_list_poster" in images:
final_attr = "tmdb_list_poster"
elif "tvdb_list_poster" in images:
final_attr = "tvdb_list_poster"
elif f"tvdb_{image_type}" in images: elif f"tvdb_{image_type}" in images:
final_attr = f"tvdb_{image_type}" final_attr = f"tvdb_{image_type}"
elif "asset_directory" in images: elif "asset_directory" in images:
@ -219,6 +223,10 @@ def pick_image(title, images, prioritize_assets, download_url_assets, item_dir,
final_attr = "tmdb_writer_details" final_attr = "tmdb_writer_details"
elif "tmdb_movie_details" in images: elif "tmdb_movie_details" in images:
final_attr = "tmdb_movie_details" final_attr = "tmdb_movie_details"
elif "tmdb_list_details" in images:
final_attr = "tmdb_list_details"
elif "tvdb_list_details" in images:
final_attr = "tvdb_list_details"
elif "tvdb_movie_details" in images: elif "tvdb_movie_details" in images:
final_attr = "tvdb_movie_details" final_attr = "tvdb_movie_details"
elif "tvdb_show_details" in images: elif "tvdb_show_details" in images:

Loading…
Cancel
Save