Technology and education
  • Home
  • Features
  • _Featured Posts
  • _Post Layouts
  • __Left Sidebar
  • __Full Width
  • __Right Sidebar
  • _Contact Page
  • _Error Page
  • _RTL Version
  • Mega Menu
  • Tipography
  • SHARED BY - FC THEMES
Responsive Advertisement
الصفحة الرئيسية

بلا عنوان

byWorld travel guide •فبراير 16, 2025
0
const express = require('express'); const cors = require('cors'); const ytdl = require('ytdl-core'); const app = express(); // Middleware app.use(cors()); app.use(express.json()); // Serve HTML frontend app.get('/', (req, res) => { res.send(` YT Downloader

YouTube Video Downloader

`); }); // API endpoint app.get('/api/download', async (req, res) => { try { const { url, format } = req.query; if (!ytdl.validateURL(url)) { return res.status(400).json({ error: 'Invalid YouTube URL' }); } const info = await ytdl.getInfo(url); const formatFilter = format === 'mp3' ? 'audioonly' : 'videoandaudio'; const formats = ytdl.filterFormats(info.formats, formatFilter); if (formats.length === 0) { return res.status(400).json({ error: 'No formats available' }); } res.json({ downloadLink: formats[0].url }); } catch (error) { res.status(500).json({ error: error.message }); } }); // Start server const PORT = process.env.PORT || 3000; app.listen(PORT, () => console.log(` Server running on http://localhost:${PORT} Required packages: express cors ytdl-core Install with: npm install express cors ytdl-core `));
  • Facebook
  • Twitter

قد تُعجبك هذه المشاركات

إرسال تعليق

أحدث أقدم

Most Recent

Responsive Advertisement
Responsive Advertisement
Responsive Advertisement

Follow Us

Popular Posts

بلا عنوان

فبراير 17, 2025

Comments

Responsive Advertisement
Technology and education

Biography

3/Biography/grid-small

Popular Posts

فبراير 17, 2025
  • Home
  • Privacy policy
  • Disclaimer
  • About Us
  • Contact Us
  • DMCA
Technology and education
  • Home
  • Biography

Menu Footer Widget

  • Home
  • Privacy policy
  • Disclaimer
  • About Us
  • DMCA
  • Contact Us
Responsive Advertisement
Technology and education

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's.

Design by @Your Name
  • Home
  • About
  • Contact
  • RTL Version

Our website uses cookies to improve your experience. Learn more

حسنًا

نموذج الاتصال