🍉 Watermelon Python Library
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
Metadata
Release files for watermelon-music 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| watermelon_music-0.2.0.tar.gz | 61.9 kB | Without provenance | Details for watermelon_music-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| watermelon_music-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for watermelon_music-0.2.0-py3-none-any.whl |
Total release size: 141.3 kB
Release files / watermelon_music-0.2.0.tar.gz
| Download URL | watermelon_music-0.2.0.tar.gz |
|---|---|
| Size | 61.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b745c963cb59f07c8c7c78c9ccf73b13381d1eb9466a75230fcac1b0e2313a0f
|
|
BLAKE2b-256 checksum How to use checksums |
814dfe505b0822dd24fa2c9dabf551a32e51ae11ea73777224a85088ed33c90c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / watermelon_music-0.2.0-py3-none-any.whl
| Download URL | watermelon_music-0.2.0-py3-none-any.whl |
|---|---|
| Size | 79.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
506d1174d1ab60726a020ce4d0f704db312cb5fc9bb7e2fa46874278a1d40707
|
|
BLAKE2b-256 checksum How to use checksums |
0e17537adab7159c3199eaa57794a6037a46b70044b6f3e1ed0626e697dd386a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for watermelon-music 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.