This commit is contained in:
yasir 2023-01-11 14:45:37 +07:00
parent 7fb8c86add
commit 1285b40d50
2 changed files with 111 additions and 72 deletions

View file

@ -24,78 +24,6 @@ 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"}
@app.on_message(filters.command(["zonafilm"], COMMAND_HANDLER))
@capture_err
async def zonafilm(_, msg):
m = await msg.reply("**__⏳ Please wait, scraping data ...__**", True)
try:
title = msg.text.split(" ", 1)[1]
except IndexError:
title = ""
try:
html = await http.get(f"https://zonafilm.icu/?s={title}", headers=headers)
text = BeautifulSoup(html.text, "lxml")
entry = text.find_all(class_="entry-header")
if "Nothing Found" in entry[0].text:
await m.delete()
if not title:
await msg.reply("404 Not FOUND!", True)
else:
await msg.reply(f"404 Not FOUND For: {title}", True)
return
data = []
for i in entry:
genre = i.find(class_="gmr-movie-on").text
genre = f"{genre}" 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})
head = f"<b>#Zonafilm Results For:</b> <code>{title}</code>\n\n" if title else f"<b>#Zonafilm Latest:</b>\n🌀 Use /{msg.command[0]} [title] to start search with title.\n\n"
msgs = ""
await m.delete()
for c, i in enumerate(data, start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Genre:</b> <code>{i['genre']}</code>\n"
msgs += f"<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n" if "/tv/" not in i["link"] else "\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:
LOGGER.error(e)
await m.delete()
await msg.reply(f"ERROR: <code>{e}</code>", True)
@app.on_message(filters.command(["nodrakor"], COMMAND_HANDLER))
@capture_err
async def nodrakor(_, msg):

View file

@ -148,6 +148,39 @@ async def getDataMelong(msg, kueri, CurrentPage):
except (IndexError, KeyError):
await msg.edit("Sorry could not find any matching results!")
# Zonafilm GetData
async def getDataZonafilm(msg, kueri, CurrentPage):
if not SCRAP_DICT.get(msg.id):
zonafilm = await http.get(f'https://zonafilm.icu/?s={kueri}', headers=headers)
text = BeautifulSoup(zonafilm.text, "lxml")
entry = text.find_all(class_="entry-header")
if "Nothing Found" in entry[0].text:
if not kueri:
return await msg.edit("404 Not FOUND!")
else:
return await msg.edit(f"404 Not FOUND For: {kueri}")
data = []
for i in entry:
genre = i.find(class_="gmr-movie-on").text
genre = f"{genre}" 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[msg.id] = [split_arr(data, 6), kueri]
try:
index = int(CurrentPage - 1)
PageLen = len(SCRAP_DICT[msg.id][0])
ZonafilmResult = f"<b>#Zonafilm Results For:</b> <code>{kueri}</code>\n\n" if kueri else f"<b>#Zonafilm Latest:</b>\n🌀 Use /zonafilm [title] to start search with title.\n\n"
for c, i in enumerate(SCRAP_DICT[msg.id][0][index], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Genre:</b> <code>{i['genre']}</code>\n"
msgs += f"<b>Extract:</b> <code>/zonafilm_scrap {i['link']}</code>\n\n" if "/tv/" not in i["link"] else "\n"
IGNORE_CHAR = "[]"
ZonafilmResult = ''.join(i for i in ZonafilmResult if not i in IGNORE_CHAR)
return ZonafilmResult, PageLen
except (IndexError, KeyError):
await msg.edit("Sorry could not find any matching results!")
# GoMov GetData
async def getDataGomov(msg, kueri, CurrentPage):
if not SCRAP_DICT.get(msg.id):
@ -247,6 +280,38 @@ async def gomov_s(client, message):
)
await editPesan(pesan, gomovres, reply_markup=keyboard)
# Zonafilm CMD
@app.on_message(filters.command(['zonafilm'], COMMAND_HANDLER))
async def zonafilm_s(client, message):
kueri = ' '.join(message.command[1:])
if not kueri:
kueri = ""
pesan = await message.reply("Getting data from Zonafilm Web..")
CurrentPage = 1
zonafilmres, PageLen = await getDataZonafilm(pesan, kueri, CurrentPage)
keyboard = InlineKeyboard()
keyboard.paginate(PageLen, CurrentPage, 'page_zonafilm#{number}' + f'#{pesan.id}#{message.from_user.id}')
keyboard.row(
InlineButton("❌ Close", f"close#{message.from_user.id}")
)
await editPesan(pesan, zonafilmres, reply_markup=keyboard)
# MelongMovie CMD
@app.on_message(filters.command(['melongmovie'], COMMAND_HANDLER))
async def melong_s(client, message):
kueri = ' '.join(message.command[1:])
if not kueri:
kueri = ""
pesan = await message.reply("Getting data from Gomov Web..")
CurrentPage = 1
melongres, PageLen = await getDataMelong(pesan, kueri, CurrentPage)
keyboard = InlineKeyboard()
keyboard.paginate(PageLen, CurrentPage, 'page_melong#{number}' + f'#{pesan.id}#{message.from_user.id}')
keyboard.row(
InlineButton("❌ Close", f"close#{message.from_user.id}")
)
await editPesan(pesan, melongres, reply_markup=keyboard)
# Terbit21 Page Callback
@app.on_callback_query(filters.create(lambda _, __, query: 'page_terbit21#' in query.data))
async def terbit21page_callback(client, callback_query):
@ -271,6 +336,29 @@ async def terbit21page_callback(client, callback_query):
)
await editPesan(callback_query.message, terbitres, reply_markup=keyboard)
@app.on_callback_query(filters.create(lambda _, __, query: 'page_melong#' in query.data))
async def melongpage_callback(client, callback_query):
if callback_query.from_user.id != int(callback_query.data.split('#')[3]):
return await callback_query.answer("Not yours..", True)
message_id = int(callback_query.data.split('#')[2])
CurrentPage = int(callback_query.data.split('#')[1])
try:
kueri = SCRAP_DICT[message_id][1]
except KeyError:
return await callback_query.answer("Invalid callback data, please send CMD again..")
try:
terbitres, PageLen = await getDataMelong(callback_query.message, kueri, CurrentPage)
except TypeError:
return
keyboard = InlineKeyboard()
keyboard.paginate(PageLen, CurrentPage, 'page_melong#{number}' + f'#{message_id}#{callback_query.from_user.id}')
keyboard.row(
InlineButton("❌ Close", f"close#{callback_query.from_user.id}")
)
await editPesan(callback_query.message, terbitres, reply_markup=keyboard)
# Lk21 Page Callback
@app.on_callback_query(filters.create(lambda _, __, query: 'page_lk21#' in query.data))
async def lk21page_callback(client, callback_query):
@ -343,6 +431,29 @@ async def gomovpage_callback(client, callback_query):
)
await editPesan(callback_query.message, gomovres, reply_markup=keyboard)
@app.on_callback_query(filters.create(lambda _, __, query: 'page_zonafilm#' in query.data))
async def zonafilmpage_callback(client, callback_query):
if callback_query.from_user.id != int(callback_query.data.split('#')[3]):
return await callback_query.answer("Not yours..", True)
message_id = int(callback_query.data.split('#')[2])
CurrentPage = int(callback_query.data.split('#')[1])
try:
kueri = SCRAP_DICT[message_id][1]
except KeyError:
return await callback_query.answer("Invalid callback data, please send CMD again..")
try:
zonafilmres, PageLen = await getDataZonafilm(callback_query.message, kueri, CurrentPage)
except TypeError:
return
keyboard = InlineKeyboard()
keyboard.paginate(PageLen, CurrentPage, 'page_gomov#{number}' + f'#{message_id}#{callback_query.from_user.id}')
keyboard.row(
InlineButton("❌ Close", f"close#{callback_query.from_user.id}")
)
await editPesan(callback_query.message, zonafilmres, reply_markup=keyboard)
### Scrape DDL Link From Web ###
# Savefilm21 DDL