This commit is contained in:
yasir 2023-02-14 10:53:05 +07:00
parent 56ebdfdab3
commit 4c0c14e4e8
3 changed files with 10 additions and 10 deletions

View file

@ -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

View file

@ -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"<b>📹 Judul:</b> <a href='{url}'>{judul} [{tahun}]</a> (<code>{typee}</code>)\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"<b>📹 Judul:</b> <a href='{url}'>{judul} [{tahun}]</a> (<code>{typee}</code>)\n"

View file

@ -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"<b>📹 Judul:</b> <a href='{url}'>{r_json['name']} [{tahun}]</a> (<code>{typee}</code>)\n"