mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Ddl (#283)
- Fix facebook downloader with latest changes from API - Fix tiktok downloader - Add Instagram downloader (Only first post to prevent user abuse) - Add Twitter Downloader Harap maklum jika ada error,,,
This commit is contained in:
parent
9aac586b87
commit
d7f2cc5590
5 changed files with 129 additions and 18 deletions
|
|
@ -3,9 +3,13 @@
|
||||||
# * @projectName MissKatyPyro
|
# * @projectName MissKatyPyro
|
||||||
# * Copyright ©YasirPedia All rights reserved
|
# * Copyright ©YasirPedia All rights reserved
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import cloudscraper
|
||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
from cloudscraper import create_scraper
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
@ -31,6 +35,8 @@ __HELP__ = """
|
||||||
/tgraph_up [reply_to_TG_File] - Download TG File
|
/tgraph_up [reply_to_TG_File] - Download TG File
|
||||||
/tiktokdl [link] - Download TikTok Video, try use ytdown command if error.
|
/tiktokdl [link] - Download TikTok Video, try use ytdown command if error.
|
||||||
/fbdl [link] - Download Facebook Video.
|
/fbdl [link] - Download Facebook Video.
|
||||||
|
/instadl [link] - Download photo or video from instagram (Only first post).
|
||||||
|
/twitterdl [link] - Dowload video from Twitter aka X.
|
||||||
/anon [link] - Upload files to Anonfiles.
|
/anon [link] - Upload files to Anonfiles.
|
||||||
/ytdown [YT-DLP Supported URL] - Downloading YT-DLP Supported Video and Audio.
|
/ytdown [YT-DLP Supported URL] - Downloading YT-DLP Supported Video and Audio.
|
||||||
"""
|
"""
|
||||||
|
|
@ -168,6 +174,99 @@ async def download(client, message):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(filters.command(["instadl"], COMMAND_HANDLER))
|
||||||
|
@capture_err
|
||||||
|
@ratelimiter
|
||||||
|
async def instadl(_, message):
|
||||||
|
if len(message.command) == 1:
|
||||||
|
return await message.reply(
|
||||||
|
f"Use command /{message.command[0]} [link] to download Instagram Photo or Video."
|
||||||
|
)
|
||||||
|
link = message.command[1]
|
||||||
|
msg = await message.reply("Trying download...")
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0",
|
||||||
|
"Accept": "*/*",
|
||||||
|
"Accept-Language": "en-US,en;q=0.5",
|
||||||
|
"Accept-Encoding": "gzip, deflate, br",
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
|
"Content-Length": "99",
|
||||||
|
"Origin": "https://saveig.app",
|
||||||
|
"Connection": "keep-alive",
|
||||||
|
"Referer": "https://saveig.app/id",
|
||||||
|
}
|
||||||
|
post = create_scraper().post("https://saveig.app/api/ajaxSearch", data={"q": link, "t": "media", "lang": "id"}, headers=headers)
|
||||||
|
if post.status_code not in [200, 401]:
|
||||||
|
return await message.reply("Unknown error.")
|
||||||
|
res = post.json()
|
||||||
|
if r := re.findall('href="(https?://(?!play\.google\.com|/)[^"]+)"', res["data"]):
|
||||||
|
res = r[0].replace("&", "&")
|
||||||
|
fname = (await fetch.head(res)).headers.get("content-disposition", "").split("filename=")[1]
|
||||||
|
is_img = (await fetch.head(res)).headers.get("content-type").startswith("image")
|
||||||
|
if is_img:
|
||||||
|
await message.reply_photo(res, caption=fname)
|
||||||
|
await message.reply_video(res, caption=fname)
|
||||||
|
await msg.delete()
|
||||||
|
except Exception as e:
|
||||||
|
await message.reply(f"Failed to download instagram video..\n\n<b>Reason:</b> {e}")
|
||||||
|
await msg.delete()
|
||||||
|
|
||||||
|
|
||||||
|
@app.on_message(filters.command(["twitterdl"], COMMAND_HANDLER))
|
||||||
|
@capture_err
|
||||||
|
@ratelimiter
|
||||||
|
async def twitter(_, message):
|
||||||
|
if len(message.command) == 1:
|
||||||
|
return await message.reply(
|
||||||
|
f"Use command /{message.command[0]} [link] to download Twitter video."
|
||||||
|
)
|
||||||
|
url = message.command[1]
|
||||||
|
if "x.com" in url:
|
||||||
|
url = url.replace("x.com", "twitter.com")
|
||||||
|
msg = await message.reply("Trying download...")
|
||||||
|
try:
|
||||||
|
headers = {
|
||||||
|
"Host": "ssstwitter.com",
|
||||||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0",
|
||||||
|
"Accept": "*/*",
|
||||||
|
"Accept-Language": "en-US,en;q=0.5",
|
||||||
|
"Accept-Encoding": "gzip, deflate, br",
|
||||||
|
"HX-Request": "true",
|
||||||
|
"Origin": "https://ssstwitter.com",
|
||||||
|
"Referer": "https://ssstwitter.com/id",
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"id": url,
|
||||||
|
"locale": "id",
|
||||||
|
"tt": "bc9841580b5d72e855e7d01bf3255278l",
|
||||||
|
"ts": "1691416179",
|
||||||
|
"source": "form",
|
||||||
|
}
|
||||||
|
post = await fetch.post(f"https://ssstwitter.com/id", data=data, headers=headers, follow_redirects=True)
|
||||||
|
if post.status_code not in [200, 401]:
|
||||||
|
return await msg.edit_msg("Unknown error.")
|
||||||
|
soup = BeautifulSoup(post.text, "lxml")
|
||||||
|
cekdata = soup.find("a", {"pure-button pure-button-primary is-center u-bl dl-button download_link without_watermark vignette_active"})
|
||||||
|
if not cekdata:
|
||||||
|
return await message.reply("ERROR: Oops! It seems that this tweet doesn't have a video! Try later or check your link")
|
||||||
|
try:
|
||||||
|
fname = (await fetch.head(cekdata.get("href"))).headers.get("content-disposition", "").split("filename=")[1]
|
||||||
|
obj = SmartDL(cekdata.get("href"), progress_bar=False, timeout=15)
|
||||||
|
obj.start()
|
||||||
|
path = obj.get_dest()
|
||||||
|
await message.reply_video(path, caption=f"<code>{fname}</code>\n\nUploaded for {message.from_user.mention} [<code>{message.from_user.id}</code>]",)
|
||||||
|
except Exception as er:
|
||||||
|
LOGGING.error(f"ERROR: while fetching TwitterDL. {er}")
|
||||||
|
return await msg.edit_msg("ERROR: Got error while extracting link.")
|
||||||
|
await msg.delete()
|
||||||
|
except Exception as e:
|
||||||
|
await message.reply(f"Failed to download twitter video..\n\n<b>Reason:</b> {e}")
|
||||||
|
await msg.delete()
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.command(["tiktokdl"], COMMAND_HANDLER))
|
@app.on_message(filters.command(["tiktokdl"], COMMAND_HANDLER))
|
||||||
@capture_err
|
@capture_err
|
||||||
@ratelimiter
|
@ratelimiter
|
||||||
|
|
@ -180,11 +279,13 @@ async def tiktokdl(_, message):
|
||||||
msg = await message.reply("Trying download...")
|
msg = await message.reply("Trying download...")
|
||||||
try:
|
try:
|
||||||
r = (
|
r = (
|
||||||
await fetch.get(f"https://apimu.my.id/downloader/tiktok3?link={link}")
|
await fetch.post(f"https://lovetik.com/api/ajax/search", data={"query": link})
|
||||||
).json()
|
).json()
|
||||||
|
fname = (await fetch.head(r["links"][0]["a"])).headers.get("content-disposition", "")
|
||||||
|
filename = unquote(fname.split('filename=')[1].strip('"').split('"')[0])
|
||||||
await message.reply_video(
|
await message.reply_video(
|
||||||
r["hasil"]["download_mp4_hd"],
|
r["links"][0]["a"],
|
||||||
caption=f"<b>Title:</b> <code>{r['hasil']['video_title']}</code>\n<b>Uploader</b>: <a href='https://www.tiktok.com/@{r['hasil']['username']}'>{r['hasil']['name']}</a>\n👍: {r['hasil']['like']} 🔁: {r['hasil']['share']} 💬: {r['hasil']['comment']}\n\nUploaded for {message.from_user.mention} [<code>{message.from_user.id}</code>]",
|
caption=f"<b>Title:</b> <code>{filename}</code>\n<b>Uploader</b>: <a href='https://www.tiktok.com/{r['author']}'>{r['author_name']}</a>\n\nUploaded for {message.from_user.mention} [<code>{message.from_user.id}</code>]",
|
||||||
)
|
)
|
||||||
await msg.delete()
|
await msg.delete()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -194,6 +295,7 @@ async def tiktokdl(_, message):
|
||||||
|
|
||||||
@app.on_message(filters.command(["fbdl"], COMMAND_HANDLER))
|
@app.on_message(filters.command(["fbdl"], COMMAND_HANDLER))
|
||||||
@capture_err
|
@capture_err
|
||||||
|
@new_task
|
||||||
async def fbdl(_, message):
|
async def fbdl(_, message):
|
||||||
if len(message.command) == 1:
|
if len(message.command) == 1:
|
||||||
return await message.reply(
|
return await message.reply(
|
||||||
|
|
@ -207,7 +309,7 @@ async def fbdl(_, message):
|
||||||
url = resjson["result"]["hd"]
|
url = resjson["result"]["hd"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
url = resjson["result"]["sd"]
|
url = resjson["result"]["sd"]
|
||||||
obj = SmartDL(url, progress_bar=False, timeout=15)
|
obj = SmartDL(url, progress_bar=False, timeout=15, verify=False)
|
||||||
obj.start()
|
obj.start()
|
||||||
path = obj.get_dest()
|
path = obj.get_dest()
|
||||||
await message.reply_video(
|
await message.reply_video(
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ async def genss(self: Client, ctx: Message, strings):
|
||||||
url = the_url_parts.strip()
|
url = the_url_parts.strip()
|
||||||
file_name = os.path.basename(url)
|
file_name = os.path.basename(url)
|
||||||
download_file_path = os.path.join("downloads/", file_name)
|
download_file_path = os.path.join("downloads/", file_name)
|
||||||
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10)
|
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False)
|
||||||
try:
|
try:
|
||||||
downloader.start(blocking=False)
|
downloader.start(blocking=False)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ from pyrogram.errors import (
|
||||||
ChannelPrivate,
|
ChannelPrivate,
|
||||||
ChatAdminRequired,
|
ChatAdminRequired,
|
||||||
ChatNotModified,
|
ChatNotModified,
|
||||||
|
ChatRestricted,
|
||||||
PeerIdInvalid,
|
PeerIdInvalid,
|
||||||
)
|
)
|
||||||
from pyrogram.types import ChatPermissions, InlineKeyboardButton, InlineKeyboardMarkup
|
from pyrogram.types import ChatPermissions, InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
|
|
@ -131,13 +132,17 @@ async def un_mute_chat(chat_id: int, perm: ChatPermissions):
|
||||||
else:
|
else:
|
||||||
job = scheduler.get_job(f"enable_nightmode_{chat_id}")
|
job = scheduler.get_job(f"enable_nightmode_{chat_id}")
|
||||||
close_at = job.next_run_time
|
close_at = job.next_run_time
|
||||||
await app.send_message(
|
try:
|
||||||
chat_id,
|
await app.send_message(
|
||||||
langdict[getlang]["nightmodev2"]["nmd_off_success"].format(
|
chat_id,
|
||||||
dt=tglsekarang(), close_at=close_at
|
langdict[getlang]["nightmodev2"]["nmd_off_success"].format(
|
||||||
),
|
dt=tglsekarang(), close_at=close_at
|
||||||
reply_markup=reply_markup,
|
),
|
||||||
)
|
reply_markup=reply_markup,
|
||||||
|
)
|
||||||
|
except ChatRestricted:
|
||||||
|
scheduler.remove_job(f"enable_nightmode_{chat_id}")
|
||||||
|
scheduler.remove_job(f"disable_nightmode_{chat_id}")
|
||||||
|
|
||||||
|
|
||||||
async def mute_chat(chat_id: int):
|
async def mute_chat(chat_id: int):
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
|
from pyrogram.errors import ChatSendPhotosForbidden, ChatWriteForbidden
|
||||||
from pyrogram.types import (
|
from pyrogram.types import (
|
||||||
CallbackQuery,
|
CallbackQuery,
|
||||||
InlineKeyboardButton,
|
InlineKeyboardButton,
|
||||||
|
|
@ -72,11 +73,14 @@ keyboard = InlineKeyboardMarkup(
|
||||||
async def start(_, ctx: Message, strings):
|
async def start(_, ctx: Message, strings):
|
||||||
if ctx.chat.type.value != "private":
|
if ctx.chat.type.value != "private":
|
||||||
nama = ctx.from_user.mention if ctx.from_user else ctx.sender_chat.title
|
nama = ctx.from_user.mention if ctx.from_user else ctx.sender_chat.title
|
||||||
return await ctx.reply_photo(
|
try:
|
||||||
photo="https://telegra.ph/file/90e9a448bc2f8b055b762.jpg",
|
return await ctx.reply_photo(
|
||||||
caption=strings("start_msg").format(kamuh=nama),
|
photo="https://telegra.ph/file/90e9a448bc2f8b055b762.jpg",
|
||||||
reply_markup=keyboard,
|
caption=strings("start_msg").format(kamuh=nama),
|
||||||
)
|
reply_markup=keyboard,
|
||||||
|
)
|
||||||
|
except (ChatSendPhotosForbidden, ChatWriteForbidden):
|
||||||
|
return await ctx.chat.leave()
|
||||||
if len(ctx.text.split()) > 1:
|
if len(ctx.text.split()) > 1:
|
||||||
name = (ctx.text.split(None, 1)[1]).lower()
|
name = (ctx.text.split(None, 1)[1]).lower()
|
||||||
if "_" in name:
|
if "_" in name:
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ async def take_ss(_, ctx: Message, strings):
|
||||||
msg = await ctx.reply_msg(strings("wait_str"))
|
msg = await ctx.reply_msg(strings("wait_str"))
|
||||||
try:
|
try:
|
||||||
url = f"https://webss.yasirapi.eu.org/api?url={url}&width=1280&height=720"
|
url = f"https://webss.yasirapi.eu.org/api?url={url}&width=1280&height=720"
|
||||||
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10)
|
downloader = SmartDL(url, download_file_path, progress_bar=False, timeout=10, verify=False)
|
||||||
downloader.start(blocking=True)
|
downloader.start(blocking=True)
|
||||||
await gather(
|
await gather(
|
||||||
*[
|
*[
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue