📌 YouTube Video and Audio Downloader Bot Code 📌 ✅
If BJS has tik it is tested & working perfectly.
📜 Description: Get YouTube Video Download URL with Audio, Video Only, Audio and Multiple Quality Options
🚀 Command: /getyt
⏳ Wait for answer: ❌ Off
🛠 BJS Code:
Bot.sendMessage("📥 Please send me the YouTube video URL you want to download.");
Bot.runCommand("/getyt_step2");
🚀 Command: /getyt_step2
⏳ Wait for answer: ✅ On
📃 Answer : ❌ No answer ( empty )
🛠 BJS Code:
if (!message || !message.includes("youtu")) {
Bot.sendMessage("❌ Please send a valid YouTube URL.");
return;
}
User.setProperty("yt_url", message, "string");
Bot.sendMessage("⏳ Fetching download links...");
HTTP.get({
url: "https://yt-vid.hazex.workers.dev/?url=" + encodeURIComponent(message),
success: "/onYTResult",
error: "/onYTError"
});
🚀 Command: /onYTResult
⏳ Wait for answer: ❌ Off
🛠 BJS Code:
let data;
try {
data = JSON.parse(content);
} catch (e) {
Bot.sendMessage("❌ Failed to parse the response. Please try again later.");
return;
}
// Show error from API
if (data.error) {
Bot.sendMessage("❌ Error: " + data.message);
return;
}
let caption = "🎬
" + data.title + "\n" +
"⏱️ Duration: " + data.duration + " seconds\n" +
"📺
Thumbnail";
Bot.sendMessage({
text: caption,
parse_mode: "HTML",
disable_web_page_preview: false
});
function sendInChunks(label, list) {
if (!list || list.length === 0) return;
let totalMaxButtons = 10;
let safeList = list.slice(0, totalMaxButtons);
let buttons = safeList.map(function(item) {
return [ { title: item.label, url: item.url } ];
});
let text = "📦
" + label + "";
Bot.sendInlineKeyboard(buttons, text, { parse_mode: "HTML" });
if (list.length > totalMaxButtons) {
Bot.sendMessage("⚠️ Too many formats in '" + label + "'. Only showing first " + totalMaxButtons + " options.");
}
}
// Send download options
sendInChunks("Video with Audio", data.video_with_audio);
sendInChunks("Audio Only", data.audio);
🚀 Command: /onYTError
⏳ Wait for answer: ❌ Off
🛠 BJS Code:
Bot.sendMessage("❌ Failed to fetch data. Please try again later or check the URL.");
⚠️ Note : This also had a video-only mode, but it was removed due to excessively long URLs. Please ensure the final video is in 360p quality. Various audio formats, including audio-only, are also available.
⚡️Posted on :
⚡️Credits :
https://t.me/FlashComOfficial
⚡️Api Credits :
https://t.me/HazexApi
⚡️Error Report :
https://t.me/FlashComBTChat
⚡️Official Channel :
https://t.me/FlashComOfficial
#BjsCode ✅
If BJS has tik it is tested & working perfectly.