# n8n-nodes-youtube-audio

This is an n8n community node that allows you to download audio from YouTube videos directly in your n8n workflows. It uses an advanced browser-based approach with stealth technology to bypass YouTube's bot detection.

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.

[Prerequisites](#prerequisites)  
[Installation](#installation)  
[Operations](#operations)  
[Proxy Support](#proxy-support)  
[Troubleshooting](#troubleshooting)  
[Resources](#resources)  
[License](#license)

## Prerequisites

- [n8n](https://n8n.io/) must be installed and set up.
- Puppeteer and FFmpeg must be installed on your system.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

```bash
npm install n8n-nodes-youtube-audio
```

### Docker Installation

If you're running n8n in Docker, you'll need to ensure that both Puppeteer and FFmpeg are available in your container. You can modify your Dockerfile to include:

````dockerfile
FROM n8nio/base

RUN apt-get update && \
    apt-get install -y ffmpeg chromium \
    # Puppeteer dependencies
    # n8n-nodes-youtube-audio

This is an n8n community node that allows you to download audio from YouTube videos directly in your n8n workflows.

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.

[Prerequisites](#prerequisites)
[Installation](#installation)
[Operations](#operations)
[Proxy Support](#proxy-support)
[Troubleshooting](#troubleshooting)
[Resources](#resources)
[License](#license)

## Prerequisites

- [n8n](https://n8n.io/) must be installed and set up.
- FFmpeg must be installed on your system for audio conversion.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

```bash
npm install n8n-nodes-youtube-audio
````

### Docker Installation

If you're running n8n in Docker, you'll need to ensure that FFmpeg is available in your container. You can modify your Dockerfile to include:

```dockerfile
FROM n8nio/base

RUN apt-get update && \
    apt-get install -y ffmpeg && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Continue with your normal n8n setup
```

## Operations

- **Download YouTube Audio**: Downloads the audio track from a YouTube video and saves it as either MP3 or WAV format.

### Parameters

- **YouTube Video ID or URL**: The full URL or just the ID of the YouTube video.
- **Output Format**: Choose between MP3 or WAV format.
- **Quality**: Select the audio quality (highest or lowest available).
- **Use Proxy**: Enable proxy support for downloading.
- **Proxy URL**: The URL of the proxy server (if proxy is enabled).
- **Proxy Type**: HTTP/HTTPS or SOCKS proxy.
- **Binary Property**: Name of the binary property to store the output file.

## Proxy Support

This node supports both HTTP/HTTPS and SOCKS proxies. You can use proxies to:

- Bypass geo-restrictions
- Avoid rate limiting
- Enhance privacy

Sample proxy format:

```
http://username:password@host:port
```

Example:

```
http://lorenzocastagnone:F37M5uM3og@82.117.252.136:19247
```

## Troubleshooting

### Common Issues:

1. **Error: ENOENT: no such file or directory, open...**  
   Make sure FFmpeg is properly installed on your system and accessible from the path or included with the package.

2. **Download fails with timeout or connection error**  
   Try using a proxy or try a different video. Some videos might be restricted in your region.

3. **Error: Status code: 403**  
   YouTube may be blocking the request. Try using a proxy to bypass the restriction.

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
- [@distube/ytdl-core documentation](https://github.com/distubejs/ytdl-core)

## License

[MIT](https://github.com/yourusername/n8n-nodes-youtube-audio/blob/master/LICENSE.md)
