This commit is contained in:
Yasir Aris M 2023-10-29 22:53:51 +07:00
commit 930a53e4d1
2 changed files with 15 additions and 15 deletions

View file

@ -5,6 +5,7 @@ import string
import time import time
from http.cookies import SimpleCookie from http.cookies import SimpleCookie
from re import match as re_match from re import match as re_match
from typing import Union
from urllib.parse import urlparse from urllib.parse import urlparse
import psutil import psutil
@ -124,7 +125,7 @@ def get_provider(url):
return pretty(netloc.split(".")) return pretty(netloc.split("."))
async def search_jw(movie_name: str, locale: str): async def search_jw(movie_name: str, locale: Union[str, None] = "ID"):
m_t_ = "" m_t_ = ""
try: try:
response = ( response = (
@ -137,17 +138,16 @@ async def search_jw(movie_name: str, locale: str):
if not response.get("results"): if not response.get("results"):
LOGGER.error("JustWatch API Error or got Rate Limited.") LOGGER.error("JustWatch API Error or got Rate Limited.")
return m_t_ return m_t_
for item in response.get("results")["items"]: for item in response["results"]["data"]["popularTitles"]["edges"]:
if movie_name == item.get("title", ""): if item["node"]["content"]["title"] == movie_name:
offers = item.get("offers", []) t_m_ = []
t_m_ = [] for offer in item["node"].get("offers", []):
for offer in offers: url = offer["standardWebURL"]
url = offer.get("urls").get("standard_web") if url not in t_m_:
if url not in t_m_: p_o = get_provider(url)
p_o = get_provider(url) m_t_ += f"<a href='{url}'>{p_o}</a> | "
m_t_ += f"<a href='{url}'>{p_o}</a> | " t_m_.append(url)
t_m_.append(url) if m_t_ != "":
if m_t_ != "": m_t_ = m_t_[:-2].strip()
m_t_ = m_t_[:-2].strip() break
break
return m_t_ return m_t_

View file

@ -165,7 +165,7 @@ async def locks_func(_, message):
await tg_lock(message, permissions, data[parameter], state == "lock") await tg_lock(message, permissions, data[parameter], state == "lock")
elif parameter == "all" and state == "lock": elif parameter == "all" and state == "lock":
try: try:
await app.set_chat_permissions(chat_id, ChatPermissions(all_perms=True)) await app.set_chat_permissions(chat_id, ChatPermissions(all_perms=False))
await message.reply_text(f"Locked Everything in {message.chat.title}") await message.reply_text(f"Locked Everything in {message.chat.title}")
except ChatAdminRequired: except ChatAdminRequired:
await message.reply_msg( await message.reply_msg(