Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,75 @@ paths:
default:
$ref: "#/components/responses/Error"

/me/saved-artists:
get:
operationId: listSavedArtists
summary: Artists you saved
description: |
Artists you saved to remember, most recently saved first. They
belong to no service: one is known by its name, and `refs` are the
links it was seen on, as hints for opening its page.
tags: [library]
responses:
"200":
description: Your saved artists
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/SavedArtist"
default:
$ref: "#/components/responses/Error"
post:
operationId: saveArtist
summary: Save an artist
description: |
Saves an artist by `name` (with `linkId` and `artistId` if you know
where it's from), or as the `artistIndex`-th artist of a room's song
(`itemId`), which also remembers the room and who queued it.
Saving one you already saved, from anywhere, returns it (200) and
remembers this link too.
tags: [library]
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SaveArtistRequest"
responses:
"200":
description: Already saved
content:
application/json:
schema:
$ref: "#/components/schemas/SavedArtist"
"201":
description: Saved
content:
application/json:
schema:
$ref: "#/components/schemas/SavedArtist"
default:
$ref: "#/components/responses/Error"

/me/saved-artists/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
delete:
operationId: unsaveArtist
summary: Unsave an artist
tags: [library]
responses:
"204":
description: Unsaved
default:
$ref: "#/components/responses/Error"

/playlists:
get:
operationId: listSavedPlaylists
Expand Down Expand Up @@ -7174,6 +7243,55 @@ components:
artist:
$ref: "#/components/schemas/ArtistResult"

SavedArtist:
type: object
required: [id, name, key, refs, savedAt]
properties:
id:
type: string
name:
type: string
key:
type: string
description: |
The simplified name it's known by: another name with the same
key is the same artist.
refs:
type: array
description: Links it was seen on, newest first. A link may since be gone or not yours to use.
items:
$ref: "#/components/schemas/ResolvedRef"
picture:
type: string
description: A Deezer picture, through `/me/discover/images/artist/{picture}`.
roomId:
type: string
description: The room it was heard in, when saved from a room's song.
queuedBy:
type: string
description: Who queued the song it was saved from (user ID).
savedAt:
type: string
format: date-time

SaveArtistRequest:
type: object
properties:
name:
type: string
maxLength: 200
linkId:
type: string
artistId:
type: string
itemId:
type: string
description: A room's song; saves its `artistIndex`-th artist instead of `name`.
artistIndex:
type: integer
minimum: 0
default: 0

ResolvedRef:
type: object
description: An artist or album to open with `linkId` and `id`.
Expand Down
4 changes: 4 additions & 0 deletions server/cmd/syncphony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"github.com/madeofpendletonwool/syncphony/server/internal/realtime"
"github.com/madeofpendletonwool/syncphony/server/internal/releases"
"github.com/madeofpendletonwool/syncphony/server/internal/rooms"
"github.com/madeofpendletonwool/syncphony/server/internal/savedartists"
"github.com/madeofpendletonwool/syncphony/server/internal/store"
"github.com/madeofpendletonwool/syncphony/server/internal/suggest"
"github.com/madeofpendletonwool/syncphony/server/internal/transcode"
Expand Down Expand Up @@ -373,8 +374,11 @@ func run() error {
Bus: a.bus, Presence: presence,
BaseURL: cfg.BaseURL, TrustedProxies: cfg.TrustedProxies,
}
api.SavedArtists = savedartists.New(db, roomSvc, nil)
if len(graph.Sources()) > 0 {
api.Graph = graph
// Saved artists' pictures come from the graph's Deezer answers.
api.SavedArtists = savedartists.New(db, roomSvc, graph)
}
// Personal discovery (ADR 0017): seed sets, minus what's in your library.
lib := library.New(db, a.links)
Expand Down
3 changes: 2 additions & 1 deletion server/internal/httpapi/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/madeofpendletonwool/syncphony/server/internal/queue"
"github.com/madeofpendletonwool/syncphony/server/internal/realtime"
"github.com/madeofpendletonwool/syncphony/server/internal/rooms"
"github.com/madeofpendletonwool/syncphony/server/internal/savedartists"
"github.com/madeofpendletonwool/syncphony/server/internal/store"
"github.com/madeofpendletonwool/syncphony/server/internal/suggest"
"github.com/madeofpendletonwool/syncphony/server/internal/transcode"
Expand Down Expand Up @@ -147,7 +148,7 @@ func newEnv(t *testing.T) *env {
pilot.Now, pilot.Memory = e.clock, &dj.Memory{DB: db, Now: e.clock}
t.Cleanup(pilot.Close)
api := &httpapi.Server{
Version: "test", StartedAt: e.clock(), Admin: e.server, Backups: e.backups, Auth: e.svc, Links: e.links, Lyrics: ly, LinerNotes: notes, Artwork: art, Palettes: e.palettes, BeatMaps: beatMaps, Rooms: e.rooms, Queue: qs, Playback: e.playback, Nights: e.nights, Playlists: playlists.New(db, e.rooms, e.links), Games: e.games, Bus: e.bus, Presence: presence,
Version: "test", StartedAt: e.clock(), Admin: e.server, Backups: e.backups, Auth: e.svc, Links: e.links, Lyrics: ly, LinerNotes: notes, Artwork: art, Palettes: e.palettes, BeatMaps: beatMaps, Rooms: e.rooms, Queue: qs, Playback: e.playback, Nights: e.nights, Playlists: playlists.New(db, e.rooms, e.links), SavedArtists: savedartists.New(db, e.rooms, nil), Games: e.games, Bus: e.bus, Presence: presence,
Suggest: suggest.New(db, e.rooms, e.links), Autopilot: pilot, Discover: discover.New(db),
BaseURL: e.base, PingEvery: 50 * time.Millisecond,
}
Expand Down
Loading
Loading