Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 Internal Server Error When Streaming Audio from YouTube URL #1304

Open
fsholehan opened this issue Jul 26, 2024 · 1 comment
Open

500 Internal Server Error When Streaming Audio from YouTube URL #1304

fsholehan opened this issue Jul 26, 2024 · 1 comment

Comments

@fsholehan
Copy link

I have an endpoint that streams audio from a YouTube URL using ytdl-core. It works fine locally, but I encounter a 500 Internal Server Error on the server. Here's my code:

const express = require('express');
const ytdl = require('ytdl-core');

const app = express();

app.get('/audio', (req, res) => {
    const videoUrl = req.query.url;

    if (!videoUrl) {
        return res.status(400).send('Video URL is required');
    }

    res.header('Content-Type', 'audio/mpeg');

    ytdl(videoUrl, { filter: 'audioonly' })
        .on('error', (err) => {
            console.error('Error:', err);
            res.status(500).send('Error streaming audio');
        })
        .pipe(res);
});

app.listen(3000, () => {
    console.log('Server is running on port 3000');
});

Could someone help identify potential causes and solutions for this issue?

@Dmytro-Tihunov
Copy link

Dmytro-Tihunov commented Jul 26, 2024

everyone almost have the same, it happened because youtube ask for captcha #1295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants