Skip to content

Commit

Permalink
Update ytv.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SkulZOnTheYT authored Nov 12, 2023
1 parent f5e8b4b commit b509907
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions plugins/download/ytv.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ytdl from 'ytdl-core'
import { niceBytes } from '../../lib/func.js'
import { youtubedl } from '@bochilteam/scraper-sosmed'

let handler = async (m, { conn, args, usedPrefix, command }) => {
Expand All @@ -9,21 +11,55 @@ let handler = async (m, { conn, args, usedPrefix, command }) => {
let url = await data.download()
if (data.fileSize > 400000) return m.reply(`Filesize: ${data.fileSizeH}\nTidak dapat mengirim, maksimal file 400 MB`)
let txt = `*${anu.title}*\n\n`
txt += `⭔ Watch : ${args[0]}\n`
txt += `⭔ Resolution : ${data.quality}\n`
txt += `⭔ Size : ${data.fileSizeH}`
+ `⭔ Watch : ${args[0]}\n`
+ `⭔ Resolution : ${data.quality}\n`
+ `⭔ Size : ${data.fileSizeH}`
await conn.sendFile(m.chat, url, `${anu.title}.mp4`, txt, m)
} catch (e) {
console.log(e)
m.reply(`Invalid Youtube URL / terjadi kesalahan.`)
try {
let res = await ytdl.getURLVideoID(args[0])
let anu = await ytdl.getInfo(res)
let data, det = anu.videoDetails
for (let x of ['360','480','240']) {
if (!data) data = anu.formats.find(v => v.mimeType.includes('video') && v.audioBitrate !== null && (v.qualityLabel || '').includes(x))
}
if (!data) throw Error()
let size = parseInt(data.bitrate)
let buffer = Buffer.from(await (await fetch(data.url)).arrayBuffer())
let buffl = Buffer.byteLength(buffer)
if (size > 400000000) return m.reply(`Filesize: ${niceBytes(buffl)}\nTidak dapat mengirim, maksimal file 400 MB`)
let txt = `*${det.title}*\n\n`
+ `⭔ Watch : ${args[0]}\n`
+ `⭔ Resolution : ${data.width} x ${data.height}\n`
+ `⭔ Size : ${niceBytes(buffl)}`
await conn.sendFile(m.chat, buffer, `${det.title}.mp4`, txt, m)
} catch (e) {
console.log(e)
try {
let anu = await (await fetch(`https://api.akuari.my.id/downloader/yt1?link=${args[0]}`)).json()
let size = anu.urldl_video.size
let vs = parseInt(size)
if (isNaN(vs)) vs = 1
if (vs > 400 && /mb|gb/i.test(size)) return m.reply(`Filesize: ${size}\nTidak dapat mengirim, maksimal file 400 MB`)
let txt = `*${anu.info.title}*\n\n`
+ `⭔ Watch : ${args[0]}\n`
+ `⭔ Resolution : ${anu.urldl_video.quality}\n`
+ `⭔ Size : ${size}`
await conn.sendFile(m.chat, anu.urldl_video.link, `${anu.info.title}.mp4`, txt, m)
} catch (e) {
console.log(e)
throw 'invalid url / internal server error.'
}
}
}
}

handler.help = ['ytvideo <url>']
handler.tags = ['download']
handler.menudownload = ['ytvideo <url>']
handler.tagsdownload = ['search']
handler.command = /^(yt(v(ideo)?|mp4))$/i

handler.premium = true
handler.premium = false
handler.limit = true

export default handler
export default handler

0 comments on commit b509907

Please sign in to comment.