diff --git a/misskaty/helper/tools.py b/misskaty/helper/tools.py index 4dd471c1..4bfddc40 100644 --- a/misskaty/helper/tools.py +++ b/misskaty/helper/tools.py @@ -5,6 +5,7 @@ import string import time from http.cookies import SimpleCookie from re import match as re_match +from typing import Union from urllib.parse import urlparse import psutil @@ -137,17 +138,16 @@ async def search_jw(movie_name: str, locale: str): if not response.get("results"): LOGGER.error("JustWatch API Error or got Rate Limited.") return m_t_ - for item in response.get("results")["items"]: - if movie_name == item.get("title", ""): - offers = item.get("offers", []) - t_m_ = [] - for offer in offers: - url = offer.get("urls").get("standard_web") - if url not in t_m_: - p_o = get_provider(url) - m_t_ += f"{p_o} | " - t_m_.append(url) - if m_t_ != "": - m_t_ = m_t_[:-2].strip() - break + for item in response["results"]["data"]["popularTitles"]["edges"]: + if item["node"]["content"]["title"] == movie_name: + t_m_ = [] + for offer in item["node"].get("offers", []): + url = offer["standardWebURL"] + if url not in t_m_: + p_o = get_provider(url) + m_t_ += f"{p_o} | " + t_m_.append(url) + if m_t_ != "": + m_t_ = m_t_[:-2].strip() + break return m_t_