Documentation Β· v2.1

leon.music docs

Everything you need to run your own streaming service: installation, accounts, live radio and the admin panel.

Install

On Windows, download leon.music-setup.exe from the latest release and run it. No admin rights or Python needed: it installs for your user, adds a Start menu shortcut and can start with Windows. Run it again to update; uninstall from Windows' Installed apps.

From source (any system), leon.music is two files: leon_music.py (the server and tray app) and frontend.html (the player). You need Python 3.9 or newer.

git clone https://github.com/weareleon/leonmusic
cd leonmusic
pip install -r requirements.txt
python leon_music.py

A tray icon appears and your browser opens http://localhost:7733. To update later, run git pull and restart. Your library and settings carry over.

πŸ’‘Optional: ffmpeg. Live radio uses ffmpeg to broadcast every audio format. Without it, only MP3 files can go out on air. Put it on your PATH, or next to the app.
ℹ️On some Linux systems you need pip install -r requirements.txt --break-system-packages, and the tray icon needs an appindicator backend (for example sudo apt install gir1.2-appindicator3-0.1).

First run

The setup wizard, with red 3D ribbons swinging behind it

The welcome wizard asks for:

  1. Your music folder. It checks the folder as you type and tells you how many songs it found and which subfolders become playlists. leon.music only reads it and never changes your files.
  2. Your music videos folder (optional, you can skip it). See Music videos.
  3. A name for your library, shown in the app and on generated covers, with a preview.
  4. An admin password (8 or more characters). You need it for the admin panel and for logging in as admin.

Then leon.music scans your files. Rescans skip unchanged files, so they're quick. Rescan from the tray menu or from Settings.

Organising your library

Music/
β”œβ”€β”€ Late Night/        ← becomes the "Late Night" playlist
β”‚   β”œβ”€β”€ song1.mp3
β”‚   └── song2.flac
β”œβ”€β”€ Workout/           ← becomes the "Workout" playlist
└── loose-song.mp3     ← in the library, but in no playlist

Home & Made for You

Home page
Home for a signed-in user: Top Picks and Made for You.

When someone logs in with an account for the first time, they pick the genres they like and get a personal mix. Their home page then shows:

Generated covers show your cover logo (set in the admin panel), or your library name if no logo is set.

Search categories

Type in Search to find songs, artists and albums. With an empty search box you see Browse categories: Radio, Charts, New, Weekly Rewind, one tinted tile per genre, and a Decades row. Each genre and decade opens a page with feature cards, generated playlists (Hits, New in…, Essentials, Deep Cuts, Mix), top songs, albums and artists.

πŸ’‘Songs without a year don't appear under Decades. The Release years card in the admin panel can look missing years up on Deezer.

New & Charts

New page
Top 50 chart

New collects the newest songs, trending songs, new albums, new and updated playlists (anything added in the last 14 days), this year's releases and new artists. Albums, Artists and Songs are at the bottom of this page.

Charts count a play once someone has listened for about 30 seconds (or half of a short song). You get a Top 50, genre charts and artist charts for this week, this month and all time, with rank movement compared with the previous period.

Rewind

Weekly Rewind

Minutes assume a counted song was played in full, so totals are a close estimate.

Up Next & Autoplay

Up Next panel
Press ☰ in the player to see what's coming up.

Press ☰ at the right of the player (on a phone: Up Next on the Now Playing screen) to see the queue:

Christmas

