chg: refactor: remove repetitive code

This commit is contained in:
Felipe Marinho 2024-11-14 15:20:45 -03:00 committed by Zoe Roux
parent 6b751e11f3
commit 50e18ee99d
No known key found for this signature in database

View File

@ -193,7 +193,7 @@ class TheMovieDatabase(Provider):
reverse=True, reverse=True,
) )
return localized_images return self.get_image(localized_images)
async def search_movie(self, name: str, year: Optional[int]) -> Movie: async def search_movie(self, name: str, year: Optional[int]) -> Movie:
search_results = ( search_results = (
@ -268,13 +268,9 @@ class TheMovieDatabase(Provider):
tagline=movie["tagline"] if movie["tagline"] else None, tagline=movie["tagline"] if movie["tagline"] else None,
tags=list(map(lambda x: x["name"], movie["keywords"]["keywords"])), tags=list(map(lambda x: x["name"], movie["keywords"]["keywords"])),
overview=movie["overview"], overview=movie["overview"],
posters=self.get_image( posters=(await self.get_best_image(movie, lng, "posters")),
await self.get_best_image(movie, lng, "posters") logos=(await self.get_best_image(movie, lng, "logos")),
), thumbnails=(await self.get_best_image(movie, lng, "backdrops")),
logos=self.get_image(await self.get_best_image(movie, lng, "logos")),
thumbnails=self.get_image(
await self.get_best_image(movie, lng, "backdrops")
),
trailers=[ trailers=[
f"https://www.youtube.com/watch?v={x['key']}" f"https://www.youtube.com/watch?v={x['key']}"
for x in movie["videos"]["results"] for x in movie["videos"]["results"]
@ -361,13 +357,9 @@ class TheMovieDatabase(Provider):
tagline=show["tagline"] if show["tagline"] else None, tagline=show["tagline"] if show["tagline"] else None,
tags=list(map(lambda x: x["name"], show["keywords"]["results"])), tags=list(map(lambda x: x["name"], show["keywords"]["results"])),
overview=show["overview"], overview=show["overview"],
posters=self.get_image( posters=(await self.get_best_image(show, lng, "posters")),
await self.get_best_image(show, lng, "posters") logos=(await self.get_best_image(show, lng, "logos")),
), thumbnails=(await self.get_best_image(show, lng, "backdrops")),
logos=self.get_image(await self.get_best_image(show, lng, "logos")),
thumbnails=self.get_image(
await self.get_best_image(show, lng, "backdrops")
),
trailers=[ trailers=[
f"https://www.youtube.com/watch?v={x['key']}" f"https://www.youtube.com/watch?v={x['key']}"
for x in show["videos"]["results"] for x in show["videos"]["results"]