rewrite scraper

This commit is contained in:
yasir 2023-01-03 21:56:20 +07:00
parent 75f403152b
commit f6185729a3
2 changed files with 388 additions and 211 deletions

View file

@ -6,16 +6,16 @@
* Copyright @YasirPedia All rights reserved * Copyright @YasirPedia All rights reserved
""" """
# This plugin to scrape from melongmovie, and lk21 # This plugin to scrape from melongmovie, lk21, pahe and many more
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import re import re
import traceback import asyncio
from logging import getLogger
from misskaty import app, BOT_USERNAME from misskaty import app, BOT_USERNAME
from pyrogram import filters from pyrogram import filters
from pyrogram.errors import MessageTooLong from pyrogram.errors import MessageTooLong
from misskaty.vars import COMMAND_HANDLER from misskaty.vars import COMMAND_HANDLER
from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.errors import capture_err
from misskaty.helper.tools import rentry
from misskaty.helper.http import http from misskaty.helper.http import http
__MODULE__ = "WebScraper" __MODULE__ = "WebScraper"
@ -29,6 +29,7 @@ __HELP__ = """
/gomov [query <optional>] - Scrape website data from GoMov. If without query will give latest movie list. /gomov [query <optional>] - Scrape website data from GoMov. If without query will give latest movie list.
""" """
LOGGER = getLogger(__name__)
# Broken # Broken
@app.on_message(filters.command(["nodrakor"], COMMAND_HANDLER)) @app.on_message(filters.command(["nodrakor"], COMMAND_HANDLER))
@ -99,253 +100,426 @@ async def ngefilm21(_, message):
# Scrape Web From Movieku.CC # Scrape Web From Movieku.CC
@app.on_message(filters.command(["movieku"], COMMAND_HANDLER)) @app.on_message(filters.command(["movieku"], COMMAND_HANDLER))
@capture_err @capture_err
async def movikucc(_, message): async def movikucc(_, msg):
if len(message.command) == 1: m = await msg.reply("**__⏳ Please wait, scraping data ...__**", True)
return await message.reply("Masukkan query yang akan dicari..!!") data = []
judul = message.text.split(" ", maxsplit=1)[1] if len(msg.command) == 1:
msg = await message.reply("Sedang proses scrap, mohon tunggu..") try:
try: html = await ambil_source(f"https://107.152.37.223/")
headers = { r = BeautifulSoup(html, "lxml")
"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" res = r.find_all(class_="bx")
} for i in res:
html = await http.get(f"https://107.152.39.187/?s={judul}", headers=headers) judul = i.find_all("a")[0]["title"]
soup = BeautifulSoup(html.text, "lxml") link = i.find_all("a")[0]["href"]
data = soup.find_all(class_="bx") data.append({"judul": judul, "link": link})
res = "".join( if not data:
f"<b>Judul: {i.find_all('a')[0]['title']}</b>\nLink: {i.find_all('a')[0]['href']}\n\n" await m.delete()
for i in data return await msg.reply("404 Result not FOUND!", True)
) await m.delete()
await msg.edit( head = f"<b>#Movieku Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
f"<b>Hasil Scrap di Movieku.cc:</b>\n{res} ⚠️ Gunakan command /movieku_scrap <b>[link]</b> untuk mengambil link download (hanya untuk movie)." msgs = ""
) for c, i in enumerate(data[:15], start=1):
except Exception as e: msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Extract:</b> <code>/{msg.commnd[0]}_scrap {i['link']}</code>\n\n"
await msg.edit(f"ERROR: {str(e)}") if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
except Exception as e:
LOGGER.error(e)
await m.delete()
await msg.reply(f"ERROR: {e}", True)
else:
title = msg.text.split(" ", 1)[1]
try:
html = await ambil_source(f"https://107.152.37.223/?s={title}")
r = BeautifulSoup(html, "lxml")
res = r.find_all(class_="bx")
for i in res:
judul = i.find_all("a")[0]["title"]
link = i.find_all("a")[0]["href"]
data.append({"judul": judul, "link": link})
if not data:
await m.delete()
return await msg.reply("404 Result not FOUND!", True)
await m.delete()
head = f"<b>#Movieku Results For:</b> <code>{title}</code>\n\n"
msgs = ""
for c, i in enumerate(data[:15], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
except Exception as e:
LOGGER.error(e)
await m.delete()
await msg.reply(f"ERROR: {e}", True)
@app.on_message(filters.command(["savefilm21"], COMMAND_HANDLER)) @app.on_message(filters.command(["savefilm21"], COMMAND_HANDLER))
@capture_err @capture_err
async def savefilm21(_, message): async def savefilm21(_, msg):
SITE = "http://185.99.135.215"
try: try:
judul = message.text.split(" ", maxsplit=1)[1] title = msg.text.split(" ", 1)[1]
except IndexError: except:
judul = "" title = None
msg = await message.reply("Sedang proses scrap, mohon tunggu..") m = await msg.reply("**__⏳ Please wait, scraping data...__**", True)
data = []
try: try:
headers = { if title is not None:
"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" html = await http.get(
} f"{SITE}/?s={title}", headers=headers, follow_redirects=False
)
html = await http.get( bs4 = BeautifulSoup(html.text, "lxml")
f"http://185.99.135.215/?s={judul}", headers=headers, follow_redirects=False res = bs4.find_all(class_="entry-title")
) for i in res:
soup = BeautifulSoup(html.text, "lxml") pas = i.find_all("a")
res = soup.find_all(class_="entry-title") judul = pas[0].text
data = [] link = pas[0]["href"]
for i in res: data.append({"judul": judul, "link": link})
pas = i.find_all("a") if not data:
judul = pas[0].text await m.delete()
link = pas[0]["href"] return await msg.reply("Result 404 Not found!", True)
data.append({"judul": judul, "link": link}) await m.delete()
if not data: head = f"<b>#SaveFilm21 Results For:</b> <code>{title}</code>\n\n"
return await msg.edit("Oops, data film tidak ditemukan") msgs = ""
res = "".join( for c, i in enumerate(data[:15], start=1):
f"<b>Judul: {i['judul']}</b>\nLink: {i['link']}\n\n" for i in data msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
) if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.edit( await msg.reply(
f"Hasil Scrap <code>{judul}</code> dari Savefilm21:\n{res}\n\n⚠️ Gunakan /savefilm21_scrap <b>[link]</b> untuk mengambil link downloadnya." head + msgs,
) True,
disable_web_page_preview=True,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
else:
html = await http.get(SITE, headers=headers, follow_redirects=False)
bs4 = BeautifulSoup(html.text, "lxml")
res = bs4.find_all(class_="entry-title")
for i in res:
pas = i.find_all("a")
judul = pas[0].text
link = pas[0]["href"]
data.append({"judul": judul, "link": link})
await m.delete()
head = f"<b>#SaveFilm21 Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
msgs = ""
for c, i in enumerate(data[:15], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Extract:</b> <code>/{savefilm21_scrap} {i['link']}</code>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
except Exception as e: except Exception as e:
await msg.edit(f"ERROR: {str(e)}") await m.delete()
LOGGER.error(e)
await msg.reply(f"ERROR: {e}", True)
@app.on_message(filters.command(["melongmovie"], COMMAND_HANDLER)) @app.on_message(filters.command(["melongmovie"], COMMAND_HANDLER))
@capture_err @capture_err
async def melongmovie(_, message): async def melongmovie(_, message):
SITE = "http://167.99.31.48"
try: try:
judul = message.text.split(" ", maxsplit=1)[1] judul = msg.text.split(" ", 1)[1]
except IndexError: except IndexError:
judul = "" judul = None
data = []
msg = await message.reply("Sedang proses scrap, mohon tunggu..") m = await msg.reply("**__⏳ Please wait, scraping data ...__**", True)
try: if judul is not None:
headers = { try:
"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" html = await http.get(f"{SITE}/?s={judul}", headers=headers)
} bs4 = BeautifulSoup(html.text, "lxml")
for res in bs4.select(".box"):
html = await http.get(f"http://167.99.31.48/?s={judul}", headers=headers) dd = res.select("a")
soup = BeautifulSoup(html.text, "lxml") url = dd[0]["href"]
data = [] title = dd[0]["title"]
for res in soup.select(".box"): try:
dd = res.select("a") quality = dd[0].find(class_="quality").text
url = dd[0]["href"] except:
title = dd[0]["title"] quality = "N/A"
try: data.append({"judul": title, "link": url, "quality": quality})
kualitas = dd[0].find(class_="quality").text if not data:
except: await m.delete()
kualitas = "" return await msg.reply("404 Not found!", True)
data.append({"judul": title, "link": url, "kualitas": kualitas}) await m.delete()
if not data: head = f"<b>#MelongMovie Results For:</b> <code>{judul}</code>\n\n"
return await msg.edit("Oops, data film tidak ditemukan di melongmovie") msgs = ""
res = "".join( for c, i in enumerate(data[:15], start=1):
f"<b>Judul: {i['judul']}</b>\n<b>Kualitas:</b> {i['kualitas']}\n<b>Link</b>: {i['link']}\n\n" msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Quality:</b> {i['quality']}\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
for i in data if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
) await msg.reply(head + msgs, True, disable_web_page_preview=True)
# return await message.reply(json.dumps(data, indent=2, ensure_ascii=False)) await asyncio.sleep(2)
return await msg.edit(res) msgs = ""
except Exception as e: if msgs != "":
await msg.edit(f"ERROR: {str(e)}") await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
await m.delete()
LOGGER.error(e)
await msg.reply(str(e), True)
else:
try:
html = await http.get(SITE, headers=headers)
bs4 = BeautifulSoup(html.text, "lxml")
for res in bs4.select(".box"):
dd = res.select("a")
url = dd[0]["href"]
title = dd[0]["title"]
try:
quality = dd[0].find(class_="quality").text
except:
quality = "N/A"
data.append({"judul": title, "link": url, "quality": quality})
if not data:
await m.delete()
return await msg.reply("404 Not found!", True)
await m.delete()
head = f"<b>#MelongMovie Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
msgs = ""
for c, i in enumerate(data[:15], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Quality:</b> {i['quality']}\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.reply(head + msgs, True, disable_web_page_preview=True)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
await m.delete()
LOGGER.error(e)
await msg.reply(str(e), True)
@app.on_message(filters.command(["pahe"], COMMAND_HANDLER)) @app.on_message(filters.command(["pahe"], COMMAND_HANDLER))
@capture_err @capture_err
async def pahe_scrap(_, message): async def pahe_scrap(_, msg):
judul = message.text.split(" ", maxsplit=1)[1] if len(message.command) > 1 else "" title = msg.text.split(" ", 1)[1] if len(msg.command) > 1 else ""
pesan = await message.reply("Please wait, scraping data..") m = await msg.reply("**__⏳ Please wait, scraping data..__**", True)
r = await http.get(f"https://yasirapi.eu.org/pahe?q={judul}")
res = r.json()
if not res["result"]:
return await pesan.edit("Yahh, no result found.")
data = "".join(
f"**{count}. {i['judul']}**\n{i['link']}\n\n"
for count, i in enumerate(res["result"], start=1)
)
try: try:
await pesan.edit( api = await http.get(f"https://yasirapi.eu.org/pahe?q={title}")
f"**Daftar rilis movie terbaru di web Pahe**:\n{data}", res = api.json()
disable_web_page_preview=True, if not res["result"]:
) await m.delete()
except MessageTooLong: return await m.reply("Result 404 Not found!", True)
msg = await rentry(data) head = (
await pesan.edit( f"<b>#Pahe Results For:</b> <code>{title}</code>\n\n"
f"Karena hasil scrape terlalu panjang, maka hasil scrape di post ke rentry.\n\n{msg}" if title
else f"<b>#Pahe Latest:</b>\n--> Use /{message.command[0]} [title] to start search with title.\n\n"
) )
await m.delete()
msgs = ""
for c, i in enumerate(res["result"][:15], 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,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
await m.delete()
LOGGER.error(e)
await msg.reply(f"ERROR: {e}", True)
@app.on_message(filters.command(["terbit21"], COMMAND_HANDLER)) @app.on_message(filters.command(["terbit21"], COMMAND_HANDLER))
@capture_err @capture_err
async def terbit21_scrap(_, message): async def terbit21_scrap(_, message):
if len(message.command) == 1: m = await msg.reply("**__Checking data list ...__**", True)
r = await http.get("https://yasirapi.eu.org/terbit21") if len(msg.command) == 1:
res = r.json()
data = "".join(
f"**Judul: {i['judul']}**\n`{i['kategori']}`\n{i['link']}\n**Download:** [Klik Disini]({i['dl']})\n\n"
for i in res["result"]
)
try: try:
return await message.reply( r = await http.get("https://yasirapi.eu.org/terbit21")
f"**Daftar rilis movie terbaru di web Terbit21**:\n{data}", res = r.json()
disable_web_page_preview=True, if not res["result"]:
) await m.delete()
except MessageTooLong: return await msg.reply("404 Result not FOUND!", True)
msg = await rentry(data) await m.delete()
return await message.reply( head = f"<b>#Terbit21 Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
f"Karena hasil scrape terlalu panjang, maka hasil scrape di post ke rentry.\n\n{msg}" msgs = ""
) for c, i in enumerate(res["result"][:15], start=1):
judul = message.text.split(" ", maxsplit=1)[1] msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n--> <b><a href='{i['dl']}'>Download</a></b>\n\n"
msg = await message.reply(f"Mencari film di Terbit21 dg keyword {judul}..") if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
r = await http.get(f"https://yasirapi.eu.org/terbit21?q={judul}") await msg.reply(head + msgs, True, disable_web_page_preview=True)
res = r.json() await asyncio.sleep(2)
data = "".join( msgs = ""
f"**Judul: {i['judul']}**\n`{i['kategori']}`\n{i['link']}\n**Download:** [Klik Disini]({i['dl']})\n\n" if msgs != "":
for i in res["result"] await msg.reply(head + msgs, True, disable_web_page_preview=True)
) except Exception as e:
if not res["result"]: await m.delete()
return await msg.edit("Yahh, ga ada hasil ditemukan") LOGGER.error(e)
try: await msg.reply(str(e), True)
await msg.edit( else:
f"<b>Hasil pencarian query {judul} di lk21:</b>\n{data}", try:
disable_web_page_preview=True, title = msg.text.split(" ", 1)[1]
) r = await http.get("https://yasirapi.eu.org/terbit21?q={title}")
except MessageTooLong: res = r.json()
pesan = await rentry(data) if not res["result"]:
await msg.edit( await m.delete()
f"Karena hasil scrape terlalu panjang, maka hasil scrape di post ke rentry.\n\n{pesan}" return await msg.reply("404 Result not FOUND!", True)
) await m.delete()
head = f"<b>#Terbit21 Results For:</b> <code>{title}</code>\n\n"
msgs = ""
for c, i in enumerate(res["result"][:15], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n--> <b><a href='{i['dl']}'>Download</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)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
await m.delete()
LOGGER.error(e)
await msg.reply(str(e), True)
@app.on_message(filters.command(["lk21"], COMMAND_HANDLER)) @app.on_message(filters.command(["lk21"], COMMAND_HANDLER))
@capture_err @capture_err
async def lk21_scrap(_, message): async def lk21_scrap(_, msg):
if len(message.command) == 1: m = await msg.reply("**__Checking data list ...__**", True)
msg = await message.reply("Mendapatkan daftar post film terbaru di lk21") if len(msg.command) == 1:
r = await http.get("https://yasirapi.eu.org/lk21")
res = r.json()
if res.get("detail", None):
return await msg.edit(f"ERROR: {res['detail']}")
data = "".join(
f"**Judul: {i['judul']}**\n`{i['kategori']}`\n{i['link']}\n**Download:** [Klik Disini]({i['dl']})\n\n"
for i in res["result"]
)
try: try:
return await msg.edit( r = await http.get("https://yasirapi.eu.org/lk21")
f"**Daftar rilis movie terbaru di web LK21**:\n{data}", res = r.json()
disable_web_page_preview=True, if res.get("detail", None):
) await m.delete()
except MessageTooLong: return await msg.reply(f"ERROR: {res['detail']}", True)
msg = await rentry(data) if not res["result"]:
await msg.edit( await m.delete()
f"Karena hasil scrape terlalu panjang, maka hasil scrape di post ke rentry.\n\n{msg}" return await msg.reply("404 Result not FOUND!", True)
) await m.delete()
judul = message.text.split(" ", maxsplit=1)[1] head = f"<b>#Layarkaca21 Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
msg = await message.reply(f"Mencari film di lk21 dg keyword {judul}..") msgs = ""
r = await http.get(f"https://yasirapi.eu.org/lk21?q={judul}") for c, i in enumerate(res["result"][:15], start=1):
res = r.json() msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n--> <b><a href='{i['dl']}'>Download</a></b>\n\n"
if res.get("detail", None): if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
return await msg.edit(f"ERROR: {res['detail']}") await msg.reply(head + msgs, True, disable_web_page_preview=True)
data = "".join( await asyncio.sleep(2)
f"**Judul: {i['judul']}**\n`{i['kategori']}`\n{i['link']}\n**Download:** [Klik Disini]({i['dl']})\n\n" msgs = ""
for i in res["result"] if msgs != "":
) await msg.reply(head + msgs, True, disable_web_page_preview=True)
if not res["result"]: except Exception as e:
return await msg.edit("Yahh, ga ada hasil ditemukan") await m.delete()
try: LOGGER.error(e)
await msg.edit( await msg.reply(str(e), True)
f"<b>Hasil pencarian query {judul} di lk21:</b>\n{data}", else:
disable_web_page_preview=True, try:
) title = msg.text.split(" ", 1)[1]
except MessageTooLong: r = await http.get("https://yasirapi.eu.org/lk21?q={title}")
pesan = await rentry(data) res = r.json()
return await msg.edit( if res.get("detail", None):
f"Karena hasil scrape terlalu panjang, maka hasil scrape di post ke rentry.\n\n{pesan}" await m.delete()
) return await msg.reply(f"ERROR: {res['detail']}", True)
if not res["result"]:
await m.delete()
return await msg.reply("404 Result not FOUND!", True)
await m.delete()
head = f"<b>#Layarkaca21 Results For:</b> <code>{title}</code>\n\n"
msgs = ""
for c, i in enumerate(res["result"][:15], start=1):
msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Category:</b> <code>{i['kategori']}</code>\n--> <b><a href='{i['dl']}'>Download</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)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
await m.delete()
LOGGER.error(e)
await msg.reply(str(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(_, message): async def gomov_scrap(_, message):
m = await msg.reply("**__⏳ Please wait, scraping data ...__**", True)
try: try:
judul = message.text.split(" ", maxsplit=1)[1] title = msg.text.split(" ", 1)[1]
except IndexError: except IndexError:
judul = "" title = ""
msg = await message.reply("Scraping GoMov Website..")
try: try:
headers = { html = await http.get(f"https://185.173.38.216/?s={title}", headers=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" text = BeautifulSoup(html.text, "lxml")
} entry = text.find_all(class_="entry-header")
html = await http.get(f"https://185.173.38.216/?s={judul}", headers=headers)
soup = BeautifulSoup(html.text, "lxml")
entry = soup.find_all(class_="entry-header")
if "Nothing Found" in entry[0].text: if "Nothing Found" in entry[0].text:
return await msg.edit("Oops, data film tidak ditemukan di GoMov") await m.delete()
DATA = [] if title != "":
await msg.reply(f"404 Not FOUND For: {key}", True)
else:
await msg.reply(f"404 Not FOUND!", True)
return
data = []
for i in entry: for i in entry:
genre = i.find(class_="gmr-movie-on").text genre = i.find(class_="gmr-movie-on").text
genre = f"{genre}\n" if genre != "" else "" genre = f"{genre}" if genre != "" else "N/A"
judul = i.find(class_="entry-title").find("a").text judul = i.find(class_="entry-title").find("a").text
link = i.find(class_="entry-title").find("a").get("href") link = i.find(class_="entry-title").find("a").get("href")
DATA.append({"judul": judul, "link": link, "genre": genre}) data.append({"judul": judul, "link": link, "genre": genre})
res = "".join( if title != "":
f"<b>{num}. {i['judul']}</b>\n<code>{i['genre']}</code>{i['link']}\n\n" head = f"<b>#Gomov Results For:</b> <code>{title}</code>\n\n"
for num, i in enumerate(DATA, start=1) else:
) head = f"<b>#Gomov Latest:</b>\n--> Use /{msg.command[0]} [title] to start search with title.\n\n"
await msg.edit( msgs = ""
f"<b>Hasil Pencarian di website GoMov:</b>\n{res}\nScraped by @{BOT_USERNAME}" await m.delete()
) for c, i in enumerate(data[:15], start=1):
except Exception: msgs += f"<b>{c}. <a href='{i['link']}'>{i['judul']}</a></b>\n<b>Genre:</b> <code>{i['genre']}</code>\n<b>Extract:</b> <code>/{msg.command[0]}_scrap {i['link']}</code>\n\n"
exc = traceback.format_exc() if len(head.encode("utf-8") + msgs.encode("utf-8")) >= 4000:
await msg.edit(f"ERROR: <code>{exc}</code>") await msg.reply(
head + msgs,
True,
disable_web_page_preview=True,
)
await asyncio.sleep(2)
msgs = ""
if msgs != "":
await msg.reply(head + msgs, True, disable_web_page_preview=True)
except Exception as e:
LOGGER.error(e)
await m.delete()
await msg.reply(f"ERROR: <code>{e}</code>", True)
@app.on_message(filters.command(["savefilm21_scrap"], COMMAND_HANDLER)) @app.on_message(filters.command(["savefilm21_scrap"], COMMAND_HANDLER))
@ -364,7 +538,7 @@ async def savefilm21_scrap(_, message):
await message.reply(f"<b>Hasil Scrap dari {link}</b>:\n\n{res}") await message.reply(f"<b>Hasil Scrap dari {link}</b>:\n\n{res}")
except IndexError: except IndexError:
return await message.reply( return await message.reply(
"Gunakan command /savefilm21_scrap <b>[link]</b> untuk scrap link download" f"Gunakan command /{message.command[0]} <b>[link]</b> untuk scrap link download"
) )
except Exception as e: except Exception as e:
await message.reply(f"ERROR: {str(e)}") await message.reply(f"ERROR: {str(e)}")
@ -385,7 +559,7 @@ async def nodrakor_scrap(_, message):
await message.reply(f"<b>Hasil Scrap dari {link}</b>:\n{hasil}") await message.reply(f"<b>Hasil Scrap dari {link}</b>:\n{hasil}")
except IndexError: except IndexError:
return await message.reply( return await message.reply(
"Gunakan command /nodrakor_scrap <b>[link]</b> untuk scrap link download" f"Gunakan command /{message.command[0]} <b>[link]</b> untuk scrap link download"
) )
except Exception as e: except Exception as e:
await message.reply(f"ERROR: {str(e)}") await message.reply(f"ERROR: {str(e)}")
@ -417,14 +591,14 @@ async def muviku_scrap(_, message):
await message.reply(res) await message.reply(res)
except IndexError: except IndexError:
return await message.reply( return await message.reply(
"Gunakan command /movieku_scrap <b>[link]</b> untuk scrap link download" f"Gunakan command /{message.command[0]} <b>[link]</b> untuk scrap link download"
) )
except Exception as e: except Exception as e:
await message.reply(f"ERROR: {str(e)}") await message.reply(f"ERROR: {str(e)}")
@app.on_message( @app.on_message(
filters.command(["melong"], COMMAND_HANDLER) filters.command(["melongmovie_scrap"], COMMAND_HANDLER)
& filters.user([617426792, 1985689491, 1172699512, 2024984460]) & filters.user([617426792, 1985689491, 1172699512, 2024984460])
) )
@capture_err @capture_err
@ -444,7 +618,7 @@ async def melong_scrap(_, message):
await message.reply(rep) await message.reply(rep)
except IndexError: except IndexError:
await message.reply( await message.reply(
"Gunakan command /melong <b>[link]</b> untuk scrap link download" f"Gunakan command /{message.command[0]} <b>[link]</b> untuk scrap link download"
) )

View file

@ -114,6 +114,9 @@ async def convertsrt(c, m):
msg = await m.reply("⏳ Converting...") msg = await m.reply("⏳ Converting...")
dl = await reply.download() dl = await reply.download()
filename = dl.split("/", 3)[3] filename = dl.split("/", 3)[3]
LOGGER.info(
f"ConvertSub: {filename} by {m.from_user.first_name} [{m.from_user.id}]"
)
(await shell_exec(f"mediaextract -i '{dl}' {filename}.srt"))[0] (await shell_exec(f"mediaextract -i '{dl}' {filename}.srt"))[0]
await m.reply_document( await m.reply_document(
f"{filename}.srt", caption=f"{filename}.srt\n\nConverted by @{c.me.username}" f"{filename}.srt", caption=f"{filename}.srt\n\nConverted by @{c.me.username}"