A smart playlist is a set of rules, an order and a limit, kept under a name and worked out again every time it is opened.
- Rules (all that are set must hold): genres, artists and albums (is, or is not), file formats and a minimum bitrate of the same file, added in the last N days, never played, played or not played in the last N days, played at least N times, skipped or not skipped lately, only liked artists or without the avoided ones, and the length of the song.
- Orders: random (the same all day, a variant gives another), most played, least played, recently added, by title. A limit of 50 by default, 500 at most.
- GET/POST /smart-playlists, GET/PATCH/DELETE /smart-playlists/{id}, GET /smart-playlists/{id}/tracks, POST /smart-playlists/preview to try rules without keeping them, and POST /smart-playlists/{id}/playlist to keep what is shown as a normal playlist.
- Only the rules are stored (migration 0020); the songs come from the files and from the owner's own history and taste. Nothing is sent to a provider, and a smart playlist is its owner's alone. A user can have 200.
- Mixes and smart playlists share the way a list of songs becomes a playlist.
16 lines
681 B
SQL
16 lines
681 B
SQL
-- Smart playlists: playlists that are a set of rules, worked out again every time they are opened.
|
|
-- PostgreSQL flavour of sqlite/0020_smart_playlists.sql.
|
|
|
|
CREATE TABLE smart_playlists (
|
|
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
name TEXT NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
rules TEXT NOT NULL,
|
|
sort TEXT NOT NULL,
|
|
max_tracks INTEGER NOT NULL,
|
|
created_at BIGINT NOT NULL, -- unix seconds
|
|
updated_at BIGINT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX idx_smart_playlists_user ON smart_playlists(user_id, updated_at);
|