-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππ΄πΌπ²π·π°πΌ π±π πΆπ°π±ππΈπ΄π»-πΉπππ
- Loading branch information
1 parent
4ca1427
commit d3b282e
Showing
1 changed file
with
39 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,46 @@ | ||
import fetch from 'node-fetch'; | ||
import fs from 'fs'; | ||
import { pipeline } from 'stream'; | ||
import { promisify } from 'util'; | ||
import os from 'os'; | ||
|
||
const streamPipeline = promisify(pipeline); | ||
|
||
const handler = async (m, { conn, command, text, usedPrefix }) => { | ||
if (!text) return conn.reply(m.chat, 'πππππππ ππ ππππ ππ π’πππππ', m); | ||
|
||
const videoUrl = text.trim(); | ||
const apiUrl = `https://youtube-api-thepapusteam.koyeb.app/api/video?url=${videoUrl}`; | ||
|
||
try { | ||
console.log(`Solicitando informaciΓ³n del video desde: ${apiUrl}`); | ||
const response = await fetch(apiUrl); | ||
const data = await response.json(); | ||
|
||
if (!data.status) { | ||
throw new Error('Error al obtener informaciΓ³n del video'); | ||
} | ||
|
||
console.log('InformaciΓ³n del video recibida:', data); | ||
|
||
const { title, thumbnails, author } = data.data; | ||
const thumbnail = thumbnails[0].url; | ||
const videoUrlMp4 = data.downloads.mp4.url; | ||
|
||
const tmpDir = os.tmpdir(); | ||
const filePath = `${tmpDir}/${title}.mp4`; | ||
const writableStream = fs.createWriteStream(filePath); | ||
|
||
console.log('Descargando video desde:', videoUrlMp4); | ||
const videoResponse = await fetch(videoUrlMp4); | ||
if (!videoResponse.ok) { | ||
throw new Error('Error al descargar el video'); | ||
} | ||
|
||
await streamPipeline(videoResponse.body, writableStream); | ||
console.log('Descarga de video completada'); | ||
|
||
await m.react('π'); | ||
import fs from 'fs' | ||
import os from 'os' | ||
import fetch from 'node-fetch' | ||
|
||
let limit = 500 | ||
let handler = async (m, { conn, args, isPrems, isOwner, usedPrefix, command }) => { | ||
let chat = global.db.data.chats[m.chat] | ||
if (!args || !args[0]) throw `β³οΈ π΄πΉπ΄πΌπΏπ»πΎ:\n${usedPrefix + command} https://www.youtube.com/watch?v=k6ltpkNnNPY` | ||
if (!args[0].match(/youtu/gi)) throw ` π π΄ππΈπ΅πΈπ²π° πππ΄ ππ π΄π½π»π°π²π΄ ππ΄π° π π°π»πΈπ³πΎ` | ||
|
||
var ggapi = `https://youtube-api-thepapusteam.koyeb.app/api/video?url=${encodeURIComponent(args[0])}` | ||
|
||
const response = await fetch(ggapi) | ||
if (!response.ok) { | ||
console.log('Error al obtener los detalles del video:', response.statusText) | ||
throw 'Error al obtener los detalles del video' | ||
} | ||
const data = await response.json() | ||
|
||
const txt = `> Β» Titulo: ${title}\n` + | ||
`> Β» Autor: ${author.name}\n` + | ||
`> Β» Canal: ${author.url}\n\n`; | ||
if (!data.status) throw 'Error al procesar el video' | ||
|
||
await conn.reply(m.chat, txt, m); | ||
const caption = `\`βqΛκ°ΰ¦ ππΎππππ±π΄ - π πΈπ³π΄πΎ ΰ»κ±Λqβ\` | ||
κ¨οΈ \`ππππππ\`: ${data.data.title} | ||
κ¨οΈ \`π°ππππ\`: ${data.data.author.name} | ||
κ¨οΈ \`π²ππππ\`: ${data.data.author.url} | ||
κ¨οΈ \`π΄πππππ\`: ${data.data.src_url} | ||
κ¨οΈ \`πΌππππππππ\` ${data.data.picture} | ||
β±βββββ±ΰΌ»ΛΛΛ β‘ ΛΛΛΰΌΊβ°βββββ° | ||
` | ||
|
||
await conn.sendMessage(m.chat, { | ||
video: { url: filePath }, | ||
mimetype: "video/mp4", | ||
fileName: `${title}.mp4`, | ||
quoted: m, | ||
contextInfo: { | ||
'forwardingScore': 200, | ||
'isForwarded': true, | ||
externalAdReply: { | ||
showAdAttribution: true, | ||
title: title, | ||
body: author.name, | ||
mediaType: 2, | ||
sourceUrl: global.canal, | ||
thumbnail: await (await conn.getFile(thumbnail)).data, | ||
mediaType: 1, | ||
showAdAttribution: true, | ||
renderLargerThumbnail: true, | ||
} | ||
} | ||
}, { quoted: m }); | ||
let vres = data.downloads.mp4.url | ||
|
||
await m.react('β '); | ||
let vid = await fetch(vres) | ||
const vidBuffer = await vid.buffer() | ||
|
||
fs.unlink(filePath, (err) => { | ||
if (err) { | ||
console.error(`OcurriΓ³ un error al borrar el archivo de video: ${err}`); | ||
m.react('β'); | ||
} else { | ||
console.log(`Borrando archivo de video: ${filePath}`); | ||
m.react('β '); | ||
} | ||
}); | ||
} catch (error) { | ||
console.error('Error en el proceso:', error); | ||
await conn.reply(m.chat, 'OcurriΓ³ un error al procesar tu solicitud', m); | ||
await m.react('β'); | ||
} | ||
}; | ||
conn.sendFile(m.chat, vidBuffer, 'video.mp4', caption, m, false, { asDocument: false }) | ||
} | ||
|
||
handler.help = ["ytmp4"].map((v) => v + " <link>"); | ||
handler.tags = ['dl']; | ||
handler.command = /^(ytmp4|ytvideo)$/i; | ||
handler.help = ['ytmp4 <yt-link>'] | ||
handler.tags = ['descargador'] | ||
handler.command = ['ytmp4', 'video', 'ytv'] | ||
handler.diamond = false | ||
|
||
export default handler; | ||
export default handler |