-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Showing
3 changed files
with
278 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,210 @@ | ||
[ | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281554, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-3PSID", | ||
"path": "/", | ||
"sameSite": "no_restriction", | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "g.a000lAhWu-GUZaq7exVTwtzSLhvxVGRH9kBnDaNnR_vxamLEHywSDpuh_4u0IMMXkfmlR41gVwACgYKAUwSARcSFQHGX2MiJ13O7GGbXa4GD9NYz-nV4BoVAUF8yKrsfy2zd-tE_7-TitOcWKRu0076" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1752830393.003465, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "SIDCC", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": false, | ||
"session": false, | ||
"storeId": null, | ||
"value": "AKEyXzW_OI3BQXUvLE3Zw41FkLQJXAU0D44hqfmSLQ7F-mEvZRaR3vf3uM6ApuqHGZQqJkrZuA" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281383, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "SID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": false, | ||
"session": false, | ||
"storeId": null, | ||
"value": "g.a000lAhWu-GUZaq7exVTwtzSLhvxVGRH9kBnDaNnR_vxamLEHywSkzv40p_7UlIEBwg9t7EASgACgYKAeYSARcSFQHGX2Mirr4E3RptLgDb6Z4r-imF4BoVAUF8yKrHCsixB0xV91ocdHJ_M57k0076" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1752830302.591556, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-1PSIDTS", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "sidts-CjIB4E2dkessW4GfZxT0TyYMdSMDlBtnlghKt_VcC1_h75x7UVZVbH9beKjwzzApgNelrxAA" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281629, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "SAPISID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "D55ljsvXVKPt5Iwv/A0ZBb7RO3ZJo0AqOX" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1752830393.003737, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-1PSIDCC", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "AKEyXzVbS0_DT2n2eFOqSWxit1kf7nL6cXzo7g9jcafDQpknmhzU3Aj0ytKXbN9NW1mOAaNh" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281593, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "SSID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "ASVG7IGSVZwKvwZ-s" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281649, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "__Secure-1PAPISID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "D55ljsvXVKPt5Iwv/A0ZBb7RO3ZJo0AqOX" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281532, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-1PSID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "g.a000lAhWu-GUZaq7exVTwtzSLhvxVGRH9kBnDaNnR_vxamLEHywSTPqtNkWQD3MS1DHpjnddDgACgYKAWMSARcSFQHGX2Mi6molbIcFs__ct_-qaJMK8hoVAUF8yKrQqU4ZvsRfLilZfhlzlJ4m0076" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281668, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "__Secure-3PAPISID", | ||
"path": "/", | ||
"sameSite": "no_restriction", | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "D55ljsvXVKPt5Iwv/A0ZBb7RO3ZJo0AqOX" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1752830393.003927, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-3PSIDCC", | ||
"path": "/", | ||
"sameSite": "no_restriction", | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "AKEyXzWrfUPi45Mv2FDX99liJd8ZspPhTDKJiXJoFhuV-k45YdrsDpZXJRxZqjOIHzoMLfrZ" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1752830302.59167, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "__Secure-3PSIDTS", | ||
"path": "/", | ||
"sameSite": "no_restriction", | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "sidts-CjIB4E2dkessW4GfZxT0TyYMdSMDlBtnlghKt_VcC1_h75x7UVZVbH9beKjwzzApgNelrxAA" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281611, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "APISID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": false, | ||
"session": false, | ||
"storeId": null, | ||
"value": "2v56EMUfsI9rbu6i/AxzQ5Qg8OLMP9Xods" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753936834.281575, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "HSID", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": false, | ||
"session": false, | ||
"storeId": null, | ||
"value": "Ar2IamUQkoYKxTJvp" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1753938447.765229, | ||
"hostOnly": false, | ||
"httpOnly": true, | ||
"name": "LOGIN_INFO", | ||
"path": "/", | ||
"sameSite": "no_restriction", | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "AFmmF2swRAIgcSBc-4tnorOufu0fek4nl2a4PiCONRkF7rtsJ4UD1y4CIDkWVU1j1Y15ZfD7ARnQOPUfM6A7KnfFO36ca_zrPOD1:QUQ3MjNmeEs3NXpRbDdhMjEya0pfeE1SVEE0R2pvMVlKaEY1OVNRem9LQWExck4teVNmc2N2a25oNnNtaGdWZUNNOHVCZEQzODV5WEx4c2xEOEhEZ1ZWalNRajBqUlY1Tm5Qb2F4b2JXaVhZWGwxYlpsTVRaMDRjQnE2MzFTRW5kbDRWTEJQVGRsY1dQd2tCX1NGMEdWMGJIT2F1d1RXdUFR" | ||
}, | ||
{ | ||
"domain": ".youtube.com", | ||
"expirationDate": 1755854395.612955, | ||
"hostOnly": false, | ||
"httpOnly": false, | ||
"name": "PREF", | ||
"path": "/", | ||
"sameSite": null, | ||
"secure": true, | ||
"session": false, | ||
"storeId": null, | ||
"value": "tz=Asia.Calcutta" | ||
} | ||
] |
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
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,38 +1,79 @@ | ||
import fs from 'fs' | ||
import os from 'os' | ||
import fetch from 'node-fetch' | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import ytdl from 'youtubedl-core'; | ||
import { Client } from 'undici'; | ||
import { fileURLToPath } from 'url'; | ||
import fetch from 'node-fetch'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
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 `✳️ Example:\n${usedPrefix + command} https://youtu.be/YzkTFFwxtXI` | ||
if (!args[0].match(/youtu/gi)) throw `❎ Verify that the YouTube link` | ||
let chat = global.db.data.chats[m.chat]; | ||
if (!args || !args[0]) throw `✳️ Example:\n${usedPrefix + command} https://youtu.be/YzkTFFwxtXI`; | ||
if (!args[0].match(/youtu/gi)) throw `❎ Verify that the YouTube link`; | ||
await m.react('⏳') | ||
|
||
var ggapi = `https://vihangayt.me/download/ytmp4?url=${encodeURIComponent(args)}` | ||
const videoDetails = await ytddl(args[0]); | ||
if (!videoDetails) throw `❎ Error downloading video`; | ||
|
||
const response = await fetch(ggapi) | ||
if (!response.ok) { | ||
console.log('Error searching for song:', response.statusText) | ||
throw 'Error searching for song' | ||
} | ||
const data = await response.json() | ||
const { url, title, author, description } = videoDetails; | ||
|
||
const response = await fetch(url); | ||
const data = await response.buffer(); | ||
|
||
const caption = `✼ ••๑⋯❀ Y O U T U B E ❀⋯⋅๑•• ✼ | ||
❏ Title: ${data.data.title} | ||
❒ Link: ${args[0]} | ||
⊱─━⊱༻●༺⊰━─⊰` | ||
let vres = data.data.vid_360p | ||
❏ Title: ${title || 'Unknown'} | ||
❒ Author: ${author || 'Unknown'} | ||
❒ Description: ${description || 'No description available'} | ||
❒ Link: ${args[0]} | ||
⊱─━⊱༻●༺⊰━─⊰`; | ||
|
||
conn.sendFile(m.chat, data, `${title || 'video'}.mp4`, caption, m, false, { asDocument: chat.useDocument }); | ||
await m.react('✅') | ||
}; | ||
|
||
|
||
handler.help = ['ytmp4 <yt-link>']; | ||
handler.tags = ['downloader']; | ||
handler.command = ['ytmp4', 'video', 'ytv']; | ||
handler.diamond = false; | ||
|
||
let vid = await fetch(vres) | ||
const vidBuffer = await vid.buffer() | ||
export default handler; | ||
|
||
conn.sendFile(m.chat, vidBuffer, `error.mp4`, caption, m, false, { asDocument: chat.useDocument }) | ||
async function getCookies() { | ||
const cookiesPath = path.resolve(__dirname, '../Assets/cookies.json'); | ||
if (!fs.existsSync(cookiesPath)) { | ||
throw new Error('Cookies file not found'); | ||
} | ||
return JSON.parse(fs.readFileSync(cookiesPath, 'utf-8')); | ||
} | ||
|
||
async function createClient() { | ||
const cookies = await getCookies(); | ||
return new Client("https://www.youtube.com", { | ||
headers: { | ||
"Cookie": cookies.map(cookie => `${cookie.name}=${cookie.value}`).join('; ') | ||
} | ||
}); | ||
} | ||
|
||
handler.help = ['ytmp4 <yt-link>'] | ||
handler.tags = ['downloader'] | ||
handler.command = ['ytmp4', 'video', 'ytv'] | ||
handler.diamond = false | ||
async function ytddl(url) { | ||
try { | ||
const client = await createClient(); | ||
const yt = await ytdl.getInfo(url, { requestOptions: { client: client } }); | ||
const link = ytdl.chooseFormat(yt.formats, { quality: 'highest', filter: 'audioandvideo' }); | ||
|
||
return { | ||
url: link.url, | ||
title: yt.videoDetails.title, | ||
author: yt.videoDetails.author.name, | ||
description: yt.videoDetails.description, | ||
}; | ||
} catch (error) { | ||
console.error("An error occurred:", error); | ||
return null; // Ensure a null is returned on error | ||
} | ||
} | ||
|
||
export default handler |