Skip to main content

Download MP3s from YouTube playlists with FastAPI backend and web interface

Project description

FetchYT ๐ŸŽต

Download MP3s from YouTube playlists with a modern web interface and CLI tool.

Python 3.12+ License: CC BY-NC-SA 4.0

Features

  • ๐Ÿ“ฅ Download MP3s from YouTube videos and playlists
  • ๐ŸŒ Web Interface with dark mode design
  • ๐Ÿ–ฅ๏ธ CLI Tool for terminal usage
  • ๐Ÿš€ FastAPI Backend for scalability
  • ๐Ÿ“ฆ Easy Installation via PyPI
  • ๐ŸŽจ Multiple Format Support (MP3, M4A, WAV)
  • โšก Quality Options (128, 192, 256, 320 kbps)

Installation

From PyPI

# Using uv (recommended - faster)
uv pip install fetchyt

# Or using pip
pip install fetchyt

From Source

git clone https://gitlab.com/allikapub/fetchyt.git
cd fetchyt

# Using uv (recommended)
uv pip install -e .

# Or using pip
pip install -e .

Development Setup

# Clone the repository
git clone https://gitlab.com/allikapub/fetchyt.git
cd fetchyt

# Using uv (recommended - much faster)
uv venv
source .venv/bin/activate  # Linux/macOS
.venv\Scripts\activate     # Windows
uv pip install -e ".[dev]"

# Or using pip
pip install -e ".[dev]"

Quick Start

CLI Usage

# Download a single video
fetchyt download "https://www.youtube.com/watch?v=VIDEO_ID"

# Download a playlist
fetchyt download "https://www.youtube.com/playlist?list=PLAYLIST_ID"

# Download with custom quality and format
fetchyt download "URL" --format m4a --quality 320

# Get information without downloading
fetchyt info "URL"

# Start web server
fetchyt server --port 8098

Web Interface

Start the web server:

fetchyt server

Then open your browser and navigate to http://localhost:8098

Python API

import asyncio
from fetchyt import YouTubeDownloader

async def main():
    downloader = YouTubeDownloader()
    
    # Extract information
    videos = await downloader.extract_info("YOUTUBE_URL")
    print(f"Found {len(videos)} videos")
    
    # Download
    task_id = await downloader.download(
        url="YOUTUBE_URL",
        format="mp3",
        quality="192"
    )
    print(f"Download started: {task_id}")

asyncio.run(main())

CLI Commands

Download Command

fetchyt download <URL> [OPTIONS]

Options:
  -f, --format    Audio format: mp3, m4a, wav (default: mp3)
  -q, --quality   Audio quality: 128, 192, 256, 320 kbps (default: 192)
  -o, --output    Output directory (default: ./downloads)
  -y, --yes       Skip confirmation prompt

Info Command

fetchyt info <URL>

Get information about videos without downloading.

Cookies Command

Extract YouTube cookies directly from your browser to bypass bot detection:

# Chrome/Chromium
fetchyt cookies --browser chrome --output cookies.txt

# Firefox
fetchyt cookies --browser firefox --output cookies.txt

# Use the cookies in FetchYT
# PowerShell (Windows)
$env:COOKIES_FILE = "./cookies.txt"
# bash (Linux/macOS)
export COOKIES_FILE=./cookies.txt

# Then run
fetchyt info "<URL>"
fetchyt download "<URL>"

Server Command

print(f"Download started: {task_id}")

asyncio.run(main()) Options: --host Server host (default: 0.0.0.0) --port Server port (default: 8098)


## API Endpoints

When running as a server, FetchYT provides the following REST API endpoints:

- `GET /` - Web interface
- `POST /api/v1/extract` - Extract video/playlist information
- `POST /api/v1/download` - Start download
- `GET /api/v1/status/{task_id}` - Check download status
- `DELETE /api/v1/task/{task_id}` - Cleanup completed task
- `GET /health` - Health check endpoint
- `GET /docs` - Interactive API documentation

## Using uv (Recommended)

This project supports **uv**, a blazingly fast Python package installer (10-100x faster than pip). The setup scripts will automatically install and use uv. For detailed uv usage, see [UV_GUIDE.md](UV_GUIDE.md).

## Configuration

FetchYT can be configured using environment variables:

