Skip to content

About

High-performance Python Scraper, RESTful API (FastAPI) & SDK for Kevin MacLeod's Incompetech Royalty-Free Music Catalog with official CC BY 4.0 credit generator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

3 Commits

Folders and files

Repository files navigation

🎼 Incompetech Royalty-Free Music Scraper & RESTful API

A high-performance Python Scraper, RESTful API (FastAPI), Python SDK, and CLI for Kevin MacLeod's 1,440+ track Incompetech catalog.
Automated metadata enrichment, direct MP3 streaming/download links, ISRC tracking, and official Creative Commons Attribution 4.0 (CC BY 4.0) credit generator.

Author Ryan Arya Pramudya FastAPI Python License MIT CC BY 4.0

Key Features β€’ Licensing & Credits β€’ Installation β€’ REST API Reference β€’ Python SDK β€’ CLI β€’ Author & Credits


🌟 Key Features

  • πŸš€ Zero-Bottleneck ETL Scraper: Ingests and normalizes the full master catalog (~1,443 tracks) directly from Incompetech's authoritative endpoints without hitting Cloudflare/rate limits.
  • 🎯 Enriched Metadata: Resolves numeric genre IDs into official genre titles (24 genres), maps album collections and categories, parses multi-mood tags (feels), and converts durations into integer seconds for precise numerical range queries.
  • πŸ“œ Official CC BY 4.0 Credit Generator: Instantly produces Kevin MacLeod's official attribution blocks ready for copy-paste in Plain Text, Markdown, and HTML formats (supports both single-track and bulk multi-track productions).
  • 🎧 Direct High-Quality MP3 Streams: Resolves direct audio URLs on Incompetech's servers with full HTTP byte-range seeking support (ideal for HTML5 <audio>, podcasts, video editors, and audio pipelines).
  • ⚑ Asynchronous REST API: Powered by FastAPI with auto-generated interactive OpenAPI/Swagger UI (/docs) and ReDoc (/redoc).
  • πŸ“¦ Dual-Mode Python SDK (client.py): Seamlessly imports into video automation pipelines (MoviePy, FFmpeg bots, YouTube generation scripts) in Local Direct Mode (zero latency, no HTTP server needed) or Remote HTTP Mode.
  • πŸ› οΈ Feature-Packed CLI (cli.py): Search tracks, inspect detailed metadata, copy credits, download MP3s, and calculate commercial license fees directly from the terminal.
  • πŸ“Š Dual Format Export: Automatically dumps the complete dataset to data/catalog_enriched.json (~2.9 MB) and data/catalog_enriched.csv (~700 KB) for analytics and spreadsheet processing.

πŸ›οΈ System Architecture

flowchart TD
    subgraph Incompetech_Source ["🌐 Incompetech.com Master Endpoints"]
        A[pieces.json<br>1,443 tracks]
        B[genre.json<br>24 genres]
        C[collections.json<br>50 collections]
        D[mp3-royaltyfree/<br>Direct MP3 Files]
    end

    subgraph ETL_Scraper ["βš™οΈ Scraper & Enrichment Engine (scraper.py)"]
        E[Data Normalizer]
        F[Duration Parser to Seconds]
        G[Genre & Album Mapper]
        H[CC BY 4.0 Credit Generator]
    end

    subgraph Local_Cache ["πŸ’Ύ Local Datasets (data/)"]
        I[(catalog_enriched.json)]
        J[(catalog_enriched.csv)]
    end

    subgraph Core_Service ["⚑ Service Layer (service.py)"]
        K[O 1 In-Memory Indices<br>ISRC, Filename, Title]
        L[Search & Multi-Filter Engine]
        M[Standard License Pricing Engine]
    end

    subgraph Access_Layers ["πŸš€ Client Access Interfaces"]
        N[FastAPI REST Server<br>app.py :8000]
        O[Python Client SDK<br>client.py]
        P[Terminal CLI Tool<br>cli.py]
    end

    A & B & C --> E
    E --> F & G & H
    F & G & H --> I & J
    I --> K
    K --> L & M
    L & M --> N & O & P
    D -. Stream/Download .-> N & O & P
Loading

πŸ“œ Licensing, Royalties & Attribution Guide

A comprehensive technical and legal analysis is documented in ANALISIS_WEBSITE.md.

All musical compositions and master sound recordings on Incompetech are composed and owned by Kevin MacLeod. The music is copyrighted and is NOT Public Domain (with the exception of FreePD tracks).

What "Royalty-Free" means: You do NOT have to pay recurring royalties per view, per stream, or per sale of your product.

1. Creative Commons Attribution 4.0 (CC BY 4.0) β€” Free ($0)

  • Cost: $0 (100% Free).
  • Commercial Use: Fully permitted (monetized YouTube videos, paid Steam/App Store/Play Store games, sponsored podcasts, commercial streams, indie films).
  • Modifications & Derivatives: You may cut, splice, loop, compress, speed up, sing over, or add instruments. If you only cut/loop, no special mention is needed. If you add vocals or new instruments, you must state in the credits which parts are yours and which parts are Kevin's.
  • Mandatory Condition: You MUST provide clear attribution/credit.