Search has a πŸŽ„ Christmas tile (it moves to the front from 15 November to 6 January). It collects everything Christmas: songs whose genre, folder or album mentions Christmas, Xmas, holiday, jul or noΓ«l. The page has feature cards (your Holiday station when it's on air, Christmas folder playlists, the song of the season), special playlists (Christmas Classics, Cozy Christmas, Christmas Party, New Christmas Music), top songs, albums and artists.

Likes & your own playlists

A user playlist
Album page with explicit badges

Lyrics

Synced lyrics
Tap Ly in the player. Synced lyrics follow the song; tap a line to jump there.

leon.music looks for lyrics in this order, and saves what it finds:

  1. A .lrc file next to the song with the same name, for example Song.mp3 + Song.lrc. Timestamped lines like [01:23.45] give synced lyrics.
  2. Lyrics stored inside the file (ID3 USLT, Vorbis LYRICS, iTunes lyrics).
  3. LRCLIB, a free, open lyrics database, when online lookup is on. It receives the artist, title, album and length. Each song is looked up once; misses are retried after a week.

Turn online lookup off in the admin panel's Artists card ("Look up lyrics on LRCLIB").

Playlist covers

Click a playlist's cover (or πŸ–Ό Cover) to open the cover designer. Admins get the same designer for folder playlists via Design cover.

The preview updates as you change things. Remove goes back to the automatic cover.

Album pages

Under the track list, album pages show:

Artist pages

An artist page

Artist pages open with the artist's photo, blurred behind the page so every artist gets their own colours, and Play and Shuffle. Then:

Explicit songs

Songs tagged as explicit get a small E badge everywhere. leon.music reads:

Songs without any of these count as clean. Existing libraries are checked once in the background after updating; new files are checked when they're scanned. Live radio stations can skip explicit songs; see Program the schedule.

Accounts & logins

Settings: users
Settings β†’ Users (admin only).

Add accounts under Settings β†’ Users. As soon as the first account exists (or a library password is set), everyone has to log in on the same screen:

WhoUsernamePassword
A usertheir usernametheir password
The adminadminthe admin password
Anyone with the shared passwordleave blankthe library password

Passwords are 8 or more characters and stored as salted scrypt hashes. Logins last 30 days. After 5 wrong attempts, logins from that device pause for 5 minutes. Resetting a user's password signs them out everywhere.

Profiles & friends

A profile page
Friends page

Everyone with an account can set up a profile. A Set up your profile card appears on Home, and Edit profile on your profile page reopens the wizard:

  1. You: profile photo (cropped to a square automatically), display name, username and bio. Changing your username also changes what you log in with.
  2. Playlists: which of your playlists (and whether your Liked Songs) appear on your profile.
  3. Privacy: who can see your listening (everyone on this server, only my friends, or only me) and whether to show your top artists and songs.

Profile pages show the photo, name, bio and friends, a Listening now strip, top artists and songs this month, recently played, and public playlists, all following that person's privacy choices. Click your own name in the sidebar to see yours.

Friends (in the sidebar): search everyone on the server, send requests, accept or decline them, and see what your friends are playing right now. Both people have to agree; removing a friend removes it for both.

Friends Mix
The Friends Mix in Made for You: what your friends played in the last three weeks, with who played what.

New profiles share listening with friends only. Friends who choose only me are left out of your Friends Mix.

Jam: listen together

A Jam with three people
The Jam bar on a phone

A Jam lets friends listen together, each on their own device, wherever they are. Everyone hears the same song at the same moment and adds to one shared queue.

  1. Start a Jam from Up Next (☰ β†’ Start) or the Friends page. What you're playing, and your queue, become the Jam.
  2. Invite people: send the invite link or the 6-letter code. Friends also see your Jam on their Friends page with a Join button.
  3. Everyone can add songs with Β·Β·Β· β†’ Play next or Add to queue. Each song shows who added it.
  4. Pressing play on an album or playlist during a Jam plays it for everyone, replacing what's coming up.
πŸ’‘How it stays in sync: the server keeps the Jam's clock (which song, where, playing or paused) and pushes every change instantly. Each device streams the music itself and quietly corrects itself if it drifts more than about half a second.

On your phone

Library tab on a phone
Now Playing on a phone

On a phone, leon.music works like a music app:

Listening from anywhere

leon.music listens on 127.0.0.1:7733. To use it from your phone or away from home, put it behind a reverse proxy with HTTPS, such as Caddy, nginx, Tailscale Serve or Cloudflare Tunnel.

⚠️Before exposing it, set an admin password and either create accounts or set a library password. Until then, anyone who can reach the server can browse and stream.

Live radio: what it is

Live radio turns your library into real radio stations. Each station plays non-stop from the playlists you choose, follows a schedule, and is broadcast as a normal internet radio stream. Everyone who tunes in hears the same song at the same moment, just like FM radio. Listeners don't need an account, and they can use the leon.music Radio page, a phone app, VLC, a smart speaker or any player that can open a stream URL.

πŸ“»Live stations (this guide)
Made by you from your own music. leon.music sends them out through Icecast. Set up in Radio β†’ Set up live radio.
🌐Internet radio streams
Someone else's station (any Icecast or Shoutcast URL). leon.music only plays them. Added in the admin panel; see below.
Radio page with live stations
The Radio page: live stations under On Air Now, upcoming shows, and other streams.

What you get:

How it works

Songs flow from your library through leon.music and ffmpeg to Icecast, which streams to listeners Your library playlists & songs leon.music picks the next song from the schedule, ffmpeg converts to MP3 and paces it in real time Icecast one mount per station leon.music app VLC / phones Smart speakers source listeners
leon.music is the source; Icecast is the broadcast tower that hands the stream to every listener.

For each station, leon.music runs a small broadcaster in the background:

  1. It picks the next song. It checks the station's schedule for the current day and time. If a show is on, it plays from the show's playlists, and otherwise from the normal rotation. Songs are random, but it won't repeat any of the last ~50 songs (fewer for small playlists). If the scheduled playlists are empty, it falls back to your whole library so the station never goes silent.
  2. It converts the song. ffmpeg turns any format (FLAC, M4A, OGG…) into a constant-bitrate MP3 at the quality you chose. Without ffmpeg, only MP3 files are played.
  3. It sends the audio to Icecast at exactly real-time speed, keeping about 3 seconds ahead so playback stays smooth across song changes.
  4. It updates the song info ("Artist - Title") on Icecast and in leon.music at the start of every song.
  5. Icecast streams it to everyone listening on that station's mount, its address on the Icecast server (for example /hits).
ℹ️Why Icecast? leon.music doesn't stream radio to listeners directly. Icecast is free, battle-tested streaming software built for exactly this: it handles many listeners, buffering and the standard radio protocols that phones and speakers understand. leon.music feeds it; Icecast does the broadcasting.

Before you start: install Icecast

You need an Icecast server that leon.music can reach. The easiest setup is Icecast on the same computer as leon.music.

SystemHow to install
WindowsDownload the installer from icecast.org/download, install, then start Icecast from the Start menu (or run it as a service).
macOSbrew install icecast, then icecast -c /opt/homebrew/etc/icecast.xml (Intel Macs: /usr/local/etc/icecast.xml).
Debian / Ubuntusudo apt install icecast2. The installer asks for the passwords, then start it with sudo systemctl enable --now icecast2.
DockerAny maintained Icecast image works. Map port 8000 and set the source password through its environment variables.

Then open icecast.xml and check three things:

<authentication>
    <source-password>choose-a-strong-one</source-password>  ← leon.music
    <admin-user>admin</admin-user>
    <admin-password>something-else</admin-password>  ← Icecast's web page
</authentication>
<listen-socket>
    <port>8000</port>  ← port for the wizard
</listen-socket>
<limits>
    <sources>12</sources>  ← β‰₯ your stations
</limits>
⚠️Change the default hackme passwords. Anyone who knows the source password can broadcast on your server.

Restart Icecast after editing, then open http://localhost:8000. If you see the Icecast status page, it's running.

πŸ’‘Install ffmpeg too (ffmpeg.org, brew install ffmpeg or sudo apt install ffmpeg) and restart leon.music. The wizard tells you whether it was found.

Setting up your stations

Log in as admin, open Radio and click Set up live radio. The wizard has four steps.

1. Pick your stations

Wizard step 1: pick stations

Click the ready-made stations you want: 1 (everything), Hits, Club, Chill, Country, Hip-Hop, Throwback, Latino, Focus, Party and Holiday. Each comes with an original logo carrying your library's name. Or click Custom station to make your own: name, tagline, two colours and a logo style, with a live preview. Station names must be unique.

2. Program the schedule

Wizard step 2: schedule
πŸ•’Times use the clock of the computer running leon.music, not each listener's time zone.

3. Connect your Icecast server

Wizard step 3: Icecast
FieldWhat to enter
Server addresslocalhost if Icecast runs on the same computer; otherwise its IP or host name. Don't include http://.
PortThe <port> from icecast.xml, usually 8000
Source usernamesource, unless your Icecast gives mounts their own login
Source passwordThe <source-password>, not the admin password. Stored only on your server and never shown again (leave it blank later to keep it).
Stream quality128, 192 (recommended), 256 or 320 kbps MP3
Use HTTPS/TLSOnly if your Icecast itself serves HTTPS
Advanced: Public listen URLThe address listeners should use if it differs from the server address, for example https://radio.example.com behind a reverse proxy
Advanced: Mount prefixPrefixes every mount, for example leon gives /leon-hits. Useful when sharing an Icecast server.
Advanced: Public directoryLists your stations in Icecast's public directory. Leave it off for private stations.

Click Test connection. A green "Connected" means Icecast accepted the source password. Otherwise the message tells you what's wrong (unreachable, wrong password, and so on).

4. Go live

Click Go live. You'll see a progress bar and a row per station moving from Saved to Connecting to Encoding the first song to LIVE, with the first song shown. That's it: the stations keep running in the background and restart by themselves whenever leon.music starts.

Listening

Station schedule
A station's schedule page. Shows use their own covers; normal rotation is listed in 2-hour blocks.

How much bandwidth?

Icecast sends one copy of the stream per listener. Upload needed β‰ˆ listeners Γ— quality: 10 people on a 192 kbps station use about 1.9 Mbit/s. One listener uses roughly 86 MB per hour at 192 kbps (58 MB at 128 kbps). leon.music itself only uploads one stream per station to Icecast.

Managing your stations

When something goes wrong

Stations fix most problems themselves. If Icecast stops or the network drops, a station goes OFFLINE and retries after 3 seconds, then 6, 12 and so on up to once a minute, and goes back on air as soon as Icecast returns. Problems that a quick retry can't fix (a wrong password, a mount already in use, a station with no playable songs) are retried every 30 seconds until you fix the setting.

MessageFix
Can't reach Icecast at …Icecast isn't running, or the address or port is wrong, or a firewall blocks it.
Icecast rejected the source username or passwordUse the <source-password> from icecast.xml, not the admin password.
Mount … is already in useAnother program (or a second copy of leon.music) is broadcasting on that mount. Stop it, or set a mount prefix.
No playable songs in this station's playlistsThe playlists are empty, or they only contain non-MP3 files and ffmpeg isn't installed.
Couldn't encode any songsffmpeg failed on several files in a row. Check that the files play normally and that ffmpeg works (ffmpeg -version).
Only some songs playffmpeg wasn't found, so only MP3s are broadcast. Install ffmpeg and restart.

Station Lists

The Hits List

Every live station gets a weekly playlist of what it's been playing: The 1 List, The Hits List and so on. Each List has the 50 songs the station played most last week, updated every Tuesday. Songs that are new to the List get a NEW tag.

Internet radio streams

You can also add any Icecast or Shoutcast stream URL in the admin panel's Radio stations card. These appear under More Stations, with now-playing info read from the stream.

Music videos

The Music Videos page

Music videos live in their own folder, separate from your music, with a folder for each artist:

music videos/
β”œβ”€ Ed Sheeran/
β”‚  └─ Ed Sheeran - Shape of You.mp4
└─ Nathan Dawe/
   └─ Nathan Dawe X Abi Flynn - Here In Your Arms.mp4

Watching

The full-screen video player

Open Search β†’ Music Videos for the newest video, Recently added, Most watched and a row for each artist. Videos also show up in search results and on artist pages, and each artist with videos has a Video Essentials playlist.

Videos open in a full-screen player. Your music pauses while it plays, and the next video starts on its own. The controls fade while you watch:

KeyDoes
Space / KPlay or pause
← β†’Back or forward 5 seconds
↑ ↓Volume
F / MFull screen / mute
N / PNext or previous video
Esc or BackClose the player

Music TV

Music TV live at the top of the Music Videos page

Music TV turns your music videos into a live channel that plays around the clock. While it's live, it's at the top of the Music Videos page for everyone on your server. The channel name is in the top right and the song in the bottom left, drawn into the video itself.

  1. Admins: open Search β†’ Music Videos and press Set up Music TV.
  2. Channel: name it and choose what plays: all your videos shuffled, or only the artists you pick.
  3. On screen: turn the channel name and the song text on or off, and pick 720p (3 Mbps) or 1080p (5 Mbps).
  4. Rebroadcast (optional), then Go live.
βš™οΈNeeds ffmpeg. Every video is re-encoded to one continuous MPEG-TS stream, which keeps about one CPU core busy while the channel is live. The browser player (mpegts.js) loads from the jsDelivr CDN, so viewers need internet access, and iPhones need iOS 17.1 or newer.

Rebroadcasting

Adding rebroadcast destinations

Music TV can send the channel to YouTube Live, Twitch, Kick or any RTMP server at the same time. The server address is filled in for the big platforms; paste the stream key from the platform's live dashboard. The stream is copied, not encoded again, so each destination costs almost no CPU, only upload bandwidth.

DJ mixes: what they are

A DJ mix page
A DJ mix: one continuous set, split into its songs.

A DJ mix is a whole set, like a festival performance, a radio show or a mixtape, recorded as one long audio file. leon.music splits it into the songs that were played, using the mix's CUE sheet, so you can see every song, skip between them, like them and add them to playlists. It still plays as one seamless mix, with no gaps between the songs.

Mixes come from mix hubs: small websites that share mixes with leon.music servers. Anyone can run a hub (it's open source), and every server can add as many hubs as it likes. The official one is leon.music Mixes.

Listening to mixes

DJ Mixes page
A curator page
  1. Open Search and tap the DJ Mixes tile. It appears once your server has at least one mix.
  2. Browse Latest Mixes and Curators, or a row per curator. Tap a curator to see their page and collections.
  3. On a mix, press β–Ά Play to hear it from the start, or tap any song to start there. The mix plays straight through: song changes happen at exactly the right moment, with nothing reloading.
  4. Shuffle plays the songs in a random order, and + saves the whole mix as one of your playlists.

In Subsonic apps, each mix shows up as an album by the DJ, with every song as its own track.

Adding mixes to your server

DJ Mixes card in the admin panel
Admin panel β†’ DJ Mixes: add a hub, then press Add on the mixes you want.
  1. Open the admin panel and find the DJ Mixes card.
  2. Press + Add the official leon.music hub, or paste another hub's address (e.g. https://someone.github.io/their-mixes/) and press Add hub.
  3. Press Browse next to the hub to list its mixes, with the DJ, curator, number of songs and size.
  4. Press Add on a mix. A progress bar shows the download. leon.music then checks the file, cuts it into songs and creates the curator's page. A 1-hour mix takes about a minute on a normal connection.
πŸ”’Only admins can add hubs and mixes. Each download is checked against the checksum in the hub, so a damaged download is refused instead of half-imported. A hub is trusted as a whole, so only add hubs you trust.

Publishing your own mixes

You need a hub you can push to: either your own (see the next section) or a hub whose owner made you a collaborator. Anyone else can send a mix through a hub's Submit your mix form, and the owner reviews it by hand.

What you need: the mix as one audio file (320 kbps MP3 is ideal, max 2 GB), a CUE sheet listing each song's start time, and optionally a square cover. Most DJ software, including rekordbox, Serato, Traktor and Mixxx, can export a CUE sheet with a recording. A CUE sheet looks like this:

PERFORMER "Leon"
TITLE "Leon's Mini-Mix Vol. 1"
FILE "mix.mp3" MP3
  TRACK 01 AUDIO
    TITLE "WannaCry (Extended Mix)"
    PERFORMER "Ninajirachi, Porter Robinson"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "More! More! More! (Extended Mix)"
    PERFORMER "Becky Hill"
    INDEX 01 04:22:30        ← minutes:seconds:frames (75 frames per second)
  1. One-time setup: install GitHub CLI, run gh auth login and sign in with an account that can push to the hub. Download the hub's files (Code β†’ Download ZIP on its GitHub page).
  2. Double-click Publish a mix.cmd.
  3. Pick the mix audio and the CUE sheet. The title and DJ are filled in from the CUE sheet.
  4. Pick the curator, or choose + New curator… and give them a name. A logo (400 Γ— 400 px), a banner (2400 Γ— 600 px, with important parts in the middle), a bio and a website are optional.
  5. Fill in the collection (use the exact same name for mixes that belong together, e.g. "Mini-Mixes"), genre and year, and tick explicit if needed. No cover? One is made with the DJ's name.
  6. Press Publish. The publisher uploads the audio to the hub's GitHub release, updates hub.json and pushes. The mix is on the hub a minute or two later. Servers then see it under Browse.

Your GitHub sign-in decides where you can publish. The publisher never stores a password. If you don't have push access, GitHub refuses and nothing half-finished is published.

Running your own hub

The hub format and tools are open source (MIT). Festivals, radio shows, labels or DJs can run their own hub and every leon.music server can add it.

  1. Open weareleon/leonmusic-mixes and press Use this template.
  2. In your copy, edit hub.config.json (name, description and your own submission link) and turn on GitHub Pages (Settings β†’ Pages β†’ Deploy from branch β†’ main).
  3. Publish mixes with Publish a mix.cmd, typing your repo in the Hub repo box.
  4. Share your hub's address, e.g. https://you.github.io/your-hub/. Its page shows your mixes and a button to copy the address.

Prefer to host it yourself? Any web server works, for example behind a Cloudflare Tunnel. Run build_hub.py without --audio-base and keep the audio next to hub.json. The format is documented in SPEC.md.

βš–οΈThe licence covers the code and the format, not the music. Only publish mixes you made or have permission to share.

Themes

Appearance settings with themes and custom CSS

Open Settings β†’ Appearance and pick a theme. It's saved to your account, so it follows you to every device.

Midnight theme
Paper theme

Custom CSS

Custom CSS lets you change anything about how leon.music looks: colours, fonts, sizes, spacing, or hiding things you don't use. It's plain CSS, applied on top of everything else.

The order is: theme β†’ the server's CSS β†’ your CSS, so yours always wins.

Colours and sizes (CSS variables)

The easiest way to restyle leon.music is to change these variables on :root. Everything uses them.

VariableWhat it colours
--bgThe page background and sidebar
--bg2The main area and cards
--bg3, --bg4Buttons, inputs, hover and pressed states
--fg, --fg2, --fg3Text: main, secondary, faint
--borderLines and outlines
--accent, --accent2The highlight colour (play buttons, links, active items) and its lighter version
--sidebar-w, --player-hSidebar width and player height (desktop)

Targeting parts of the app

SelectorPart
.sidebar, .topbar, .main, .contentSidebar, top bar, the scrolling page and its padding
.player, .p-title, .p-playThe player bar, its song title and play button
.track-row, .track-title, .track-thumbSong rows in lists
.album-card, .album-art, .detail-artAlbum cards, their covers, and the big cover on detail pages
.featuredThe banner at the top of Home
.tabbar, .npPhone tab bar and the Now Playing screen
body[data-view="home"]Only on one page. Views include home, search, new, radio, charts, library, settings, friends, mixes
:root[data-lm-theme="paper"], :root[data-theme="light"]Only with one theme, or only in light mode

To find any other class, right-click something in your browser and choose Inspect.

Examples

/* Your own accent colour (overrides the theme's) */
:root { --accent: #00b894; --accent2: #55d6b8; }

/* A different font (any Google Font works) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');
body, button, input { font-family: 'Inter', sans-serif !important; }

/* Round covers everywhere */
.album-art, .track-thumb, .detail-art { border-radius: 50% !important; }

/* Compact song lists */
.track-row { padding: 4px 10px; min-height: 0; }

/* A background image behind everything */
.main { background: linear-gradient(rgba(0,0,0,.75), rgba(0,0,0,.9)), url('https://example.com/bg.jpg') center/cover fixed; }

/* Hide the Home banner */
body[data-view="home"] .featured { display: none; }

/* Only tweak the Paper theme */
:root[data-lm-theme="paper"] { --bg2: #fffdf7; }
πŸ›ŸBroke something? Open your server's address with /?nocss at the end (e.g. https://music.example.com/?nocss). Custom CSS is skipped for that visit, so you can go to Settings and fix or remove it.

Custom CSS can only change how things look; it can't run code. Server CSS applies to everyone, so admins should test it with Preview in their own Settings first. Each one can be up to 50,000 characters.

Admin panel

Open /admin (for example http://localhost:7733/admin) and sign in with the admin password.

Admin accounts

Besides the built-in admin login, any user account can be an admin. It keeps its own profile, likes and playlists and also gets the admin controls (including /admin) just by logging in. Use Make admin in Settings β†’ Users, or the command line from the folder with leon_music.py:

cd path\to\leonmusic
python leon_music.py admin list              # accounts, β˜… = admin
python leon_music.py admin add alex          # make an account an admin
python leon_music.py admin remove alex       # take it away again
python leon_music.py admin create someone    # new admin account, asks for a password

The commands work while leon.music is running. They need the Python version; with the packaged app, use Make admin in Settings instead.

Configuration & data

Everything lives in ~/.leon-music/. Your music files are only read, never modified.

PathContents
config.jsonLibrary path and name, theme, password hashes, radio and live-radio setup (including the Icecast source password)
library.dbTrack index, embedded covers, plays, accounts, sessions, mixes, likes, playlists, profiles, friends and saved lyrics
playlist-covers/Generated playlist covers
artist-pics/Cached or custom artist photos

To start over, delete the folder. To use a different port, change PORT near the top of leon_music.py.

Building an app

pip install pyinstaller
pyinstaller --onefile --windowed --name "leon.music" leon_music.py

Put frontend.html next to the built app; it's loaded from disk at runtime. This works on Windows (.exe) and macOS (.app). For live radio, put ffmpeg next to the app too.

API

Everything is under /api. Once logins are on, requests need a session cookie (from POST /api/auth/login) or an X-Admin-Token header.

EndpointDescription
GET /api/statusLibrary name, counts, scan progress, theme
GET /api/tracks, /albums, /artists, /playlistsBrowse the library
GET /api/stream/{id}Audio with range support
GET /api/search?q=Songs, artists and albums
GET /api/genres, /genres/{key}, /decadesCategories and their pages
GET /api/new, /charts?period=week|month|allNew page and charts
POST /api/plays/{id}Count a play
POST /api/auth/login, /auth/logout, GET /api/auth/meLogins
GET /api/me/home, /me/rewind, /me/rewind/weekPersonal mixes and Rewind
GET /api/radio/stations, /radio/{id}/nowRadio stations and now playing
GET|POST|DELETE /api/me/likesLiked Songs
/api/me/playlists, /api/me/playlists/{id}Your playlists (create, edit, reorder, share)
GET /api/lyrics/{id}Lyrics (synced or plain)
GET /api/albums/related?album=Featured On, More from, You May Also Like
GET|PATCH /api/me/profile, GET /api/users/{name}Profiles
/api/me/friends, /api/me/friends/{name}Friends and requests
GET /api/christmasThe Christmas category page
POST /api/covers/preview, GET /api/covers/fonts, /api/me/playlists/{id}/coverCover designer
/api/me/email, POST /api/auth/forgot, /api/auth/resetEmail address, preferences and password reset
/rest/*Subsonic API (1.16.1, OpenSubsonic) for apps
GET /api/radio/lists, /radio/lists/{id}Station Lists
GET /api/mixes, /mixes/{id}, /mixes/curators/{id}DJ mixes and curators
GET /api/autoplay?ids=Similar songs for when a queue ends
POST /api/jam, /jam/{code}/join, /control, /queue, GET /jam/{code}/eventsJams (the events stream is server-sent events)
GET /api/appearance, GET|PATCH /api/me/appearanceServer and personal theme and custom CSS
GET /api/explicitIDs of explicit songs
GET /status, /api/server-statusServer status page: health, CPU, memory, storage, library and services
GET /api/artist/page?name=Latest release, top songs, albums and singles for an artist page
GET /api/videos, ?artist=, ?q=, /videos/{id}/stream, /videos/{id}/thumbMusic videos
GET /api/tv, /api/tv/stream.tsMusic TV status and the live MPEG-TS stream
GET|POST /api/admin/videos, /api/admin/tvVideo folder and Music TV setup (admin)
GET|POST /api/broadcastLive radio setup (admin)
/api/admin/*Admin actions (users, settings, stations)

Email

leon.music can send emails through your own mail provider: password resets, digests, friend notifications and server alerts.

  1. Open the admin panel's Email card and fill in your provider's SMTP details. Gmail and Outlook need an app password; services like Brevo or Resend give you SMTP details too.
  2. Set the public address of your server, so links in emails point to the right place.
  3. Press Send test email.

Each person adds their address in Settings β†’ Email (confirming with their password) and clicks the link they're sent. Then they pick which emails they want; everything starts off:

Forgot password? on the login screen emails a reset link (one hour, single use) to a confirmed address. Adding an account with an email sends a welcome. Every optional email has an unsubscribe link.

πŸ’‘The SMTP password is saved in config.json on the server and never shown again in the admin panel.

Subsonic apps

leon.music speaks the Subsonic API, so you can use apps like Symfonium, Tempo or DSub (Android), Substreamer or play:Sub (iPhone) and Feishin (desktop). They add offline downloads, CarPlay and Android Auto.

  1. In leon.music, open Settings β†’ Apps & scrobbling and press Create app password.
  2. In the app, add a server with the address, username and app password shown there.

Last.fm & ListenBrainz

Each person can send what they play to Last.fm and ListenBrainz from Settings β†’ Apps & scrobbling. A song counts once half of it (or 4 minutes) has played, from the web player or a Subsonic app. Only the song, artist, album, length and time are sent. If the internet is down, scrobbles are kept and sent later.

Security

Found a vulnerability? Please open a private security advisory instead of a public issue.

Troubleshooting

"Too many attempts" when logging in

That's the lockout after 5 wrong passwords. Wait 5 minutes, or restart leon.music.

A station says "Temporarily off air"

Open Manage live radio β†’ Icecast and press Test connection. The error messages and their fixes are listed in When something goes wrong.

Only some songs play on my station

ffmpeg wasn't found, so only MP3 files can be broadcast. Install ffmpeg and restart leon.music.

Decades or genres are missing

They come from file tags. Add genre and year tags, or run the Release years scan in the admin panel, then rescan.

Charts and Rewind are empty

Both need listening history. A play counts after about 30 seconds, and Rewind only counts plays made while logged in with an account.