| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- import { youtubedl, youtubedlv2 } from '@bochilteam/scraper'
- import fetch from 'node-fetch'
- import yts from 'yt-search'
- import ytdl from 'ytdl-core'
- import axios from 'axios'
- let handler = async (m, { conn, args, usedPrefix, command }) => {
- if (!args[0]) throw '*๐๐ช๐ ๐๐จ๐ฉ๐ ๐๐ช๐จ๐๐๐๐ค๐ค ๐๐ฃ๐๐ง๐๐จ๐ ๐๐ก ๐๐ฃ๐ก๐๐๐ ๐๐ ๐๐ค๐ช๐๐ช๐๐ ๐ฅ๐๐ง๐ ๐๐๐จ๐๐๐ง๐๐๐ง ๐๐ก ๐๐ช๐๐๐ค*'
- if (command == 'ytmp3doc') {
- let youtubeLink = '';
- if (args[0].includes('you')) {
- youtubeLink = args[0];
- } else {
- const index = parseInt(args[0]) - 1;
- if (index >= 0) {
- if (Array.isArray(global.videoList) && global.videoList.length > 0) {
- const matchingItem = global.videoList.find(item => item.from === m.sender);
- if (matchingItem) {
- if (index < matchingItem.urls.length) {
- youtubeLink = matchingItem.urls[index];
- } else {
- throw `โ ๏ธ ๐๐ค ๐จ๐ ๐๐ฃ๐๐ค๐ฃ๐ฉ๐ง๐ค ๐ช๐ฃ ๐๐ฃ๐ก๐๐๐๐จ ๐ฅ๐๐ง๐ ๐๐จ๐ ๐ฃ๐ช๐ข๐๐ง๐ค, ๐ฅ๐ค๐ง ๐๐๐ซ๐ค๐ง ๐๐ฃ๐๐ง๐๐จ๐ ๐๐ก ๐ฃ๐ช๐ข๐๐ง๐ค ๐๐ฃ๐ฉ๐ง๐ 1 ๐ฎ ๐๐ก ${matchingItem.urls.length}*`
- }} else {
- throw `โ ๏ธ ๐๐๐ง๐ ๐ฅ๐ค๐๐๐ง ๐ช๐จ๐๐ง ๐๐จ๐ฉ๐ ๐๐ค๐ข๐๐ฃ๐๐ค ๐๐ ๐๐จ๐ฉ๐ ๐๐ค๐ง๐ข๐ (${usedPrefix + command} <numero>), ๐๐ค๐ง ๐๐๐ซ๐ค๐ง ๐ง๐๐๐ก๐๐ฏ๐๐ง ๐ก๐ ๐๐ช๐จ๐ฆ๐ช๐๐๐ ๐๐ ๐ซ๐๐๐๐ค๐จ ๐๐ค๐ฃ ๐๐ก ๐๐ค๐ข๐๐ฃ๐๐ค ${usedPrefix}playlist <texto>*`
- }} else {
- throw `โ ๏ธ ๐๐๐ง๐ ๐ฅ๐ค๐๐๐ง ๐ช๐จ๐๐ง ๐๐จ๐ฉ๐ ๐๐ค๐ข๐๐ฃ๐๐ค ๐๐ ๐๐จ๐ฉ๐ ๐๐ค๐ง๐ข๐ (${usedPrefix + command} <numero>), ๐๐ค๐ง ๐๐๐ซ๐ค๐ง ๐ง๐๐๐ก๐๐ฏ๐๐ง ๐ก๐ ๐๐ช๐จ๐ฆ๐ช๐๐๐ ๐๐ ๐ซ๐๐๐๐ค๐จ ๐๐ค๐ฃ ๐๐ก ๐๐ค๐ข๐๐ฃ๐๐ค ${usedPrefix}playlist <texto>*`
- }}}
-
- conn.reply(m.chat, [`*โ ๐๐จ๐ฅ๐๐ง๐ โ ๐ช๐ฃ ๐ข๐ค๐ข๐๐ฃ๐ฉ๐ค... ๐๐ ๐๐จ๐ฉ๐ค๐ฎ ๐๐๐จ๐๐๐ง๐๐๐๐ค ๐ฉ๐ช ๐๐ช๐๐๐ค๐น*`, `โ ๐๐๐๐พ๐๐๐ผ๐๐ฟ๐...\n*๐๐ด๐ต๐ฐ๐บ ๐ช๐ฏ๐ต๐ฆ๐ฏ๐ต๐ข๐ฏ๐ฅ๐ฐ ๐ฅ๐ฆ๐ด๐ค๐ข๐ณ๐จ๐ข ๐ด๐ถ๐ด ๐๐ถ๐ฅ๐ช๐ฐ ๐ฆ๐ด๐ฑ๐ฆ๐ณ๐ฆ ๐โโ๏ธ๐จ*`].getRandom(), m, {contextInfo: {externalAdReply :{ mediaUrl: null, mediaType: 1, description: null, title: wm, body: ' ๐ซ ๐๐ฎ๐ฉ๐๐ซ ๐๐จ๐ญ ๐๐ ๐๐ก๐๐ญ๐ฌ๐๐ฉ๐ฉ ๐ฅณ ', previewType: 0, thumbnail: img.getRandom(), sourceUrl: redes.getRandom()}}})
- try {
- let q = '128kbps'
- let v = youtubeLink
- const yt = await youtubedl(v).catch(async _ => await youtubedlv2(v))
- const dl_url = await yt.audio[q].download()
- const ttl = await yt.title
- const size = await yt.audio[q].fileSizeH
- await conn.sendMessage(m.chat, { document: { url: dl_url }, fileName: `${ttl}.mp3`, mimetype: 'audio/mp4' }, { quoted: m })
- //conn.sendFile(m.chat, dl_url, ttl + '.mp3', null, m, false, { mimetype: 'audio/mp4' })
- } catch {
- try {
- let lolhuman = await fetch(`https://api.lolhuman.xyz/api/ytaudio2?apikey=${lolkeysapi}&url=${youtubeLink}`)
- let lolh = await lolhuman.json()
- let n = lolh.result.title || 'error'
- await conn.sendMessage(m.chat, { document: { url: lolh.result.link }, fileName: `${n}.mp3`, mimetype: 'audio/mp4' }, { quoted: m })
- } catch {
- try {
- let searchh = await yts(youtubeLink)
- let __res = searchh.all.map(v => v).filter(v => v.type == "video")
- let infoo = await ytdl.getInfo('https://youtu.be/' + __res[0].videoId)
- let ress = await ytdl.chooseFormat(infoo.formats, { filter: 'audioonly' })
- conn.sendMessage(m.chat, { document: { url: ress.url }, fileName: __res[0].title + '.mp3', mimetype: 'audio/mp4' }, { quoted: m })
- } catch {
- }}}}
- if (command == 'ytmp4' || command == 'fgmp4') {
- let youtubeLink = '';
- if (args[0].includes('you')) {
- youtubeLink = args[0];
- } else {
- const index = parseInt(args[0]) - 1;
- if (index >= 0) {
- if (Array.isArray(global.videoList) && global.videoList.length > 0) {
- const matchingItem = global.videoList.find(item => item.from === m.sender);
- if (matchingItem) {
- if (index < matchingItem.urls.length) {
- youtubeLink = matchingItem.urls[index];
- } else {
- throw `โ ๏ธ ๐๐ค ๐จ๐ ๐๐ฃ๐๐ค๐ฃ๐ฉ๐ง๐ค ๐ช๐ฃ ๐๐ฃ๐ก๐๐๐๐จ ๐ฅ๐๐ง๐ ๐๐จ๐ ๐ฃ๐ช๐ข๐๐ง๐ค, ๐ฅ๐ค๐ง ๐๐๐ซ๐ค๐ง ๐๐ฃ๐๐ง๐๐จ๐ ๐๐ก ๐ฃ๐ช๐ข๐๐ง๐ค ๐๐ฃ๐ฉ๐ง๐ 1 ๐ฎ ๐๐ก ${matchingItem.urls.length}*`
- }} else {
- throw `โ ๏ธ ๐๐๐ง๐ ๐ฅ๐ค๐๐๐ง ๐ช๐จ๐๐ง ๐๐จ๐ฉ๐ ๐๐ค๐ข๐๐ฃ๐๐ค ๐๐ ๐๐จ๐ฉ๐ ๐๐ค๐ง๐ข๐ (${usedPrefix + command} <numero>), ๐๐ค๐ง ๐๐๐ซ๐ค๐ง ๐ง๐๐๐ก๐๐ฏ๐๐ง ๐ก๐ ๐๐ช๐จ๐ฆ๐ช๐๐๐ ๐๐ ๐ซ๐๐๐๐ค๐จ ๐๐ค๐ฃ ๐๐ก ๐๐ค๐ข๐๐ฃ๐๐ค ${usedPrefix}playlist <texto>*`
- }} else {
- throw `โ ๏ธ ๐๐๐ง๐ ๐ฅ๐ค๐๐๐ง ๐ช๐จ๐๐ง ๐๐จ๐ฉ๐ ๐๐ค๐ข๐๐ฃ๐๐ค ๐๐ ๐๐จ๐ฉ๐ ๐๐ค๐ง๐ข๐ (${usedPrefix + command} <numero>), ๐๐ค๐ง ๐๐๐ซ๐ค๐ง ๐ง๐๐๐ก๐๐ฏ๐๐ง ๐ก๐ ๐๐ช๐จ๐ฆ๐ช๐๐๐ ๐๐ ๐ซ๐๐๐๐ค๐จ ๐๐ค๐ฃ ๐๐ก ๐๐ค๐ข๐๐ฃ๐๐ค ${usedPrefix}playlist <texto>*`
- }}}
- conn.reply(m.chat, [`*โ ๐๐ ๐๐จ๐ฉ๐ค๐ฎ ๐๐๐จ๐๐๐ง๐๐๐๐ค ๐ฉ๐ช ๐๐๐๐๐ค ๐น*`, `โ ๐๐๐๐พ๐๐๐ผ๐๐ฟ๐...\n*๐๐ด๐ต๐ฐ๐บ ๐ช๐ฏ๐ต๐ฆ๐ฏ๐ต๐ข๐ฏ๐ฅ๐ฐ ๐ฅ๐ฆ๐ด๐ค๐ข๐ณ๐จ๐ข ๐ด๐ถ๐ด ๐๐ช๐ฅ๐ฆo...*`].getRandom(), m, {contextInfo: {externalAdReply :{ mediaUrl: null, mediaType: 1, description: null, title: wm, body: ' โก ๐๐ฎ๐ฉ๐๐ซ Kantu Bot ๐ฃ ', previewType: 0, thumbnail: img.getRandom(), sourceUrl: redes.getRandom()}}})
- try {
- let qu = args[1] || '360'
- let q = qu + 'p'
- let v = youtubeLink
- const yt = await youtubedl(v).catch(async _ => await youtubedlv2(v))
- const dl_url = await yt.video[q].download()
- const ttl = await yt.title
- const size = await yt.video[q].fileSizeH
- await await conn.sendMessage(m.chat, { document: { url: dl_url }, fileName: `${ttl}.mp4`, mimetype: 'video/mp4', caption: `๐ฐ ๐ผ๐ฆ๐ช๐ ๐๐จ๐ฉ๐ ๐ฉ๐ช ๐ซ๐๐๐๐ค \n๐ฅ ๐๐๐ฉ๐ช๐ก๐ค: ${ttl}`, thumbnail: await fetch(yt.thumbnail) }, { quoted: m })
- } catch (E1) {
- //console.log('Error 1 ' + E1)
- try {
- let mediaa = await ytMp4(youtubeLink)
- await conn.sendMessage(m.chat, { document: { url: mediaa.result }, fileName: `error.mp4`, caption: `_${wm}_`, thumbnail: mediaa.thumb, mimetype: 'video/mp4' }, { quoted: m })
- } catch (E2) {
- //console.log('Error 2 ' + E2)
- try {
- let lolhuman = await fetch(`https://api.lolhuman.xyz/api/ytvideo2?apikey=${lolkeysapi}&url=${youtubeLink}`)
- let lolh = await lolhuman.json()
- let n = lolh.result.title || 'error'
- let n2 = lolh.result.link
- let n3 = lolh.result.size
- let n4 = lolh.result.thumbnail
- await conn.sendMessage(m.chat, { document: { url: n2 }, fileName: `${n}.mp4`, mimetype: 'video/mp4', caption: `๐ฐ ๐ผ๐ฆ๐ช๐ ๐๐จ๐ฉ๐ ๐ฉ๐ช ๐ซ๐๐๐๐ค \n๐ฅ ๐๐๐ฉ๐ช๐ก๐ค: ${n}`, thumbnail: await fetch(n4) }, { quoted: m })
- } catch (E3) {
- //console.log('Error 3 ' + E3)
- }}}}}
- handler.help = ['ytmp4doc', 'ytmp3doc'];
- handler.tags = ['downloader'];
- handler.command = /^ytmp3doc|ytmp4doc?$/i
- export default handler
- function bytesToSize(bytes) {
- return new Promise((resolve, reject) => {
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
- if (bytes === 0) return 'n/a';
- const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
- if (i === 0) resolve(`${bytes} ${sizes[i]}`);
- resolve(`${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`)})};
- async function ytMp3(url) {
- return new Promise((resolve, reject) => {
- ytdl.getInfo(url).then(async(getUrl) => {
- let result = [];
- for(let i = 0; i < getUrl.formats.length; i++) {
- let item = getUrl.formats[i];
- if (item.mimeType == 'audio/webm; codecs=\"opus\"') {
- let { contentLength } = item;
- let bytes = await bytesToSize(contentLength);
- result[i] = { audio: item.url, size: bytes }}};
- let resultFix = result.filter(x => x.audio != undefined && x.size != undefined)
- let tiny = await axios.get(`https://tinyurl.com/api-create.php?url=${resultFix[0].audio}`);
- let tinyUrl = tiny.data;
- let title = getUrl.videoDetails.title;
- let thumb = getUrl.player_response.microformat.playerMicroformatRenderer.thumbnail.thumbnails[0].url;
- resolve({ title, result: tinyUrl, result2: resultFix, thumb })}).catch(reject)})}
- async function ytMp4(url) {
- return new Promise(async(resolve, reject) => {
- ytdl.getInfo(url).then(async(getUrl) => {
- let result = [];
- for(let i = 0; i < getUrl.formats.length; i++) {
- let item = getUrl.formats[i];
- if (item.container == 'mp4' && item.hasVideo == true && item.hasAudio == true) {
- let { qualityLabel, contentLength } = item;
- let bytes = await bytesToSize(contentLength);
- result[i] = { video: item.url, quality: qualityLabel, size: bytes }}};
- let resultFix = result.filter(x => x.video != undefined && x.size != undefined && x.quality != undefined)
- let tiny = await axios.get(`https://tinyurl.com/api-create.php?url=${resultFix[0].video}`);
- let tinyUrl = tiny.data;
- let title = getUrl.videoDetails.title;
- let thumb = getUrl.player_response.microformat.playerMicroformatRenderer.thumbnail.thumbnails[0].url;
- resolve({ title, result: tinyUrl, rersult2: resultFix[0].video, thumb })}).catch(reject)})};
- async function ytPlay(query) {
- return new Promise((resolve, reject) => {
- yts(query).then(async(getData) => {
- let result = getData.videos.slice( 0, 5 );
- let url = [];
- for (let i = 0; i < result.length; i++) { url.push(result[i].url) }
- let random = url[0];
- let getAudio = await ytMp3(random);
- resolve(getAudio)}).catch(reject)})};
- async function ytPlayVid(query) {
- return new Promise((resolve, reject) => {
- yts(query).then(async(getData) => {
- let result = getData.videos.slice( 0, 5 );
- let url = [];
- for (let i = 0; i < result.length; i++) { url.push(result[i].url) }
- let random = url[0];
- let getVideo = await ytMp4(random);
- resolve(getVideo)}).catch(reject)})};
|