Skip to main content

🍉 Watermelon Python Library

PyPI Python License: MIT

A Python terminal music player + SDK for the Watermelon music platform. Free, open-source, no ads.


Features

  • 🔍 Real-time search — results update letter by letter as you type
  • ⬇️ Smart cache loop — downloads one song, plays it, auto-deletes when next starts
  • 🎵 Background playback — minimise the terminal, music keeps playing
  • 🤖 AI recommendations — Gemini 2.5 Flash picks your next song automatically
  • 📻 Radio — stream internet radio stations
  • 📚 History — full SQLite listening history, persisted across sessions
  • 🛠️ SDK — use as a pure Python library in your own code

Install

pip install watermelon-music

Requirements:

  • Python 3.9+
  • ffplay (part of ffmpeg) for audio playback:
    Windows : winget install ffmpeg
    macOS   : brew install ffmpeg
    Linux   : sudo apt install ffmpeg
    

Quick Start

Terminal Player

watermelon

SDK Usage

from watermelon import WatermelonClient, LocalDB

client = WatermelonClient()

# Search
songs = client.search.songs("Arijit Singh")
print(songs[0])  # Kesariya — Arijit Singh

# Get metadata
song = client.songs.get("dQw4w9WgXcQ")
print(song.title, song.duration_str)

# Stream URL (for your own player)
url = client.songs.stream_url("dQw4w9WgXcQ")

# Download to file
path = client.songs.download("dQw4w9WgXcQ", output_path="./song.mp3")

# Search artists / albums / playlists
artists = client.search.artists("AR Rahman")
albums  = client.search.albums("Dilwale Dulhania")

# Radio
stations = client.radio.browse()
hindi    = client.radio.search("hindi")

# AI Recommendations (Gemini 2.5 Flash)
recs = client.ai.recommendations(title="Kesariya", artist="Arijit Singh")
for song in recs:
    print(song)

# Global stats
stats = client.stats.get()
print(stats.total_streams)

# Local database
db = LocalDB()
db.history.add(songs[0], source="search")
history = db.history.recent(limit=20)
top_artists = db.activity.top_artists(limit=10)

Custom Server (Self-Hosted)

client = WatermelonClient(base_url="http://your-server.com:3000")

Or set it permanently in ~/.watermelon/config.json:

{ "base_url": "http://your-server.com:3000" }

Terminal UI Controls

Screen Key Action
Menu ^S Search
Menu ^L Library
Menu ^R Radio
Menu / Settings (lyrics language)
Menu ^Q / Ctrl+C Quit
Menu ↑ / ↓ + Enter Navigate & select
Any screen ^S / ^L / ^R / / Jump straight to Search / Library / Radio / Settings (music keeps playing)
Search Type Update results live
Search ↑ / ↓ Navigate results
Search Enter Play selected song
Search ^R Get AI recommendations
Search ^B / ESC Back to menu
Player ^N Next song
Player ^P Pause / Resume
Player ^U / ^D Volume up / down
Player ^Y Lyrics
Player / Settings
Player ^B / ESC Back to menu
Radio Type Search stations
Radio Enter Stream station
Radio ^B / ESC Back
Library ↑ / ↓ + Enter Navigate & replay
Library ^R Refresh history
Lyrics ↑ / ↓ Scroll lyrics
Lyrics ^Y / ^B Close

Architecture

~/.watermelon/
├── watermelon.db    ← SQLite (history, activity, cache, session)
├── cache/           ← One .mp3 at a time
└── config.json      ← base_url, volume, theme
WatermelonClient
├── .search   → SearchAPI   (/search/songs, /artists, /albums, /playlists)
├── .songs    → SongAPI     (/song/:id, /stream/:id, /download/:id)
├── .radio    → RadioAPI    (/radio/stations, /radio/search)
├── .ai       → AIAPI       (/api/recommendations)
├── .stats    → StatsAPI    (/stats)
└── .auth     → AuthAPI     (/auth/delete-user)

LocalDB
├── .history  → HistoryRepo   (songs_history table)
├── .activity → ActivityRepo  (user_activity table)
├── .cache    → CacheRepo     (cached_songs table)
└── .session  → SessionRepo   (session_state table)

Development

git clone https://github.com/watermelon-music/Watermelon-lib
cd Watermelon-lib
pip install -e ".[dev]"

# Run the player
watermelon

# Run tests
pytest

License

MIT © SatyamPote / watermelon-music

Download files

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

Source Distribution

watermelon_music-0.2.0.tar.gz (61.9 kB view details)

Uploaded Source

Built Distribution

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

watermelon_music-0.2.0-py3-none-any.whl (79.3 kB view details)

Uploaded Python 3

File details

Details for the file watermelon_music-0.2.0.tar.gz.

File metadata

  • Download URL: watermelon_music-0.2.0.tar.gz
  • Upload date:
  • Size: 61.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for watermelon_music-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b745c963cb59f07c8c7c78c9ccf73b13381d1eb9466a75230fcac1b0e2313a0f
MD5 dfe23ceaea0447d6ebb2fc4aef5e3145
BLAKE2b-256 814dfe505b0822dd24fa2c9dabf551a32e51ae11ea73777224a85088ed33c90c

See more details on using hashes here.

File details

Details for the file watermelon_music-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for watermelon_music-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 506d1174d1ab60726a020ce4d0f704db312cb5fc9bb7e2fa46874278a1d40707
MD5 8684d13150eaf242a774bf85573afbe7
BLAKE2b-256 0e17537adab7159c3199eaa57794a6037a46b70044b6f3e1ed0626e697dd386a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page