loqtek/freeSound
The free, light, self hostable app to download SoundCloud songs as a .mp3
Welcome To Free Sound
The free, light, self hostable app to download SoundCloud songs as a .mp3
Features
- ๐ต Download SoundCloud tracks as MP3 files
- ๐ Display track information (title, artist, duration, plays, likes)
- โก Fast HLS stream processing
- ๐ฑ Simple and light design
Architecture
- Frontend: Next.js 16 with TypeScript and Tailwind CSS
- Backend: FastAPI with async HTTP client and ffmpeg
Quick Start
Note: We do not reccommend setting this up public facing. As of now anyone can download songs and there is no authentication method. Please only use on private or properly secured networks.
Option 1: Docker (Recommended)
The easiest way to run FreeSound is using Docker:
-
Copy the environment file:
cp .env.sample .env
-
Edit
.envfile and configure the settings:# Open .env in your editor and update: # For local Docker setup (services in same network): NEXT_PUBLIC_API_URL=http://backend:8000 # For remote backend (if backend is on different server): # NEXT_PUBLIC_API_URL=http://your-server-ip:8000 # For accessing from host machine (if needed): # NEXT_PUBLIC_API_URL=http://localhost:8000
Note: The
.envfile is gitignoredand won't be committed to the repository. Only.env.sample` is tracked. -
Build and start all services:
docker-compose up -d
-
View logs:
docker-compose logs -f
-
Stop services:
docker-compose down
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
See DOCKER.md for detailed Docker documentation.
Option 2: Manual Setup
Prerequisites
- Node.js 18+ (or Bun)
- Python 3.8+
- ffmpeg installed on your system
1. Install ffmpeg
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install ffmpegmacOS:
brew install ffmpegWindows:
Download from https://ffmpeg.org/download.html
2. Start the Backend
cd backend
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.pyThe backend will run on http://localhost:8000
3. Start the Frontend
In a new terminal:
npm install # or bun install
npm run dev # or bun devThe frontend will run on http://localhost:3000
4. Use the Application
- Open
http://localhost:3000in your browser - Paste a SoundCloud track URL
- Click "Download" to get the MP3 file
Project Structure
freeSound/
โโโ app/ # Next.js frontend
โ โโโ page.tsx # Main page component
โ โโโ layout.tsx # Root layout
โ โโโ globals.css # Global styles
โโโ backend/ # FastAPI backend
โ โโโ main.py # FastAPI application
โ โโโ soundcloud_client.py # SoundCloud API client
โ โโโ downloader.py # Download and conversion handler
โ โโโ config.py # Configuration settings
โ โโโ utils/ # Utility modules
โ โโโ requirements.txt
โโโ README.md
How It Works
- User Input: User pastes a SoundCloud URL in the frontend
- URL Resolution: Backend resolves the URL to get track metadata
- Stream Extraction: Backend extracts the HLS (m3u8) stream URL
- Direct Download: Backend uses ffmpeg to download the HLS stream directly and convert to MP3 (handles authentication automatically)
- Fallback: If direct download fails, falls back to segment-by-segment download
- Download: Frontend receives and downloads the MP3 file
API Endpoints
Backend (FastAPI)
GET /- Health checkGET /health- Health check with ffmpeg statusPOST /download?url=<soundcloud_url>&format=mp3- Download and convert trackGET /track-info?url=<soundcloud_url>- Get track information
Frontend
GET /- Main application page
Configuration
Docker Setup
-
Copy the sample environment file:
cp .env.sample .env
-
Edit
.envand configure:NEXT_PUBLIC_API_URL: The backend API URL that the frontend will use- For Docker:
http://backend:8000(uses Docker service name) - For remote backend:
http://your-server-ip:8000 - For local development:
http://localhost:8000
- For Docker:
Manual Setup
Backend
No configuration needed. The backend automatically extracts client IDs from SoundCloud.
Frontend
Create a .env.local file (optional):
NEXT_PUBLIC_API_URL=http://localhost:8000If not set, defaults to http://localhost:8000
Development
Backend Development
cd backend
python main.py
# or
uvicorn main:app --reloadFrontend Development
npm run dev
# or
bun run devDocumentation
Troubleshooting
Backend Issues
- ffmpeg not found: Install ffmpeg and ensure it's in your PATH
- Connection errors: Check if port 8000 is available
- SoundCloud API errors: Some tracks may be private or restricted
Frontend Issues
- Cannot connect to backend: Ensure backend is running on port 8000
- CORS errors: Backend CORS is configured to allow all origins in development
- Download not working: Check browser console and backend logs
License
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This project is for educational & learning purposes. Please respect SoundCloud's terms of service and copyright laws.