ilhamdev commited on
Commit
54949ad
·
verified ·
1 Parent(s): 66e4214

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +9 -7
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
- // Fetch the video info
202
- const info = await ytdlp.exec(url, ['--dump-json']);
203
 
204
- // Parse the JSON data
205
- const videoData = JSON.parse(info);
206
 
207
  // Extract necessary information
208
  const videoDetails = {
209
- title: videoData.title,
210
  url: url,
211
- formats: videoData.formats.map(format => ({
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 = {