diff --git a/misskaty/helper/kuso_utils.py b/misskaty/helper/kuso_utils.py index 39a41cb0..0f153018 100644 --- a/misskaty/helper/kuso_utils.py +++ b/misskaty/helper/kuso_utils.py @@ -1,7 +1,7 @@ import re import chevron -import telegraph +from telegraph.aio import Telegraph import logging from aiohttp import ClientSession from misskaty import BOT_USERNAME @@ -9,11 +9,6 @@ from bs4 import BeautifulSoup as bs4 LOGGER = logging.getLogger(__name__) -telegraph = telegraph.Telegraph() -if telegraph.get_access_token() is None: - token_ph = telegraph.create_account(short_name=BOT_USERNAME) - LOGGER.info("kuso_utils: Create TGH Account ..") - headers = {"Accept": "*/*", "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"} @@ -88,7 +83,12 @@ async def byPassPh(url: str, msg_id: int): {{/data}} """.strip() html = chevron.render(template, kusonime) - page = telegraph.create_page(f"{kusonime.get('title')}-{msg_id}", html_content=html) + telegraph = Telegraph() + if telegraph.get_access_token() is None: + await telegraph.create_account(short_name=BOT_USERNAME) + LOGGER.info("Create TGH Account ..") + page = await telegraph.create_page(f"{kusonime.get('title')}-{msg_id}", html_content=html) + LOGGER.info(page) results |= {"error": False, "url": f'https://telegra.ph/{page["path"]}'} del results["error_message"] return results diff --git a/misskaty/plugins/imdb_search.py b/misskaty/plugins/imdb_search.py index 8f09cc68..247575d3 100644 --- a/misskaty/plugins/imdb_search.py +++ b/misskaty/plugins/imdb_search.py @@ -274,7 +274,7 @@ async def imdb_id_callback(_, query): res_str = "" if judul := r_json.get("name"): try: - tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span", class_="sc-8c396aa2-2 jwaBvf").text + tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span").text except: tahun = "N/A" res_str += f"📹 Judul: {judul} [{tahun}] ({typee})\n" @@ -394,7 +394,7 @@ async def imdb_en_callback(bot, query): res_str = "" if judul := r_json.get("name"): try: - tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span", class_="sc-8c396aa2-2 jwaBvf").text + tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span").text except: tahun = "N/A" res_str += f"📹 Judul: {judul} [{tahun}] ({typee})\n" diff --git a/misskaty/plugins/inline_search.py b/misskaty/plugins/inline_search.py index 51c9894f..c2f79b18 100644 --- a/misskaty/plugins/inline_search.py +++ b/misskaty/plugins/inline_search.py @@ -548,7 +548,7 @@ async def imdb_inl(_, query): typee = r_json.get("@type", "") if r_json.get("name"): try: - tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span", class_="sc-8c396aa2-2 jwaBvf").text + tahun = sop.select('ul[data-testid="hero-title-block__metadata"]')[0].find("span").text except: tahun = "N/A" res_str += f"📹 Judul: {r_json['name']} [{tahun}] ({typee})\n"