Official Attribution Format:

A. Single Track:

"Title of Track" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/

B. Multiple Tracks:

"Track 1", "Track 2", "Track 3"
Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0
http://creativecommons.org/licenses/by/4.0/

C. HTML Web Embed:

<p>
  &ldquo;Title of Track&rdquo; Kevin MacLeod (<a href="https://incompetech.com" target="_blank" rel="noopener">incompetech.com</a>)<br>
  Licensed under Creative Commons: By Attribution 4.0 License<br>
  <a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener">http://creativecommons.org/licenses/by/4.0/</a>
</p>

Placement Guidelines by Platform:

Platform / Media Proper Credit Location
YouTube / Vimeo In the video description box or inside the closing credits of the video.
Twitch / Streaming In your profile/channel panels under a dedicated "Music" section, or via a chatbot !music command.
Video Games On the "Credits" screen accessible via the Settings/Options menu or end-game credits roll.
Films / Television In the credit roll (either opening or closing credits).
Podcasts / Audio Voiced aloud (voice-over credit) at the end of the episode or written in the episode show notes.
Live Stage / Theater In the printed event program or via a voice announcement.

2. Standard License (Paid β€” No Attribution Required)

Required if your format cannot or does not want to include credits (e.g., 30-second TV/radio commercials, corporate on-hold phone music, internal presentations under strict NDA):

  • 1 Track: $30 flat
  • 2 Tracks: $50 ($25/track)
  • 3 to 18 Tracks: $20 per track (e.g., 5 tracks = $100, 10 tracks = $200).
  • Terms: Non-exclusive, worldwide, in perpetuity for the named production title.
  • Official Payment: Direct via PayPal to payments@incompetech.com.

3. Copyright Disputes & ISRC Numbers

Every track has an allocated ISRC (International Standard Recording Code, e.g., USUAN1100772).

  • If an automated bot or third-party rights aggregator submits a false Content ID claim on your YouTube video, file a Dispute referencing the track title, official ISRC, and the CC BY 4.0 legal text (https://creativecommons.org/licenses/by/4.0/legalcode.en).
  • For Spotify podcast flags: Kevin MacLeod's official representative is "Kelvin Ruijters t/as Frequency", escalation email: support@frequencydigital.com.

πŸš€ Quickstart & Installation

1. Clone the Repository

git clone https://github.com/ryanaryapramudya/Incompetech-api.git
cd Incompetech-api

2. Create Virtual Environment & Install Dependencies

python3 -m venv .venv
source .venv/bin/activate  # macOS / Linux
# .venv\Scripts\activate   # Windows

pip install -r requirements.txt

3. Run the Scraper

python scraper.py

Fetches the remote catalog, joins all metadata, and saves enriched datasets to data/.

4. Start the REST API Server

python cli.py serve --port 8000

Open your browser to explore the interactive Swagger documentation:
πŸ‘‰ http://localhost:8000/docs


πŸ“‘ REST API Documentation

Method Endpoint Description
GET / API status, catalog summary statistics, and license overview.
GET /api/tracks Search & filter tracks (query, genre, feel, BPM range, duration range, pagination).
GET /api/tracks/{id} Retrieve track metadata by ISRC code, filename, or title.
GET /api/tracks/{id}/credits Get official attribution snippet in json, text, markdown, or html format.
GET /api/tracks/{id}/download HTTP 302 redirect directly to the official MP3 stream/download URL.
POST /api/credits/bulk Generate combined CC BY 4.0 credits for multiple tracks.
POST /api/license/standard-calculator Calculate paid Standard License pricing & preview legal contract terms.
GET /api/genres List all 24 musical genres with track counts.
GET /api/feels List all mood/feel tags with track frequencies.
GET /api/collections List all album collections and categories.
GET /api/stats Aggregate catalog statistics (BPM average, duration ranges, etc.).
POST /api/sync Force re-sync the catalog from incompetech.com.

cURL Examples:

1. Filter High-Energy Soundtrack Music (>120 BPM with "Action" Mood)

curl -s "http://localhost:8000/api/tracks?feel=Action&min_bpm=120&page_size=3" | jq

2. Get Copy-Paste Attribution Credit (Plain Text)

curl -s "http://localhost:8000/api/tracks/USUAN1100772/credits?format=text"

Response:

"Sneaky Snitch" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/

3. Direct Audio Download

curl -L -O "http://localhost:8000/api/tracks/USUAN1100772/download"

4. Bulk Credit Generator

curl -X POST "http://localhost:8000/api/credits/bulk" \
  -H "Content-Type: application/json" \
  -d '{
    "titles": ["Carefree", "Sneaky Snitch"],
    "derivative_notes": "Trimmed and looped for video game intro"
  }' | jq

