mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-03 11:04:51 +00:00
fix
This commit is contained in:
parent
a974582316
commit
c9feae5e7a
2 changed files with 75 additions and 85 deletions
|
|
@ -19,19 +19,6 @@ from misskaty.core.decorator.errors import capture_err
|
||||||
from misskaty.helper.http import http
|
from misskaty.helper.http import http
|
||||||
from misskaty.vars import COMMAND_HANDLER
|
from misskaty.vars import COMMAND_HANDLER
|
||||||
|
|
||||||
__MODULE__ = "WebScraper"
|
|
||||||
__HELP__ = """
|
|
||||||
/melongmovie - Scrape website data from MelongMovie Web. If without query will give latest movie list.
|
|
||||||
/lk21 [query <optional>] - Scrape website data from LayarKaca21. If without query will give latest movie list.
|
|
||||||
/pahe [query <optional>] - Scrape website data from Pahe.li. If without query will give latest post list.
|
|
||||||
/terbit21 [query <optional>] - Scrape website data from Terbit21. If without query will give latest movie list.
|
|
||||||
/savefilm21 [query <optional>] - Scrape website data from Savefilm21. If without query will give latest movie list.
|
|
||||||
/movieku [query <optional>] - Scrape website data from Movieku.cc
|
|
||||||
/nodrakor [query] - Scrape website data from nodrakor.icu
|
|
||||||
/zonafilm [query] - Scrape website data from zonafilm.icu
|
|
||||||
/gomov [query <optional>] - Scrape website data from GoMov. If without query will give latest movie list.
|
|
||||||
"""
|
|
||||||
|
|
||||||
LOGGER = getLogger(__name__)
|
LOGGER = getLogger(__name__)
|
||||||
|
|
||||||
headers = {"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"}
|
headers = {"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"}
|
||||||
|
|
@ -532,63 +519,6 @@ async def melongmovie(_, msg):
|
||||||
LOGGER.error(e)
|
LOGGER.error(e)
|
||||||
await msg.reply(str(e), True)
|
await msg.reply(str(e), True)
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command(["pahe"], COMMAND_HANDLER))
|
|
||||||
@capture_err
|
|
||||||
async def pahe_scrap(_, msg):
|
|
||||||
title = msg.text.split(" ", 1)[1] if len(msg.command) > 1 else ""
|
|
||||||
m = await msg.reply("**__⏳ Please wait, scraping data..__**", True)
|
|
||||||
try:
|
|
||||||
api = await http.get(f"https://yasirapi.eu.org/pahe?q={title}")
|
|
||||||
res = api.json()
|
|
||||||
if not res["result"]:
|
|
||||||
await m.delete()
|
|
||||||
return await msg.reply("404 Result not FOUND!", True)
|
|
||||||
head = f"<b>#Pahe Results For:</b> <code>{title}</code>\n\n" if title else f"<b>#Pahe Latest:</b>\n🌀 Use /{msg.command[0]} [title] to start search with title.\n\n"
|
|
||||||
await m.delete()
|
|
||||||
msgs = ""
|
|
||||||
for c, i in enumerate(res["result"], start=1):
|
|
||||||
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n\n"
|
|
||||||
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
|
|
||||||
await msg.reply(
|
|
||||||
head + msgs,
|
|
||||||
True,
|
|
||||||
disable_web_page_preview=True,
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
text="❌ Close",
|
|
||||||
callback_data=f"close#{msg.from_user.id}",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
await asyncio.sleep(2)
|
|
||||||
msgs = ""
|
|
||||||
if msgs != "":
|
|
||||||
await msg.reply(
|
|
||||||
head + msgs,
|
|
||||||
True,
|
|
||||||
disable_web_page_preview=True,
|
|
||||||
reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(
|
|
||||||
text="❌ Close",
|
|
||||||
callback_data=f"close#{msg.from_user.id}",
|
|
||||||
)
|
|
||||||
]
|
|
||||||
]
|
|
||||||
),
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
await m.delete()
|
|
||||||
LOGGER.error(e)
|
|
||||||
await msg.reply(f"ERROR: {e}", True)
|
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command(["gomov"], COMMAND_HANDLER))
|
@app.on_message(filters.command(["gomov"], COMMAND_HANDLER))
|
||||||
@capture_err
|
@capture_err
|
||||||
async def gomov_scrap(_, msg):
|
async def gomov_scrap(_, msg):
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,23 @@ from misskaty import app
|
||||||
from misskaty.vars import COMMAND_HANDLER
|
from misskaty.vars import COMMAND_HANDLER
|
||||||
from misskaty.core.message_utils import *
|
from misskaty.core.message_utils import *
|
||||||
|
|
||||||
|
__MODULE__ = "WebScraper"
|
||||||
|
__HELP__ = """
|
||||||
|
/melongmovie - Scrape website data from MelongMovie Web. If without query will give latest movie list.
|
||||||
|
/lk21 [query <optional>] - Scrape website data from LayarKaca21. If without query will give latest movie list.
|
||||||
|
/pahe [query <optional>] - Scrape website data from Pahe.li. If without query will give latest post list.
|
||||||
|
/terbit21 [query <optional>] - Scrape website data from Terbit21. If without query will give latest movie list.
|
||||||
|
/savefilm21 [query <optional>] - Scrape website data from Savefilm21. If without query will give latest movie list.
|
||||||
|
/movieku [query <optional>] - Scrape website data from Movieku.cc
|
||||||
|
/nodrakor [query] - Scrape website data from nodrakor.icu
|
||||||
|
/zonafilm [query] - Scrape website data from zonafilm.icu
|
||||||
|
/gomov [query <optional>] - Scrape website data from GoMov. If without query will give latest movie list.
|
||||||
|
"""
|
||||||
|
|
||||||
|
headers = {"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"}
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
LKTERBIT_DICT = {}
|
PTL_DICT = {} # Dict for Pahe, Terbit21, LK21
|
||||||
|
|
||||||
def split_arr(arr, size):
|
def split_arr(arr, size):
|
||||||
arrs = []
|
arrs = []
|
||||||
|
|
@ -28,7 +43,7 @@ def split_arr(arr, size):
|
||||||
|
|
||||||
# Terbit21 GetData
|
# Terbit21 GetData
|
||||||
async def getDataTerbit21(chat_id, message_id, kueri, CurrentPage):
|
async def getDataTerbit21(chat_id, message_id, kueri, CurrentPage):
|
||||||
if not LKTERBIT_DICT.get(message_id):
|
if not PTL_DICT.get(message_id):
|
||||||
if not kueri:
|
if not kueri:
|
||||||
terbitjson = (await http.get('https://yasirapi.eu.org/terbit21')).json()
|
terbitjson = (await http.get('https://yasirapi.eu.org/terbit21')).json()
|
||||||
else:
|
else:
|
||||||
|
|
@ -39,20 +54,20 @@ async def getDataTerbit21(chat_id, message_id, kueri, CurrentPage):
|
||||||
reply_to_message_id=message_id,
|
reply_to_message_id=message_id,
|
||||||
text="Sorry, could not find any results!"
|
text="Sorry, could not find any results!"
|
||||||
)
|
)
|
||||||
LKTERBIT_DICT[message_id] = [split_arr(terbitjson["result"], 6), kueri]
|
PTL_DICT[message_id] = [split_arr(terbitjson["result"], 6), kueri]
|
||||||
try:
|
try:
|
||||||
index = int(CurrentPage - 1)
|
index = int(CurrentPage - 1)
|
||||||
PageLen = len(LKTERBIT_DICT[message_id][0])
|
PageLen = len(PTL_DICT[message_id][0])
|
||||||
|
|
||||||
if kueri:
|
if kueri:
|
||||||
TerbitRes = f"<b>#Terbit21 Results For:</b> <code>{kueri}</code>\n\n"
|
TerbitRes = f"<b>#Terbit21 Results For:</b> <code>{kueri}</code>\n\n"
|
||||||
else:
|
else:
|
||||||
TerbitRes = "<b>#Terbit21 Latest:</b>\n🌀 Use /terbit21 [title] to start search with title.\n\n"
|
TerbitRes = "<b>#Terbit21 Latest:</b>\n🌀 Use /terbit21 [title] to start search with title.\n\n"
|
||||||
for c, i in enumerate(LKTERBIT_DICT[message_id][0][index], start=1):
|
for c, i in enumerate(PTL_DICT[message_id][0][index], start=1):
|
||||||
TerbitRes += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
TerbitRes += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
||||||
TerbitRes += "\n" if re.search(r"Complete|Ongoing", i["kategori"]) else f"💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
|
TerbitRes += "\n" if re.search(r"Complete|Ongoing", i["kategori"]) else f"💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
|
||||||
INGNORE_CHAR = "[]"
|
IGNORE_CHAR = "[]"
|
||||||
TerbitRes = ''.join(i for i in TerbitRes if not i in INGNORE_CHAR)
|
TerbitRes = ''.join(i for i in TerbitRes if not i in IGNORE_CHAR)
|
||||||
return TerbitRes, PageLen
|
return TerbitRes, PageLen
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
|
|
@ -63,7 +78,7 @@ async def getDataTerbit21(chat_id, message_id, kueri, CurrentPage):
|
||||||
|
|
||||||
# LK21 GetData
|
# LK21 GetData
|
||||||
async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
||||||
if not LKTERBIT_DICT.get(message_id):
|
if not PTL_DICT.get(message_id):
|
||||||
if not kueri:
|
if not kueri:
|
||||||
lk21json = (await http.get('https://yasirapi.eu.org/lk21')).json()
|
lk21json = (await http.get('https://yasirapi.eu.org/lk21')).json()
|
||||||
else:
|
else:
|
||||||
|
|
@ -74,20 +89,20 @@ async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
||||||
reply_to_message_id=message_id,
|
reply_to_message_id=message_id,
|
||||||
text="Sorry could not find any matching results!"
|
text="Sorry could not find any matching results!"
|
||||||
)
|
)
|
||||||
LKTERBIT_DICT[message_id] = [split_arr(lk21json["result"], 6), kueri]
|
PTL_DICT[message_id] = [split_arr(lk21json["result"], 6), kueri]
|
||||||
try:
|
try:
|
||||||
index = int(CurrentPage - 1)
|
index = int(CurrentPage - 1)
|
||||||
PageLen = len(LKTERBIT_DICT[message_id][0])
|
PageLen = len(PTL_DICT[message_id][0])
|
||||||
|
|
||||||
if kueri:
|
if kueri:
|
||||||
lkResult = f"<b>#Layarkaca21 Results For:</b> <code>{kueri}</code>\n\n"
|
lkResult = f"<b>#Layarkaca21 Results For:</b> <code>{kueri}</code>\n\n"
|
||||||
else:
|
else:
|
||||||
lkResult = "<b>#Layarkaca21 Latest:</b>\n🌀 Use /lk21 [title] to start search with title.\n\n"
|
lkResult = "<b>#Layarkaca21 Latest:</b>\n🌀 Use /lk21 [title] to start search with title.\n\n"
|
||||||
for c, i in enumerate(LKTERBIT_DICT[message_id][0][index], start=1):
|
for c, i in enumerate(PTL_DICT[message_id][0][index], start=1):
|
||||||
lkResult += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
lkResult += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n"
|
||||||
lkResult += "\n" if re.search(r"Complete|Ongoing", i["kategori"]) else f"💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
|
lkResult += "\n" if re.search(r"Complete|Ongoing", i["kategori"]) else f"💠 <b><a href='{i['dl']}'>Download</a></b>\n\n"
|
||||||
INGNORE_CHAR = "[]"
|
IGNORE_CHAR = "[]"
|
||||||
lkResult = ''.join(i for i in lkResult if not i in INGNORE_CHAR)
|
lkResult = ''.join(i for i in lkResult if not i in IGNORE_CHAR)
|
||||||
return lkResult, PageLen
|
return lkResult, PageLen
|
||||||
except (IndexError, KeyError):
|
except (IndexError, KeyError):
|
||||||
await app.send_message(
|
await app.send_message(
|
||||||
|
|
@ -96,6 +111,34 @@ async def getDatalk21(chat_id, message_id, kueri, CurrentPage):
|
||||||
text="Sorry could not find any matching results!"
|
text="Sorry could not find any matching results!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Pahe GetData
|
||||||
|
async def getDataPahe(chat_id, message_id, kueri, CurrentPage):
|
||||||
|
if not PTL_DICT.get(message_id):
|
||||||
|
pahejson = (await http.get(f'https://yasirapi.eu.org/pahe?q={kueri}')).json()
|
||||||
|
if not pahejson.get("result"):
|
||||||
|
return await app.send_message(
|
||||||
|
chat_id=chat_id,
|
||||||
|
reply_to_message_id=message_id,
|
||||||
|
text="Sorry could not find any matching results!"
|
||||||
|
)
|
||||||
|
PTL_DICT[message_id] = [split_arr(pahejson["result"], 6), kueri]
|
||||||
|
try:
|
||||||
|
index = int(CurrentPage - 1)
|
||||||
|
PageLen = len(PTL_DICT[message_id][0])
|
||||||
|
|
||||||
|
paheResult = f"<b>#Pahe Results For:</b> <code>{kueri}</code>\n\n" if kueri else f"<b>#Pahe Latest:</b>\n🌀 Use /pahe [title] to start search with title.\n\n"
|
||||||
|
for c, i in enumerate(PTL_DICT[message_id][0][index], start=1):
|
||||||
|
paheResult += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n\n"
|
||||||
|
IGNORE_CHAR = "[]"
|
||||||
|
paheResult = ''.join(i for i in paheResult if not i in IGNORE_CHAR)
|
||||||
|
return paheResult, PageLen
|
||||||
|
except (IndexError, KeyError):
|
||||||
|
await app.send_message(
|
||||||
|
chat_id=chat_id,
|
||||||
|
reply_to_message_id=message_id,
|
||||||
|
text="Sorry could not find any matching results!"
|
||||||
|
)
|
||||||
|
|
||||||
# Terbit21 CMD
|
# Terbit21 CMD
|
||||||
@app.on_message(filters.command(['terbit21'], COMMAND_HANDLER))
|
@app.on_message(filters.command(['terbit21'], COMMAND_HANDLER))
|
||||||
async def terbit21_s(client, message):
|
async def terbit21_s(client, message):
|
||||||
|
|
@ -130,6 +173,23 @@ async def lk21_s(client, message):
|
||||||
)
|
)
|
||||||
await editPesan(pesan, lkres, reply_markup=keyboard)
|
await editPesan(pesan, lkres, reply_markup=keyboard)
|
||||||
|
|
||||||
|
# Pahe CMD
|
||||||
|
@app.on_message(filters.command(['pahe'], COMMAND_HANDLER))
|
||||||
|
async def pahe_s(client, message):
|
||||||
|
chat_id = message.chat.id
|
||||||
|
kueri = ' '.join(message.command[1:])
|
||||||
|
if not kueri:
|
||||||
|
kueri = ""
|
||||||
|
pesan = await message.reply("Getting data from Pahe Web..")
|
||||||
|
CurrentPage = 1
|
||||||
|
paheres, PageLen = await getDataPahe(chat_id, pesan.id, kueri, CurrentPage)
|
||||||
|
keyboard = InlineKeyboard()
|
||||||
|
keyboard.paginate(PageLen, CurrentPage, 'page_pahe#{number}' + f'#{pesan.id}#{message.from_user.id}')
|
||||||
|
keyboard.row(
|
||||||
|
InlineButton("❌ Close", f"close#{message.from_user.id}")
|
||||||
|
)
|
||||||
|
await editPesan(pesan, paheres, reply_markup=keyboard)
|
||||||
|
|
||||||
# Lk21 Page Callback
|
# Lk21 Page Callback
|
||||||
@app.on_callback_query(filters.create(lambda _, __, query: 'page_terbit21#' in query.data))
|
@app.on_callback_query(filters.create(lambda _, __, query: 'page_terbit21#' in query.data))
|
||||||
async def terbit21page_callback(client, callback_query):
|
async def terbit21page_callback(client, callback_query):
|
||||||
|
|
@ -139,7 +199,7 @@ async def terbit21page_callback(client, callback_query):
|
||||||
chat_id = callback_query.message.chat.id
|
chat_id = callback_query.message.chat.id
|
||||||
CurrentPage = int(callback_query.data.split('#')[1])
|
CurrentPage = int(callback_query.data.split('#')[1])
|
||||||
try:
|
try:
|
||||||
kueri = LKTERBIT_DICT[message_id][1]
|
kueri = PTL_DICT[message_id][1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return await callback_query.answer("Invalid callback data, please send CMD again..")
|
return await callback_query.answer("Invalid callback data, please send CMD again..")
|
||||||
|
|
||||||
|
|
@ -164,7 +224,7 @@ async def lk21page_callback(client, callback_query):
|
||||||
chat_id = callback_query.message.chat.id
|
chat_id = callback_query.message.chat.id
|
||||||
CurrentPage = int(callback_query.data.split('#')[1])
|
CurrentPage = int(callback_query.data.split('#')[1])
|
||||||
try:
|
try:
|
||||||
kueri = LKTERBIT_DICT[message_id][1]
|
kueri = PTL_DICT[message_id][1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return await callback_query.answer("Invalid callback data, please send CMD again..")
|
return await callback_query.answer("Invalid callback data, please send CMD again..")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue