Update index.js
Browse files
index.js
CHANGED
|
@@ -15,7 +15,6 @@ const { File } = require('megajs')
|
|
| 15 |
const { BingChat } = require("bing-chat-cjs-rnz");
|
| 16 |
const path = require("path")
|
| 17 |
const fs = require("fs")
|
| 18 |
-
const ytdlp = require('yt-dlp-exec');
|
| 19 |
let fetch;
|
| 20 |
|
| 21 |
(async () => {
|
|
@@ -196,19 +195,21 @@ async function fby2mate(url) {
|
|
| 196 |
}
|
| 197 |
}
|
| 198 |
|
|
|
|
|
|
|
| 199 |
async function ytAPI(url) {
|
| 200 |
try {
|
| 201 |
-
//
|
| 202 |
-
const
|
| 203 |
|
| 204 |
-
//
|
| 205 |
-
const
|
| 206 |
|
| 207 |
// Extract necessary information
|
| 208 |
const videoDetails = {
|
| 209 |
-
title:
|
| 210 |
url: url,
|
| 211 |
-
formats:
|
| 212 |
format_id: format.format_id,
|
| 213 |
ext: format.ext,
|
| 214 |
resolution: format.resolution,
|
|
@@ -235,6 +236,7 @@ async function ytAPI(url) {
|
|
| 235 |
}
|
| 236 |
|
| 237 |
|
|
|
|
| 238 |
// Fungsi untuk mengkonversi video dari YouTube
|
| 239 |
const convert = async (url, v_id, ftype, fquality, fname, token, timeExpire) => {
|
| 240 |
let params = {
|
|
|
|
| 15 |
const { BingChat } = require("bing-chat-cjs-rnz");
|
| 16 |
const path = require("path")
|
| 17 |
const fs = require("fs")
|
|
|
|
| 18 |
let fetch;
|
| 19 |
|
| 20 |
(async () => {
|
|
|
|
| 195 |
}
|
| 196 |
}
|
| 197 |
|
| 198 |
+
const { exec } = require('@distubejs/yt-dlp');
|
| 199 |
+
|
| 200 |
async function ytAPI(url) {
|
| 201 |
try {
|
| 202 |
+
// Eksekusi yt-dlp untuk mendapatkan informasi video
|
| 203 |
+
const { stdout, stderr } = await exec(url, ['--dump-json']);
|
| 204 |
|
| 205 |
+
// Handle output
|
| 206 |
+
const info = JSON.parse(stdout);
|
| 207 |
|
| 208 |
// Extract necessary information
|
| 209 |
const videoDetails = {
|
| 210 |
+
title: info.title,
|
| 211 |
url: url,
|
| 212 |
+
formats: info.formats.map(format => ({
|
| 213 |
format_id: format.format_id,
|
| 214 |
ext: format.ext,
|
| 215 |
resolution: format.resolution,
|
|
|
|
| 236 |
}
|
| 237 |
|
| 238 |
|
| 239 |
+
|
| 240 |
// Fungsi untuk mengkonversi video dari YouTube
|
| 241 |
const convert = async (url, v_id, ftype, fquality, fname, token, timeExpire) => {
|
| 242 |
let params = {
|