```bash
# API Configuration
export API_HOST=0.0.0.0
export API_PORT=8098

# Download Configuration
export DOWNLOAD_DIR=./downloads
export MAX_CONCURRENT_DOWNLOADS=3
export COOKIES_FILE=./cookies.txt   # Optional: path to exported browser cookies

# Debug Mode
export DEBUG=True

Project Structure

fetchyt/
โ”œโ”€โ”€ fetchyt/
โ”‚   โ”œโ”€โ”€ __init__.py          # Package initialization
โ”‚   โ”œโ”€โ”€ api.py               # FastAPI application
โ”‚   โ”œโ”€โ”€ cli.py               # Command-line interface
โ”‚   โ”œโ”€โ”€ config.py            # Configuration settings
โ”‚   โ”œโ”€โ”€ downloader.py        # YouTube downloader core
โ”‚   โ”œโ”€โ”€ models.py            # Data models
โ”‚   โ””โ”€โ”€ static/              # Web interface
โ”‚       โ”œโ”€โ”€ index.html
โ”‚       โ”œโ”€โ”€ css/
โ”‚       โ”‚   โ””โ”€โ”€ style.css
โ”‚       โ””โ”€โ”€ js/
โ”‚           โ””โ”€โ”€ app.js
โ”œโ”€โ”€ pyproject.toml           # Project configuration
โ”œโ”€โ”€ requirements.txt         # Dependencies
โ”œโ”€โ”€ LICENSE                  # MIT License
โ””โ”€โ”€ README.md               # This file

Requirements

  • Python 3.12+
  • FFmpeg (for audio conversion)
  • uv (recommended) or pip for package management
  • yt-dlp (installed automatically as a dependency)

Troubleshooting (YouTube bot detection)

If you see an error like "Sign in to confirm youโ€™re not a bot":

  • Extract cookies from your browser and set COOKIES_FILE (see Cookies Command above)
  • Wait 10โ€“30 minutes and try again (temporary rate limits)
  • Try a different network or a VPN
  • Use a different browser to export cookies

Learn more: https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies

Installing uv (Recommended)

uv is a blazingly fast Python package installer and resolver:

Windows (PowerShell):

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

Linux/macOS:

curl -LsSf https://astral.sh/uv/install.sh | sh

Learn more: https://github.com/astral-sh/uv

Installing FFmpeg

Windows:

# Using Chocolatey
choco install ffmpeg

# Or download from https://ffmpeg.org/download.html

macOS:

brew install ffmpeg

Linux:

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# Fedora
sudo dnf install ffmpeg

# Arch
sudo pacman -S ffmpeg

Development

Running Tests

pytest

Publishing to PyPI

Prerequisites

  1. Install build tools:
pip install build twine
  1. Create accounts on PyPI and TestPyPI

Build and Upload

# Build the package
python -m build

# Upload to TestPyPI (for testing)
python -m twine upload --repository testpypi dist/*

# Upload to PyPI (production)
python -m twine upload dist/*

Roadmap

  • Resume interrupted downloads
  • Batch download from file
  • Download queue management
  • Progress notifications
  • Subtitle download support
  • Video format support
  • Playlist filtering options
  • Docker support
  • Desktop application (Electron/Tauri)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. See LICENSE for details.

Disclaimer

This tool is for personal use only. Please respect YouTube's Terms of Service and copyright laws. Always ensure you have the right to download content.

Acknowledgments

  • yt-dlp - The powerful YouTube downloader
  • FastAPI - Modern web framework
  • FFmpeg - Multimedia framework

Support

If you encounter any issues or have questions:


Made with โค๏ธ by the FetchYT team

Copyright (c) 2026 Krishnakanth Allika. All rights reserved.

Licensed under CC-BY-NC-SA-4.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fetchyt-0.1.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fetchyt-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file fetchyt-0.1.0.tar.gz.

File metadata

  • Download URL: fetchyt-0.1.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for fetchyt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b532d754d095114748ed64a38e6d776102dda451800d65f1bc2d085a8d8bd8e5
MD5 70e19299127a4118b02cc845e56d057c
BLAKE2b-256 4704f3d99a0d64473f21b6ac39c6e504bcd498ef6d87f90fe71c1cd7518b32e7

See more details on using hashes here.

File details

Details for the file fetchyt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fetchyt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for fetchyt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 952b95f2c769dd40d204aa8cf1c2bf0466d7dbaf58c3d699fcf8ee1d09b38cd6
MD5 aed88537c724fd05472a3ca3f055348e
BLAKE2b-256 2dd18cc7386309417d8ae07d7e3c943721cc23c4ea4653ba1896746b28244a66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page