# YouTube to MP3 Downloader

A simple web application to download YouTube videos as MP3 files.

## Features

- Clean, modern UI
- Direct MP3 download from YouTube URLs
- Automatic file cleanup (files older than 1 hour are deleted)
- Mobile responsive design
- robots.txt configured to block search engine crawlers
- Meta tags to prevent search engine indexing

## Setup Instructions for cPanel

### 1. Upload Files

Upload all files to your `public_html` directory (or your domain's root directory):
- `index.html`
- `download.php`
- `style.css`
- `robots.txt`
- `.htaccess` (optional, for Apache servers)

### 2. Install yt-dlp or youtube-dl

You need to install `yt-dlp` (recommended) or `youtube-dl` on your server:

**Option A: Using SSH (if available)**
```bash
# For yt-dlp (recommended)
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
chmod a+rx /usr/local/bin/yt-dlp

# OR for youtube-dl
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
```

**Option B: Using cPanel File Manager**
1. Download yt-dlp from: https://github.com/yt-dlp/yt-dlp/releases/latest
2. Upload it to `/usr/local/bin/` or your home directory
3. Set execute permissions (chmod 755)

**Option C: Check if already installed**
Many shared hosting providers already have `youtube-dl` installed. Check with:
```bash
which youtube-dl
which yt-dlp
```

### 3. Set Permissions

The `downloads` directory will be created automatically by PHP with proper permissions. If you need to create it manually:
```bash
mkdir downloads
chmod 755 downloads
```

### 4. Install FFmpeg (Required for MP3 conversion)

Most shared hosting providers have FFmpeg installed. If not, contact your hosting provider or install it:

```bash
# Check if FFmpeg is installed
ffmpeg -version
```

If FFmpeg is not available, yt-dlp will try to use alternative methods, but MP3 conversion may fail.

### 5. Test the Application

1. Visit your website URL
2. Paste a YouTube URL
3. Click "Download MP3"
4. If you get an error about yt-dlp/youtube-dl not found, you'll need to install it (see step 2)

## File Structure

```
public_html/
├── index.html          # Main page
├── download.php        # Backend processing script
├── style.css          # Styling
├── robots.txt         # Blocks search engines
├── .htaccess          # Apache configuration (optional)
└── downloads/         # Auto-created directory for MP3 files
```

## Security Notes

- The `robots.txt` file blocks all search engine crawlers from indexing your site
- Meta tags in HTML also prevent indexing (`noindex, nofollow`)
- Files are automatically deleted after 1 hour
- Maximum file size is set to 100MB
- Input validation is performed on YouTube URLs

## Troubleshooting

**Error: "yt-dlp or youtube-dl not found"**
- Install yt-dlp or youtube-dl on your server (see Setup Step 2)

**Error: "Download failed"**
- Check if FFmpeg is installed
- Verify the YouTube URL is valid
- Check server error logs for more details
- Some shared hosts disable shell_exec - contact your hosting provider

**Files not downloading**
- Check that the `downloads` directory has write permissions (chmod 755)
- Verify PHP's `exec()` function is not disabled in php.ini

## Legal Notice

This tool is for personal use only. Please respect YouTube's Terms of Service and copyright laws. Users are responsible for ensuring they have the right to download content.
