Update index.js
Browse files196 unmodified lines197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234196 unmodified lines}async function ytAPI(url) {try {// Fetch the video infoconst info = await ytdlp.getInfo(url);// Extract necessary informationconst videoDetails = {title: info.title,url: url,formats: info.formats.map(format => ({format_id: format.format_id,ext: format.ext,resolution: format.resolution,url: format.url}))};// Filter MP4 and MP3 formatsconst mp4Format = videoDetails.formats.find(format => format.ext === 'mp4');const mp3Format = videoDetails.formats.find(format => format.ext === 'mp3');const result = {title: videoDetails.title,url: videoDetails.url,mp4Url: mp4Format ? mp4Format.url : null,mp3Url: mp3Format ? mp3Format.url : null};return result;} catch (error) {console.error('Error fetching video info:', error);throw error;}}196 unmodified lines197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237196 unmodified lines}async function ytAPI(url) {try {// Fetch the video infoconst info = await ytdlp.exec(url, ['--dump-json']);// Parse the JSON dataconst videoData = JSON.parse(info);// Extract necessary informationconst videoDetails = {title: videoData.title,url: url,formats: videoData.formats.map(format => ({format_id: format.format_id,ext: format.ext,resolution: format.resolution,url: format.url}))};// Filter MP4 and MP3 formatsconst mp4Format = videoDetails.formats.find(format => format.ext === 'mp4');const mp3Format = videoDetails.formats.find(format => format.ext === 'mp3');const result = {title: videoDetails.title,url: videoDetails.url,mp4Url: mp4Format ? mp4Format.url : null,mp3Url: mp3Format ? mp3Format.url : null};return result;} catch (error) {console.error('Error fetching video info:', error);throw error;}}
index.js+32-29