mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
Initial commit for PusatFilm21 Scraper
Some checks failed
Notify on Telegram / notify (push) Has been cancelled
Some checks failed
Notify on Telegram / notify (push) Has been cancelled
Signed-off-by: Yasir Aris <git@yasir.id>
This commit is contained in:
parent
a6a7e73e3b
commit
47fbee67d2
1 changed files with 217 additions and 0 deletions
|
|
@ -38,6 +38,7 @@ __HELP__ = """
|
|||
/nodrakor [query <optional>] - Scrape website data from NoDrakor
|
||||
/nunadrama [query <optional>] - Scrape website data from NunaDrama
|
||||
/dutamovie [query <optional>] - Scrape website data from DutaMovie
|
||||
/pusatfilm [query <optional>] - Scrape website data from Pusatfilm21
|
||||
"""
|
||||
|
||||
LOGGER = logging.getLogger("MissKaty")
|
||||
|
|
@ -63,6 +64,7 @@ web = {
|
|||
"nodrakor": "https://no-drakor.xyz",
|
||||
"nunadrama": "https://tv.nunadrama.store",
|
||||
"dutamovie": "https://yborfilmfestival.com",
|
||||
"pusatfilm": "http://85.203.26.50"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -444,6 +446,61 @@ async def getDataNunaDrama(msg, kueri, CurrentPage, user, strings):
|
|||
return nunaResult, PageLen, extractbtn
|
||||
|
||||
|
||||
# PusatFilm21 GetData
|
||||
async def getDataPusatFilm(msg, kueri, CurrentPage, user, strings):
|
||||
if not SCRAP_DICT.get(msg.id):
|
||||
with contextlib.redirect_stdout(sys.stderr):
|
||||
try:
|
||||
nunafetch = await fetch.get(
|
||||
f"{web['pusatfilm']}/?s={kueri}", follow_redirects=True
|
||||
)
|
||||
nunafetch.raise_for_status()
|
||||
except httpx.HTTPError as exc:
|
||||
await msg.edit_msg(
|
||||
f"ERROR: Failed to fetch data from {exc.request.url} - <code>{exc}</code>",
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
return None, 0, None
|
||||
text = BeautifulSoup(nunafetch, "lxml")
|
||||
entry = text.find_all(class_="entry-header")
|
||||
if entry[0].text.strip() == "Nothing Found":
|
||||
if not kueri:
|
||||
await msg.edit_msg(strings("no_result"), del_in=5)
|
||||
else:
|
||||
await msg.edit_msg(
|
||||
strings("no_result_w_query").format(kueri=kueri), del_in=5
|
||||
)
|
||||
return None, 0, None
|
||||
else:
|
||||
data = []
|
||||
for i in entry:
|
||||
genre = i.find(class_="gmr-movie-on")
|
||||
genre = f"{genre.text}" if genre else "N/A"
|
||||
judul = i.find(class_="entry-title").find("a").text
|
||||
link = i.find(class_="entry-title").find("a").get("href")
|
||||
data.append({"judul": judul, "link": link, "genre": genre})
|
||||
SCRAP_DICT.add(msg.id, [split_arr(data, 6), kueri], timeout=1800)
|
||||
index = int(CurrentPage - 1)
|
||||
PageLen = len(SCRAP_DICT[msg.id][0])
|
||||
extractbtn = []
|
||||
|
||||
pfResult = (
|
||||
strings("header_with_query").format(web="PusatFilm21", kueri=kueri)
|
||||
if kueri
|
||||
else strings("header_no_query").format(web="PusatFilm21", cmd="pusatfilm")
|
||||
)
|
||||
for c, i in enumerate(SCRAP_DICT[msg.id][0][index], start=1):
|
||||
pfResult += f"<b>{index*6+c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Genre:</b> <code>{i['genre']}</code>\n\n"
|
||||
if not re.search(r"Series", i["genre"]):
|
||||
extractbtn.append(
|
||||
InlineButton(
|
||||
index * 6 + c, f"pfextract#{CurrentPage}#{c}#{user}#{msg.id}"
|
||||
)
|
||||
)
|
||||
pfResult += strings("unsupport_dl_btn")
|
||||
return pfResult, PageLen, extractbtn
|
||||
|
||||
|
||||
# DutaMovie GetData
|
||||
async def getDataDutaMovie(msg, kueri, CurrentPage, user, strings):
|
||||
if not SCRAP_DICT.get(msg.id):
|
||||
|
|
@ -875,6 +932,34 @@ async def nunadrama_s(self, message, strings):
|
|||
)
|
||||
|
||||
|
||||
# PusatFilm21 CMD
|
||||
@app.on_cmd("pusatfilm", no_channel=True)
|
||||
@use_chat_lang()
|
||||
async def pusatfilm_s(self, message, strings):
|
||||
kueri = " ".join(message.command[1:])
|
||||
if not kueri:
|
||||
kueri = ""
|
||||
pesan = await message.reply_msg(strings("get_data"), quote=True)
|
||||
CurrentPage = 1
|
||||
pfres, PageLen, btn = await getDataPusatFilm(
|
||||
pesan, kueri, CurrentPage, message.from_user.id, strings
|
||||
)
|
||||
if not pfres:
|
||||
return
|
||||
keyboard = InlineKeyboard()
|
||||
keyboard.paginate(
|
||||
PageLen,
|
||||
CurrentPage,
|
||||
"page_pf#{number}" + f"#{pesan.id}#{message.from_user.id}",
|
||||
)
|
||||
keyboard.row(InlineButton(strings("ex_data"), user_id=self.me.id))
|
||||
keyboard.row(*btn)
|
||||
keyboard.row(InlineButton(strings("cl_btn"), f"close#{message.from_user.id}"))
|
||||
await pesan.edit_msg(
|
||||
pfres, disable_web_page_preview=True, reply_markup=keyboard
|
||||
)
|
||||
|
||||
|
||||
# DutaMovie CMD
|
||||
@app.on_cmd("dutamovie", no_channel=True)
|
||||
@use_chat_lang()
|
||||
|
|
@ -1170,6 +1255,93 @@ async def sf21page_callback(self, callback_query, strings):
|
|||
dutares, disable_web_page_preview=True, reply_markup=keyboard
|
||||
)
|
||||
|
||||
# NunaDrama Page Callback
|
||||
@app.on_cb("page_nuna#")
|
||||
@use_chat_lang()
|
||||
async def sf21page_callback(self, callback_query, strings):
|
||||
try:
|
||||
if callback_query.from_user.id != int(callback_query.data.split("#")[3]):
|
||||
return await callback_query.answer(strings("unauth"), True)
|
||||
message_id = int(callback_query.data.split("#")[2])
|
||||
CurrentPage = int(callback_query.data.split("#")[1])
|
||||
kueri = SCRAP_DICT[message_id][1]
|
||||
except (IndexError, ValueError): # Gatau napa err ini
|
||||
return
|
||||
except KeyError:
|
||||
return await callback_query.message.edit_msg(strings("invalid_cb"))
|
||||
except QueryIdInvalid:
|
||||
return
|
||||
|
||||
try:
|
||||
nunares, PageLen, btn = await getDataNunaDrama(
|
||||
callback_query.message,
|
||||
kueri,
|
||||
CurrentPage,
|
||||
callback_query.from_user.id,
|
||||
strings,
|
||||
)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
keyboard = InlineKeyboard()
|
||||
keyboard.paginate(
|
||||
PageLen,
|
||||
CurrentPage,
|
||||
"page_nuna#{number}" + f"#{message_id}#{callback_query.from_user.id}",
|
||||
)
|
||||
keyboard.row(InlineButton(strings("ex_data"), user_id=self.me.id))
|
||||
keyboard.row(*btn)
|
||||
keyboard.row(
|
||||
InlineButton(strings("cl_btn"), f"close#{callback_query.from_user.id}")
|
||||
)
|
||||
await callback_query.message.edit_msg(
|
||||
nunares, disable_web_page_preview=True, reply_markup=keyboard
|
||||
)
|
||||
|
||||
|
||||
# PusatFilm Page Callback
|
||||
@app.on_cb("page_pf#")
|
||||
@use_chat_lang()
|
||||
async def pfpage_callback(self, callback_query, strings):
|
||||
try:
|
||||
if callback_query.from_user.id != int(callback_query.data.split("#")[3]):
|
||||
return await callback_query.answer(strings("unauth"), True)
|
||||
message_id = int(callback_query.data.split("#")[2])
|
||||
CurrentPage = int(callback_query.data.split("#")[1])
|
||||
kueri = SCRAP_DICT[message_id][1]
|
||||
except (IndexError, ValueError):
|
||||
return
|
||||
except KeyError:
|
||||
return await callback_query.message.edit_msg(strings("invalid_cb"))
|
||||
except QueryIdInvalid:
|
||||
return
|
||||
|
||||
try:
|
||||
pfres, PageLen, btn = await getDataDutaMovie(
|
||||
callback_query.message,
|
||||
kueri,
|
||||
CurrentPage,
|
||||
callback_query.from_user.id,
|
||||
strings,
|
||||
)
|
||||
except TypeError:
|
||||
return
|
||||
|
||||
keyboard = InlineKeyboard()
|
||||
keyboard.paginate(
|
||||
PageLen,
|
||||
CurrentPage,
|
||||
"page_pf#{number}" + f"#{message_id}#{callback_query.from_user.id}",
|
||||
)
|
||||
keyboard.row(InlineButton(strings("ex_data"), user_id=self.me.id))
|
||||
keyboard.row(*btn)
|
||||
keyboard.row(
|
||||
InlineButton(strings("cl_btn"), f"close#{callback_query.from_user.id}")
|
||||
)
|
||||
await callback_query.message.edit_msg(
|
||||
pfres, disable_web_page_preview=True, reply_markup=keyboard
|
||||
)
|
||||
|
||||
|
||||
# NoDrakor Page Callback
|
||||
@app.on_cb("page_nodrakor#")
|
||||
|
|
@ -1697,6 +1869,51 @@ async def nunadrama_ddl(_, callback_query, strings):
|
|||
)
|
||||
|
||||
|
||||
# PusatFilm21 DDL
|
||||
@app.on_cb("pfextract#")
|
||||
@use_chat_lang()
|
||||
async def pusatfilm_ddl(_, callback_query, strings):
|
||||
try:
|
||||
if callback_query.from_user.id != int(callback_query.data.split("#")[3]):
|
||||
return await callback_query.answer(strings("unauth"), True)
|
||||
idlink = int(callback_query.data.split("#")[2])
|
||||
message_id = int(callback_query.data.split("#")[4])
|
||||
CurrentPage = int(callback_query.data.split("#")[1])
|
||||
link = SCRAP_DICT[message_id][0][CurrentPage - 1][idlink - 1].get("link")
|
||||
except QueryIdInvalid:
|
||||
return
|
||||
except KeyError:
|
||||
return await callback_query.message.edit_msg(strings("invalid_cb"))
|
||||
|
||||
keyboard = InlineKeyboard()
|
||||
keyboard.row(
|
||||
InlineButton(
|
||||
strings("back_btn"),
|
||||
f"page_pf#{CurrentPage}#{message_id}#{callback_query.from_user.id}",
|
||||
),
|
||||
InlineButton(strings("cl_btn"), f"close#{callback_query.from_user.id}"),
|
||||
)
|
||||
with contextlib.redirect_stdout(sys.stderr):
|
||||
try:
|
||||
html = await fetch.get(link)
|
||||
html.raise_for_status()
|
||||
soup = BeautifulSoup(html.text, "lxml")
|
||||
ddl = soup.find("li", {"pull-right"}).find("a").get("href")
|
||||
res = f"<b>Link Download:</b> {ddl}"
|
||||
await callback_query.message.edit_msg(
|
||||
strings("res_scrape").format(link=link, kl=res), reply_markup=keyboard
|
||||
)
|
||||
except httpx.HTTPError as exc:
|
||||
await callback_query.message.edit_msg(
|
||||
f"HTTP Exception for {exc.request.url} - <code>{exc}</code>",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
except Exception as err:
|
||||
await callback_query.message.edit_msg(
|
||||
f"ERROR: {err}", reply_markup=keyboard
|
||||
)
|
||||
|
||||
|
||||
# DutaMovie DDL
|
||||
@app.on_cb("dutaextract#")
|
||||
@use_chat_lang()
|
||||
|
|
|
|||
Loading…
Reference in a new issue