Module: Rocksky::Playlist

Defined in:
lib/rocksky/playlist.rb

Overview

app.rocksky.playlist.* — the global, AT-Proto-backed playlists.

Distinct from Rocksky::Library's playlist methods, which drive the Subsonic/Navidrome library (app.rocksky.library.*).

Writes publish records to the caller's repo, so they need a token and only show up in reads once the AppView has ingested the commit.

Class Method Summary collapse

Class Method Details

.add_songs(uri, songs, token:, base: nil) ⇒ Object

Add songs by their app.rocksky.song AT-URIs. Owner only. Returns { "uris" => [...] } — the created entry records.



48
49
50
51
# File 'lib/rocksky/playlist.rb', line 48

def add_songs(uri, songs, token:, base: nil)
  Rocksky.post("app.rocksky.playlist.addSongs", { uri: uri, songs: songs },
               base: base, token: token)
end

.create(name, token:, description: nil, picture_url: nil, base: nil) ⇒ Object

Create a playlist. Returns { "uri" => ..., "cid" => ... }.



30
31
32
33
34
35
# File 'lib/rocksky/playlist.rb', line 30

def create(name, token:, description: nil, picture_url: nil, base: nil)
  params = { name: name }
  params[:description] = description if description
  params[:pictureUrl] = picture_url if picture_url
  Rocksky.post("app.rocksky.playlist.createPlaylist", params, base: base, token: token)
end

.get(uri, filter: nil, base: nil) ⇒ Object

A single playlist with its tracks. filter is an RSQL expression over the tracks (e.g. 'artist=="Daft Punk"').



23
24
25
26
27
# File 'lib/rocksky/playlist.rb', line 23

def get(uri, filter: nil, base: nil)
  params = { uri: uri }
  params[:filter] = filter if filter
  Rocksky.get("app.rocksky.playlist.getPlaylist", params, base: base)
end

.list(limit: 50, offset: 0, filter: nil, base: nil) ⇒ Object

The playlist catalog.



15
16
17
18
19
# File 'lib/rocksky/playlist.rb', line 15

def list(limit: 50, offset: 0, filter: nil, base: nil)
  params = { limit: limit, offset: offset }
  params[:filter] = filter if filter
  Rocksky.get("app.rocksky.playlist.getPlaylists", params, base: base)
end

.remove(uri, token:, base: nil) ⇒ Object

Delete a playlist and the caller's own entries. Owner only.



61
62
63
# File 'lib/rocksky/playlist.rb', line 61

def remove(uri, token:, base: nil)
  Rocksky.post("app.rocksky.playlist.removePlaylist", { uri: uri }, base: base, token: token)
end

.remove_track(uri, song_uri, token:, base: nil) ⇒ Object

Remove a song. An entry lives in the repo that added it, so only that repo can retract it.



55
56
57
58
# File 'lib/rocksky/playlist.rb', line 55

def remove_track(uri, song_uri, token:, base: nil)
  Rocksky.post("app.rocksky.playlist.removeTrack", { uri: uri, songUri: song_uri },
               base: base, token: token)
end

.update(uri, token:, name: nil, description: nil, picture_url: nil, base: nil) ⇒ Object

Rename or re-describe a playlist. Owner only.



38
39
40
41
42
43
44
# File 'lib/rocksky/playlist.rb', line 38

def update(uri, token:, name: nil, description: nil, picture_url: nil, base: nil)
  params = { uri: uri }
  params[:name] = name if name
  params[:description] = description if description
  params[:pictureUrl] = picture_url if picture_url
  Rocksky.post("app.rocksky.playlist.updatePlaylist", params, base: base, token: token)
end