mirror of
https://github.com/navidrome/navidrome.git
synced 2025-08-10 00:52:20 +00:00
Make all Subsonic helper functions private
This commit is contained in:
@@ -22,7 +22,7 @@ func NewAlbumListController(listGen engine.ListGenerator) *AlbumListController {
|
||||
}
|
||||
|
||||
func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries, error) {
|
||||
typ, err := RequiredParamString(r, "type", "Required string parameter 'type' is not present")
|
||||
typ, err := requiredParamString(r, "type", "Required string parameter 'type' is not present")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -69,22 +69,22 @@ func (c *AlbumListController) getNewAlbumList(r *http.Request) (engine.Entries,
|
||||
func (c *AlbumListController) GetAlbumList(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
albums, err := c.getNewAlbumList(r)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, err.Error())
|
||||
return nil, newError(responses.ErrorGeneric, err.Error())
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response.AlbumList = &responses.AlbumList{Album: ToChildren(r.Context(), albums)}
|
||||
response := newResponse()
|
||||
response.AlbumList = &responses.AlbumList{Album: toChildren(r.Context(), albums)}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *AlbumListController) GetAlbumList2(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
albums, err := c.getNewAlbumList(r)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, err.Error())
|
||||
return nil, newError(responses.ErrorGeneric, err.Error())
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response.AlbumList2 = &responses.AlbumList{Album: ToAlbums(r.Context(), albums)}
|
||||
response := newResponse()
|
||||
response.AlbumList2 = &responses.AlbumList{Album: toAlbums(r.Context(), albums)}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -92,14 +92,14 @@ func (c *AlbumListController) GetStarred(w http.ResponseWriter, r *http.Request)
|
||||
artists, albums, mediaFiles, err := c.listGen.GetAllStarred(r.Context())
|
||||
if err != nil {
|
||||
log.Error(r, "Error retrieving starred media", "error", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Starred = &responses.Starred{}
|
||||
response.Starred.Artist = ToArtists(artists)
|
||||
response.Starred.Album = ToChildren(r.Context(), albums)
|
||||
response.Starred.Song = ToChildren(r.Context(), mediaFiles)
|
||||
response.Starred.Artist = toArtists(artists)
|
||||
response.Starred.Album = toChildren(r.Context(), albums)
|
||||
response.Starred.Song = toChildren(r.Context(), mediaFiles)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -107,14 +107,14 @@ func (c *AlbumListController) GetStarred2(w http.ResponseWriter, r *http.Request
|
||||
artists, albums, mediaFiles, err := c.listGen.GetAllStarred(r.Context())
|
||||
if err != nil {
|
||||
log.Error(r, "Error retrieving starred media", "error", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Starred2 = &responses.Starred{}
|
||||
response.Starred2.Artist = ToArtists(artists)
|
||||
response.Starred2.Album = ToAlbums(r.Context(), albums)
|
||||
response.Starred2.Song = ToChildren(r.Context(), mediaFiles)
|
||||
response.Starred2.Artist = toArtists(artists)
|
||||
response.Starred2.Album = toAlbums(r.Context(), albums)
|
||||
response.Starred2.Song = toChildren(r.Context(), mediaFiles)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -122,14 +122,14 @@ func (c *AlbumListController) GetNowPlaying(w http.ResponseWriter, r *http.Reque
|
||||
npInfos, err := c.listGen.GetNowPlaying(r.Context())
|
||||
if err != nil {
|
||||
log.Error(r, "Error retrieving now playing list", "error", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.NowPlaying = &responses.NowPlaying{}
|
||||
response.NowPlaying.Entry = make([]responses.NowPlayingEntry, len(npInfos))
|
||||
for i, entry := range npInfos {
|
||||
response.NowPlaying.Entry[i].Child = ToChild(r.Context(), entry)
|
||||
response.NowPlaying.Entry[i].Child = toChild(r.Context(), entry)
|
||||
response.NowPlaying.Entry[i].UserName = entry.UserName
|
||||
response.NowPlaying.Entry[i].MinutesAgo = entry.MinutesAgo
|
||||
response.NowPlaying.Entry[i].PlayerId = entry.PlayerId
|
||||
@@ -147,12 +147,12 @@ func (c *AlbumListController) GetRandomSongs(w http.ResponseWriter, r *http.Requ
|
||||
songs, err := c.listGen.GetSongs(r.Context(), 0, size, engine.SongsByRandom(genre, fromYear, toYear))
|
||||
if err != nil {
|
||||
log.Error(r, "Error retrieving random songs", "error", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.RandomSongs = &responses.Songs{}
|
||||
response.RandomSongs.Songs = ToChildren(r.Context(), songs)
|
||||
response.RandomSongs.Songs = toChildren(r.Context(), songs)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -164,11 +164,11 @@ func (c *AlbumListController) GetSongsByGenre(w http.ResponseWriter, r *http.Req
|
||||
songs, err := c.listGen.GetSongs(r.Context(), offset, count, engine.SongsByGenre(genre))
|
||||
if err != nil {
|
||||
log.Error(r, "Error retrieving random songs", "error", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.SongsByGenre = &responses.Songs{}
|
||||
response.SongsByGenre.Songs = ToChildren(r.Context(), songs)
|
||||
response.SongsByGenre.Songs = toChildren(r.Context(), songs)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func HGone(r chi.Router, path string) {
|
||||
}
|
||||
|
||||
func SendError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
code := responses.ErrorGeneric
|
||||
if e, ok := err.(SubsonicError); ok {
|
||||
code = e.code
|
||||
|
||||
@@ -24,14 +24,14 @@ func (c *BookmarksController) GetBookmarks(w http.ResponseWriter, r *http.Reques
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
bmks, err := repo.GetBookmarks()
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Bookmarks = &responses.Bookmarks{}
|
||||
for _, bmk := range bmks {
|
||||
b := responses.Bookmark{
|
||||
Entry: []responses.Child{ChildFromMediaFile(r.Context(), bmk.Item)},
|
||||
Entry: []responses.Child{childFromMediaFile(r.Context(), bmk.Item)},
|
||||
Position: bmk.Position,
|
||||
Username: user.UserName,
|
||||
Comment: bmk.Comment,
|
||||
@@ -44,7 +44,7 @@ func (c *BookmarksController) GetBookmarks(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
func (c *BookmarksController) CreateBookmark(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -55,13 +55,13 @@ func (c *BookmarksController) CreateBookmark(w http.ResponseWriter, r *http.Requ
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
err = repo.AddBookmark(id, comment, position)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *BookmarksController) DeleteBookmark(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -69,9 +69,9 @@ func (c *BookmarksController) DeleteBookmark(w http.ResponseWriter, r *http.Requ
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
err = repo.DeleteBookmark(id)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *BookmarksController) GetPlayQueue(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
@@ -80,12 +80,12 @@ func (c *BookmarksController) GetPlayQueue(w http.ResponseWriter, r *http.Reques
|
||||
repo := c.ds.PlayQueue(r.Context())
|
||||
pq, err := repo.Retrieve(user.ID)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.PlayQueue = &responses.PlayQueue{
|
||||
Entry: ChildrenFromMediaFiles(r.Context(), pq.Items),
|
||||
Entry: childrenFromMediaFiles(r.Context(), pq.Items),
|
||||
Current: pq.Current,
|
||||
Position: pq.Position,
|
||||
Username: user.UserName,
|
||||
@@ -96,7 +96,7 @@ func (c *BookmarksController) GetPlayQueue(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
func (c *BookmarksController) SavePlayQueue(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
ids, err := RequiredParamStrings(r, "id", "id parameter required")
|
||||
ids, err := requiredParamStrings(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (c *BookmarksController) SavePlayQueue(w http.ResponseWriter, r *http.Reque
|
||||
repo := c.ds.PlayQueue(r.Context())
|
||||
err = repo.Store(pq)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c *BrowsingController) GetMusicFolders(w http.ResponseWriter, r *http.Requ
|
||||
folders[i].Id = f.ID
|
||||
folders[i].Name = f.Name
|
||||
}
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.MusicFolders = &responses.MusicFolders{Folders: folders}
|
||||
return response, nil
|
||||
}
|
||||
@@ -39,13 +39,13 @@ func (c *BrowsingController) getArtistIndex(ctx context.Context, mediaFolderId s
|
||||
folder, err := c.ds.MediaFolder(ctx).Get(mediaFolderId)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving MediaFolder", "id", mediaFolderId, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
l, err := c.ds.Property(ctx).DefaultGet(model.PropLastScan+"-"+folder.Path, "-1")
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving LastScan property", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
var indexes model.ArtistIndexes
|
||||
@@ -55,7 +55,7 @@ func (c *BrowsingController) getArtistIndex(ctx context.Context, mediaFolderId s
|
||||
indexes, err = c.ds.Artist(ctx).GetIndex()
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving Indexes", err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (c *BrowsingController) GetIndexes(w http.ResponseWriter, r *http.Request)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Indexes = res
|
||||
return response, nil
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func (c *BrowsingController) GetArtists(w http.ResponseWriter, r *http.Request)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Artist = res
|
||||
return response, nil
|
||||
}
|
||||
@@ -111,10 +111,10 @@ func (c *BrowsingController) GetMusicDirectory(w http.ResponseWriter, r *http.Re
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested ID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Directory not found")
|
||||
case err != nil:
|
||||
log.Error(err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
var dir *responses.Directory
|
||||
@@ -126,15 +126,15 @@ func (c *BrowsingController) GetMusicDirectory(w http.ResponseWriter, r *http.Re
|
||||
dir, err = c.buildAlbumDirectory(ctx, v)
|
||||
default:
|
||||
log.Error(r, "Requested ID of invalid type", "id", id, "entity", v)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Directory not found")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Directory = dir
|
||||
return response, nil
|
||||
}
|
||||
@@ -147,19 +147,19 @@ func (c *BrowsingController) GetArtist(w http.ResponseWriter, r *http.Request) (
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(ctx, "Requested ArtistID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Artist not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Artist not found")
|
||||
case err != nil:
|
||||
log.Error(ctx, "Error retrieving artist", "id", id, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
albums, err := c.ds.Album(ctx).FindByArtist(id)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving albums by artist", "id", id, "name", artist.Name, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.ArtistWithAlbumsID3 = c.buildArtist(ctx, artist, albums)
|
||||
return response, nil
|
||||
}
|
||||
@@ -172,19 +172,19 @@ func (c *BrowsingController) GetAlbum(w http.ResponseWriter, r *http.Request) (*
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(ctx, "Requested AlbumID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Album not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Album not found")
|
||||
case err != nil:
|
||||
log.Error(ctx, "Error retrieving album", "id", id, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
mfs, err := c.ds.MediaFile(ctx).FindByAlbum(id)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving tracks from album", "id", id, "name", album.Name, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.AlbumWithSongsID3 = c.buildAlbum(ctx, album, mfs)
|
||||
return response, nil
|
||||
}
|
||||
@@ -197,14 +197,14 @@ func (c *BrowsingController) GetSong(w http.ResponseWriter, r *http.Request) (*r
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Requested MediaFileID not found ", "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Song not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Song not found")
|
||||
case err != nil:
|
||||
log.Error(r, "Error retrieving MediaFile", "id", id, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
child := ChildFromMediaFile(ctx, *mf)
|
||||
response := newResponse()
|
||||
child := childFromMediaFile(ctx, *mf)
|
||||
response.Song = &child
|
||||
return response, nil
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (c *BrowsingController) GetGenres(w http.ResponseWriter, r *http.Request) (
|
||||
genres, err := c.ds.Genre(ctx).GetAll()
|
||||
if err != nil {
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
for i, g := range genres {
|
||||
if strings.TrimSpace(g.Name) == "" {
|
||||
@@ -225,8 +225,8 @@ func (c *BrowsingController) GetGenres(w http.ResponseWriter, r *http.Request) (
|
||||
return genres[i].Name < genres[j].Name
|
||||
})
|
||||
|
||||
response := NewResponse()
|
||||
response.Genres = ToGenres(genres)
|
||||
response := newResponse()
|
||||
response.Genres = toGenres(genres)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ const placeholderArtistImageLargeUrl = "https://lastfm.freetls.fastly.net/i/u/30
|
||||
|
||||
// TODO Integrate with Last.FM
|
||||
func (c *BrowsingController) GetArtistInfo(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.ArtistInfo = &responses.ArtistInfo{}
|
||||
response.ArtistInfo.Biography = "Biography not available"
|
||||
response.ArtistInfo.SmallImageUrl = placeholderArtistImageSmallUrl
|
||||
@@ -247,7 +247,7 @@ func (c *BrowsingController) GetArtistInfo(w http.ResponseWriter, r *http.Reques
|
||||
|
||||
// TODO Integrate with Last.FM
|
||||
func (c *BrowsingController) GetArtistInfo2(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.ArtistInfo2 = &responses.ArtistInfo2{}
|
||||
response.ArtistInfo2.Biography = "Biography not available"
|
||||
response.ArtistInfo2.SmallImageUrl = placeholderArtistImageSmallUrl
|
||||
@@ -258,7 +258,7 @@ func (c *BrowsingController) GetArtistInfo2(w http.ResponseWriter, r *http.Reque
|
||||
|
||||
// TODO Integrate with Last.FM
|
||||
func (c *BrowsingController) GetTopSongs(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.TopSongs = &responses.TopSongs{}
|
||||
return response, nil
|
||||
}
|
||||
@@ -279,7 +279,7 @@ func (c *BrowsingController) buildArtistDirectory(ctx context.Context, artist *m
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dir.Child = ChildrenFromAlbums(ctx, albums)
|
||||
dir.Child = childrenFromAlbums(ctx, albums)
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ func (c *BrowsingController) buildArtist(ctx context.Context, artist *model.Arti
|
||||
dir.Starred = &artist.StarredAt
|
||||
}
|
||||
|
||||
dir.Album = ChildrenFromAlbums(ctx, albums)
|
||||
dir.Album = childrenFromAlbums(ctx, albums)
|
||||
return dir
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func (c *BrowsingController) buildAlbumDirectory(ctx context.Context, album *mod
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dir.Child = ChildrenFromMediaFiles(ctx, mfs)
|
||||
dir.Child = childrenFromMediaFiles(ctx, mfs)
|
||||
return dir, nil
|
||||
}
|
||||
|
||||
@@ -337,6 +337,6 @@ func (c *BrowsingController) buildAlbum(ctx context.Context, album *model.Album,
|
||||
dir.Starred = &album.StarredAt
|
||||
}
|
||||
|
||||
dir.Song = ChildrenFromMediaFiles(ctx, mfs)
|
||||
dir.Song = childrenFromMediaFiles(ctx, mfs)
|
||||
return dir
|
||||
}
|
||||
|
||||
@@ -14,30 +14,30 @@ import (
|
||||
"github.com/deluan/navidrome/utils"
|
||||
)
|
||||
|
||||
func NewResponse() *responses.Subsonic {
|
||||
func newResponse() *responses.Subsonic {
|
||||
return &responses.Subsonic{Status: "ok", Version: Version, Type: consts.AppName, ServerVersion: consts.Version()}
|
||||
}
|
||||
|
||||
func RequiredParamString(r *http.Request, param string, msg string) (string, error) {
|
||||
func requiredParamString(r *http.Request, param string, msg string) (string, error) {
|
||||
p := utils.ParamString(r, param)
|
||||
if p == "" {
|
||||
return "", NewError(responses.ErrorMissingParameter, msg)
|
||||
return "", newError(responses.ErrorMissingParameter, msg)
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func RequiredParamStrings(r *http.Request, param string, msg string) ([]string, error) {
|
||||
func requiredParamStrings(r *http.Request, param string, msg string) ([]string, error) {
|
||||
ps := utils.ParamStrings(r, param)
|
||||
if len(ps) == 0 {
|
||||
return nil, NewError(responses.ErrorMissingParameter, msg)
|
||||
return nil, newError(responses.ErrorMissingParameter, msg)
|
||||
}
|
||||
return ps, nil
|
||||
}
|
||||
|
||||
func RequiredParamInt(r *http.Request, param string, msg string) (int, error) {
|
||||
func requiredParamInt(r *http.Request, param string, msg string) (int, error) {
|
||||
p := utils.ParamString(r, param)
|
||||
if p == "" {
|
||||
return 0, NewError(responses.ErrorMissingParameter, msg)
|
||||
return 0, newError(responses.ErrorMissingParameter, msg)
|
||||
}
|
||||
return utils.ParamInt(r, param, 0), nil
|
||||
}
|
||||
@@ -47,7 +47,7 @@ type SubsonicError struct {
|
||||
messages []interface{}
|
||||
}
|
||||
|
||||
func NewError(code int, message ...interface{}) error {
|
||||
func newError(code int, message ...interface{}) error {
|
||||
return SubsonicError{
|
||||
code: code,
|
||||
messages: message,
|
||||
@@ -64,16 +64,16 @@ func (e SubsonicError) Error() string {
|
||||
return msg
|
||||
}
|
||||
|
||||
func ToAlbums(ctx context.Context, entries engine.Entries) []responses.Child {
|
||||
func toAlbums(ctx context.Context, entries engine.Entries) []responses.Child {
|
||||
children := make([]responses.Child, len(entries))
|
||||
for i, entry := range entries {
|
||||
children[i] = ToAlbum(ctx, entry)
|
||||
children[i] = toAlbum(ctx, entry)
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
func ToAlbum(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
album := ToChild(ctx, entry)
|
||||
func toAlbum(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
album := toChild(ctx, entry)
|
||||
album.Name = album.Title
|
||||
album.Title = ""
|
||||
album.Parent = ""
|
||||
@@ -82,7 +82,7 @@ func ToAlbum(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
return album
|
||||
}
|
||||
|
||||
func ToArtists(entries engine.Entries) []responses.Artist {
|
||||
func toArtists(entries engine.Entries) []responses.Artist {
|
||||
artists := make([]responses.Artist, len(entries))
|
||||
for i, entry := range entries {
|
||||
artists[i] = responses.Artist{
|
||||
@@ -97,15 +97,15 @@ func ToArtists(entries engine.Entries) []responses.Artist {
|
||||
return artists
|
||||
}
|
||||
|
||||
func ToChildren(ctx context.Context, entries engine.Entries) []responses.Child {
|
||||
func toChildren(ctx context.Context, entries engine.Entries) []responses.Child {
|
||||
children := make([]responses.Child, len(entries))
|
||||
for i, entry := range entries {
|
||||
children[i] = ToChild(ctx, entry)
|
||||
children[i] = toChild(ctx, entry)
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
func ToChild(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
func toChild(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
child := responses.Child{}
|
||||
child.Id = entry.Id
|
||||
child.Title = entry.Title
|
||||
@@ -146,7 +146,7 @@ func ToChild(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
return child
|
||||
}
|
||||
|
||||
func ToGenres(genres model.Genres) *responses.Genres {
|
||||
func toGenres(genres model.Genres) *responses.Genres {
|
||||
response := make([]responses.Genre, len(genres))
|
||||
for i, g := range genres {
|
||||
response[i] = responses.Genre(g)
|
||||
@@ -166,7 +166,7 @@ func getTranscoding(ctx context.Context) (format string, bitRate int) {
|
||||
|
||||
// This seems to be duplicated, but it is an initial step into merging `engine` and the `subsonic` packages,
|
||||
// In the future there won't be any conversion to/from `engine. Entry` anymore
|
||||
func ChildFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child {
|
||||
func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child {
|
||||
child := responses.Child{}
|
||||
child.Id = mf.ID
|
||||
child.Title = mf.Title
|
||||
@@ -219,15 +219,15 @@ func realArtistName(mf model.MediaFile) string {
|
||||
return mf.Artist
|
||||
}
|
||||
|
||||
func ChildrenFromMediaFiles(ctx context.Context, mfs model.MediaFiles) []responses.Child {
|
||||
func childrenFromMediaFiles(ctx context.Context, mfs model.MediaFiles) []responses.Child {
|
||||
children := make([]responses.Child, len(mfs))
|
||||
for i, mf := range mfs {
|
||||
children[i] = ChildFromMediaFile(ctx, mf)
|
||||
children[i] = childFromMediaFile(ctx, mf)
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
func ChildFromAlbum(ctx context.Context, al model.Album) responses.Child {
|
||||
func childFromAlbum(ctx context.Context, al model.Album) responses.Child {
|
||||
child := responses.Child{}
|
||||
child.Id = al.ID
|
||||
child.IsDir = true
|
||||
@@ -248,10 +248,10 @@ func ChildFromAlbum(ctx context.Context, al model.Album) responses.Child {
|
||||
return child
|
||||
}
|
||||
|
||||
func ChildrenFromAlbums(ctx context.Context, als model.Albums) []responses.Child {
|
||||
func childrenFromAlbums(ctx context.Context, als model.Albums) []responses.Child {
|
||||
children := make([]responses.Child, len(als))
|
||||
for i, al := range als {
|
||||
children[i] = ChildFromAlbum(ctx, al)
|
||||
children[i] = childFromAlbum(ctx, al)
|
||||
}
|
||||
return children
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ func NewMediaAnnotationController(scrobbler engine.Scrobbler, ds model.DataStore
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) SetRating(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "Required id parameter is missing")
|
||||
id, err := requiredParamString(r, "id", "Required id parameter is missing")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rating, err := RequiredParamInt(r, "rating", "Required rating parameter is missing")
|
||||
rating, err := requiredParamInt(r, "rating", "Required rating parameter is missing")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -37,13 +37,13 @@ func (c *MediaAnnotationController) SetRating(w http.ResponseWriter, r *http.Req
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "ID not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "ID not found")
|
||||
case err != nil:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) setRating(ctx context.Context, id string, rating int) error {
|
||||
@@ -62,7 +62,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)
|
||||
albumIds := utils.ParamStrings(r, "albumId")
|
||||
artistIds := utils.ParamStrings(r, "artistId")
|
||||
if len(ids)+len(albumIds)+len(artistIds) == 0 {
|
||||
return nil, NewError(responses.ErrorMissingParameter, "Required id parameter is missing")
|
||||
return nil, newError(responses.ErrorMissingParameter, "Required id parameter is missing")
|
||||
}
|
||||
ids = append(ids, albumIds...)
|
||||
ids = append(ids, artistIds...)
|
||||
@@ -72,7 +72,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) Unstar(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
@@ -80,7 +80,7 @@ func (c *MediaAnnotationController) Unstar(w http.ResponseWriter, r *http.Reques
|
||||
albumIds := utils.ParamStrings(r, "albumId")
|
||||
artistIds := utils.ParamStrings(r, "artistId")
|
||||
if len(ids)+len(albumIds)+len(artistIds) == 0 {
|
||||
return nil, NewError(responses.ErrorMissingParameter, "Required id parameter is missing")
|
||||
return nil, newError(responses.ErrorMissingParameter, "Required id parameter is missing")
|
||||
}
|
||||
ids = append(ids, albumIds...)
|
||||
ids = append(ids, artistIds...)
|
||||
@@ -90,17 +90,17 @@ func (c *MediaAnnotationController) Unstar(w http.ResponseWriter, r *http.Reques
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) Scrobble(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
ids, err := RequiredParamStrings(r, "id", "Required id parameter is missing")
|
||||
ids, err := requiredParamStrings(r, "id", "Required id parameter is missing")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
times := utils.ParamTimes(r, "time")
|
||||
if len(times) > 0 && len(times) != len(ids) {
|
||||
return nil, NewError(responses.ErrorGeneric, "Wrong number of timestamps: %d, should be %d", len(times), len(ids))
|
||||
return nil, newError(responses.ErrorGeneric, "Wrong number of timestamps: %d, should be %d", len(times), len(ids))
|
||||
}
|
||||
submission := utils.ParamBool(r, "submission", true)
|
||||
playerId := 1 // TODO Multiple players, based on playerName/username/clientIP(?)
|
||||
@@ -129,7 +129,7 @@ func (c *MediaAnnotationController) Scrobble(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
}
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) setStar(ctx context.Context, star bool, ids ...string) error {
|
||||
@@ -177,10 +177,10 @@ func (c *MediaAnnotationController) setStar(ctx context.Context, star bool, ids
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(ctx, err)
|
||||
return NewError(responses.ErrorDataNotFound, "ID not found")
|
||||
return newError(responses.ErrorDataNotFound, "ID not found")
|
||||
case err != nil:
|
||||
log.Error(ctx, err)
|
||||
return NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *MediaRetrievalController) GetAvatar(w http.ResponseWriter, r *http.Requ
|
||||
f, err := resources.AssetFile().Open(consts.PlaceholderAlbumArt)
|
||||
if err != nil {
|
||||
log.Error(r, "Image not found", err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Avatar image not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Avatar image not found")
|
||||
}
|
||||
defer f.Close()
|
||||
_, _ = io.Copy(w, f)
|
||||
@@ -34,7 +34,7 @@ func (c *MediaRetrievalController) GetAvatar(w http.ResponseWriter, r *http.Requ
|
||||
}
|
||||
|
||||
func (c *MediaRetrievalController) GetCoverArt(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -46,10 +46,10 @@ func (c *MediaRetrievalController) GetCoverArt(w http.ResponseWriter, r *http.Re
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, "Couldn't find coverArt", "id", id, err)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Artwork not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Artwork not found")
|
||||
case err != nil:
|
||||
log.Error(r, "Error retrieving coverArt", "id", id, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
|
||||
@@ -23,7 +23,7 @@ func postFormToQueryParams(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
SendError(w, r, NewError(responses.ErrorGeneric, err.Error()))
|
||||
SendError(w, r, newError(responses.ErrorGeneric, err.Error()))
|
||||
}
|
||||
var parts []string
|
||||
for key, values := range r.Form {
|
||||
@@ -45,7 +45,7 @@ func checkRequiredParameters(next http.Handler) http.Handler {
|
||||
if utils.ParamString(r, p) == "" {
|
||||
msg := fmt.Sprintf(`Missing required parameter "%s"`, p)
|
||||
log.Warn(r, msg)
|
||||
SendError(w, r, NewError(responses.ErrorMissingParameter, msg))
|
||||
SendError(w, r, newError(responses.ErrorMissingParameter, msg))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ func authenticate(users engine.Users) func(next http.Handler) http.Handler {
|
||||
|
||||
if err != nil {
|
||||
log.Warn(r, "Invalid login", "username", username)
|
||||
SendError(w, r, NewError(responses.ErrorAuthenticationFail))
|
||||
SendError(w, r, newError(responses.ErrorAuthenticationFail))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func (c *PlaylistsController) GetPlaylists(w http.ResponseWriter, r *http.Reques
|
||||
allPls, err := c.pls.GetAll(r.Context())
|
||||
if err != nil {
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal error")
|
||||
}
|
||||
playlists := make([]responses.Playlist, len(allPls))
|
||||
for i, p := range allPls {
|
||||
@@ -39,13 +39,13 @@ func (c *PlaylistsController) GetPlaylists(w http.ResponseWriter, r *http.Reques
|
||||
playlists[i].Created = p.CreatedAt
|
||||
playlists[i].Changed = p.UpdatedAt
|
||||
}
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Playlists = &responses.Playlists{Playlist: playlists}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) GetPlaylist(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -53,13 +53,13 @@ func (c *PlaylistsController) GetPlaylist(w http.ResponseWriter, r *http.Request
|
||||
switch {
|
||||
case err == model.ErrNotFound:
|
||||
log.Error(r, err.Error(), "id", id)
|
||||
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
|
||||
return nil, newError(responses.ErrorDataNotFound, "Directory not found")
|
||||
case err != nil:
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.Playlist = c.buildPlaylistWithSongs(r.Context(), pinfo)
|
||||
return response, nil
|
||||
}
|
||||
@@ -74,29 +74,29 @@ func (c *PlaylistsController) CreatePlaylist(w http.ResponseWriter, r *http.Requ
|
||||
err := c.pls.Create(r.Context(), playlistId, name, songIds)
|
||||
if err != nil {
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) DeletePlaylist(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "Required parameter id is missing")
|
||||
id, err := requiredParamString(r, "id", "Required parameter id is missing")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = c.pls.Delete(r.Context(), id)
|
||||
if err == model.ErrNotAuthorized {
|
||||
return nil, NewError(responses.ErrorAuthorizationFail)
|
||||
return nil, newError(responses.ErrorAuthorizationFail)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) UpdatePlaylist(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
playlistId, err := RequiredParamString(r, "playlistId", "Required parameter playlistId is missing")
|
||||
playlistId, err := requiredParamString(r, "playlistId", "Required parameter playlistId is missing")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -118,20 +118,20 @@ func (c *PlaylistsController) UpdatePlaylist(w http.ResponseWriter, r *http.Requ
|
||||
|
||||
err = c.pls.Update(r.Context(), playlistId, pname, songsToAdd, songIndexesToRemove)
|
||||
if err == model.ErrNotAuthorized {
|
||||
return nil, NewError(responses.ErrorAuthorizationFail)
|
||||
return nil, newError(responses.ErrorAuthorizationFail)
|
||||
}
|
||||
if err != nil {
|
||||
log.Error(r, err)
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) buildPlaylistWithSongs(ctx context.Context, d *engine.PlaylistInfo) *responses.PlaylistWithSongs {
|
||||
pls := &responses.PlaylistWithSongs{
|
||||
Playlist: *c.buildPlaylist(d),
|
||||
}
|
||||
pls.Entry = ToChildren(ctx, d.Entries)
|
||||
pls.Entry = toChildren(ctx, d.Entries)
|
||||
return pls
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func NewSearchingController(search engine.Search) *SearchingController {
|
||||
func (c *SearchingController) getParams(r *http.Request) (*searchParams, error) {
|
||||
var err error
|
||||
sp := &searchParams{}
|
||||
sp.query, err = RequiredParamString(r, "query", "Parameter query required")
|
||||
sp.query, err = requiredParamString(r, "query", "Parameter query required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -69,11 +69,11 @@ func (c *SearchingController) Search2(w http.ResponseWriter, r *http.Request) (*
|
||||
}
|
||||
mfs, als, as := c.searchAll(r, sp)
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
searchResult2 := &responses.SearchResult2{}
|
||||
searchResult2.Artist = ToArtists(as)
|
||||
searchResult2.Album = ToChildren(r.Context(), als)
|
||||
searchResult2.Song = ToChildren(r.Context(), mfs)
|
||||
searchResult2.Artist = toArtists(as)
|
||||
searchResult2.Album = toChildren(r.Context(), als)
|
||||
searchResult2.Song = toChildren(r.Context(), mfs)
|
||||
response.SearchResult2 = searchResult2
|
||||
return response, nil
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (c *SearchingController) Search3(w http.ResponseWriter, r *http.Request) (*
|
||||
}
|
||||
mfs, als, as := c.searchAll(r, sp)
|
||||
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
searchResult3 := &responses.SearchResult3{}
|
||||
searchResult3.Artist = make([]responses.ArtistID3, len(as))
|
||||
for i, e := range as {
|
||||
@@ -99,8 +99,8 @@ func (c *SearchingController) Search3(w http.ResponseWriter, r *http.Request) (*
|
||||
searchResult3.Artist[i].Starred = &e.Starred
|
||||
}
|
||||
}
|
||||
searchResult3.Album = ToAlbums(r.Context(), als)
|
||||
searchResult3.Song = ToChildren(r.Context(), mfs)
|
||||
searchResult3.Album = toAlbums(r.Context(), als)
|
||||
searchResult3.Song = toChildren(r.Context(), mfs)
|
||||
response.SearchResult3 = searchResult3
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func NewStreamController(streamer core.MediaStreamer, archiver core.Archiver, ds
|
||||
}
|
||||
|
||||
func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (c *StreamController) Stream(w http.ResponseWriter, r *http.Request) (*resp
|
||||
}
|
||||
|
||||
func (c *StreamController) Download(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := RequiredParamString(r, "id", "id parameter required")
|
||||
id, err := requiredParamString(r, "id", "id parameter required")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ func NewSystemController() *SystemController {
|
||||
}
|
||||
|
||||
func (c *SystemController) Ping(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
return NewResponse(), nil
|
||||
return newResponse(), nil
|
||||
}
|
||||
|
||||
func (c *SystemController) GetLicense(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.License = &responses.License{Valid: true}
|
||||
return response, nil
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ func NewUsersController() *UsersController {
|
||||
|
||||
// TODO This is a placeholder. The real one has to read this info from a config file or the database
|
||||
func (c *UsersController) GetUser(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
user, err := RequiredParamString(r, "username", "Required string parameter 'username' is not present")
|
||||
user, err := requiredParamString(r, "username", "Required string parameter 'username' is not present")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response := NewResponse()
|
||||
response := newResponse()
|
||||
response.User = &responses.User{}
|
||||
response.User.Username = user
|
||||
response.User.StreamRole = true
|
||||
|
||||
Reference in New Issue
Block a user