🐍 Python SDK (client.py)

You can import IncompetechClient directly into Python scripts (video editors, voiceover bots, podcast pipelines) without even running an HTTP server:

from client import IncompetechClient

# Initialize client (Local Direct Mode - zero overhead, instant response)
client = IncompetechClient()

# 1. Search tracks by mood and tempo
results = client.search(feel="Suspenseful", min_bpm=90, page_size=5)
for track in results["items"]:
    print(f"[{track['isrc']}] {track['title']} ({track['length']}) - {track['bpm']} BPM")
    print(f"Direct MP3: {track['direct_download_url']}")

# 2. Lookup track by ISRC code
track = client.get_track("USUAN1100772")
print("Title:", track["title"])
print("Instruments:", track["instruments"])

# 3. Retrieve formatted attribution snippet
credit_text = client.get_credits("USUAN1100772", format="plain_text")
print(credit_text)

# 4. Download high-quality MP3 file locally
mp3_file = client.download_track("USUAN1100772", dest_folder="./downloads")
print(f"Saved audio to: {mp3_file}")

# 5. Generate bulk credits for multiple tracks
bulk = client.generate_bulk_credits(
    titles=["Sneaky Snitch", "Carefree"],
    derivative_notes="Custom vocal added by Creator"
)
print(bulk["plain_text"])

Remote HTTP Mode: If your FastAPI server is deployed remotely, simply pass the base_url:

client = IncompetechClient(base_url="https://api-incompetech.yourdomain.com")

πŸ’» Command Line Interface (CLI)

Use cli.py to search, inspect tracks, copy credits, or download music straight from your terminal:

# 1. Search catalog by keyword
python cli.py search "dungeon" --limit 5

# 2. Filter by genre, mood, and BPM
python cli.py search --genre "Electronica" --feel "Dark" --min-bpm 120

# 3. Display full track card and description
python cli.py info "Sneaky Snitch"

# 4. Generate attribution credits for one or more tracks
python cli.py credit "Carefree" "Monkeys Spinning Monkeys"

# 5. Output credit in Markdown format
python cli.py credit "Sneaky Snitch" --format markdown

# 6. Download track MP3 to a local directory
python cli.py download "Sneaky Snitch" --dest ./my_audio

# 7. Calculate commercial Standard License costs (no attribution)
python cli.py license 4 --company "Indie Game Studios" --title "Pixel Dungeon"

# 8. View catalog metrics & stats
python cli.py stats

πŸ§ͺ Automated Testing

The project includes an automated test suite covering the ETL scraper, service layer, FastAPI routes, credit formats, and SDK:

PYTHONPATH=. pytest tests/test_api.py -v

Test results:

tests/test_api.py::test_service_catalog_loaded PASSED                    [  7%]
tests/test_api.py::test_service_lookup_by_isrc PASSED                    [ 14%]
tests/test_api.py::test_service_lookup_by_filename_and_title PASSED      [ 21%]
tests/test_api.py::test_service_search_filtering PASSED                  [ 28%]
tests/test_api.py::test_bulk_credits_generation PASSED                   [ 35%]
tests/test_api.py::test_standard_license_calculator PASSED               [ 42%]
tests/test_api.py::test_api_root PASSED                                  [ 50%]
tests/test_api.py::test_api_tracks_search PASSED                         [ 57%]
tests/test_api.py::test_api_track_detail PASSED                          [ 64%]
tests/test_api.py::test_api_track_credits_formats PASSED                 [ 71%]
tests/test_api.py::test_api_download_redirect PASSED                     [ 78%]
tests/test_api.py::test_api_bulk_credits PASSED                          [ 85%]
tests/test_api.py::test_api_genres_and_stats PASSED                      [ 92%]
tests/test_api.py::test_python_client_local_mode PASSED                  [100%]

============================== 14 passed in 0.29s ==============================

πŸ‘¨β€πŸ’» Author & Credits

Developed by:

Ryan Arya Pramudya
GitHub: @ryanaryapramudya β€’ Email: pramudyaryan5@gmail.com


Music Composer & Copyright Attribution:

All musical compositions and master sound recordings are composed by:
Kevin MacLeod β€” incompetech.com
Special gratitude to Kevin MacLeod for his monumental contribution to millions of content creators, game developers, and filmmakers worldwide.


πŸ“„ Code License

This software project is licensed under the MIT License.
Musical works cataloged and streamed by this project remain subject to Kevin MacLeod's Creative Commons Attribution 4.0 International (CC BY 4.0) license or separate commercial Standard Licenses.

About

High-performance Python Scraper, RESTful API (FastAPI) & SDK for Kevin MacLeod's Incompetech Royalty-Free Music Catalog with official CC BY 4.0 credit generator

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages