Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
998f320e31
|
||
|
|
3836e97ccb
|
No files matched your search
@@ -24,7 +24,7 @@
|
|||||||
- support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
|
- support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
|
||||||
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
|
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
|
||||||
- newer salt and token auth
|
- newer salt and token auth
|
||||||
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [amperfy](https://github.com/BLeeEZ/amperfy), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](https://github.com/sqrlmstr5000/Jamstash), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [termsonic](https://git.sixfoisneuf.fr/termsonic/), [tempus](https://github.com/eddyizm/tempus/), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
|
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [termsonic](https://git.sixfoisneuf.fr/termsonic/), [tempus](https://github.com/eddyizm/tempus/), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
|
||||||
|
|
||||||
## installation
|
## installation
|
||||||
|
|
||||||
@@ -52,6 +52,7 @@ password can then be changed from the web interface
|
|||||||
| env var | command line arg | description |
|
| env var | command line arg | description |
|
||||||
| ----------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) |
|
| `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) |
|
||||||
|
| `GONIC_DEFAULT_MUSIC_PATH` | `-default-music-path` | default music path for when no folder is selected in client (useful for when client does not support choosing a folder) |
|
||||||
| `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory |
|
| `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory |
|
||||||
| `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. |
|
| `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. |
|
||||||
| `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc |
|
| `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc |
|
||||||
|
|||||||
+2
-1
@@ -62,6 +62,7 @@ func main() {
|
|||||||
|
|
||||||
var confMusicPaths pathAliases
|
var confMusicPaths pathAliases
|
||||||
flag.Var(&confMusicPaths, "music-path", "path to music")
|
flag.Var(&confMusicPaths, "music-path", "path to music")
|
||||||
|
defaultMusicPath := flag.String("default-music-path", "", "interval (in minutes) to automatically scan music (optional)")
|
||||||
|
|
||||||
confPlaylistsPath := flag.String("playlists-path", "", "path to your list of new or existing m3u playlists that gonic can manage")
|
confPlaylistsPath := flag.String("playlists-path", "", "path to your list of new or existing m3u playlists that gonic can manage")
|
||||||
|
|
||||||
@@ -256,7 +257,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error creating admin controller: %v\n", err)
|
log.Panicf("error creating admin controller: %v\n", err)
|
||||||
}
|
}
|
||||||
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath)
|
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *defaultMusicPath, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("error creating subsonic controller: %v\n", err)
|
log.Panicf("error creating subsonic controller: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ type Track struct {
|
|||||||
TagDiscNumber int `sql:"default: null"`
|
TagDiscNumber int `sql:"default: null"`
|
||||||
TagBrainzID string `sql:"default: null"`
|
TagBrainzID string `sql:"default: null"`
|
||||||
TagLyrics string `sql:"default: null"`
|
TagLyrics string `sql:"default: null"`
|
||||||
TagYear int `sql:"default: null"`
|
|
||||||
|
|
||||||
ReplayGainTrackGain float32
|
ReplayGainTrackGain float32
|
||||||
ReplayGainTrackPeak float32
|
ReplayGainTrackPeak float32
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
|||||||
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
|
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
|
||||||
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
|
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
|
||||||
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
|
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
|
||||||
construct(ctx, "202602061800", migrateAddTrackYear),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return gormigrate.
|
return gormigrate.
|
||||||
@@ -880,22 +879,3 @@ func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
|
|||||||
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
|
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
|
||||||
return tx.AutoMigrate(AlbumDiscTitle{}).Error
|
return tx.AutoMigrate(AlbumDiscTitle{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func migrateAddTrackYear(tx *gorm.DB, _ MigrationContext) error {
|
|
||||||
step := tx.AutoMigrate(Track{})
|
|
||||||
if err := step.Error; err != nil {
|
|
||||||
return fmt.Errorf("step auto migrate: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
step = tx.Exec(`
|
|
||||||
UPDATE tracks
|
|
||||||
SET tag_year=(SELECT tag_year
|
|
||||||
FROM albums
|
|
||||||
WHERE tracks.album_id = albums.id)
|
|
||||||
`)
|
|
||||||
if err := step.Error; err != nil {
|
|
||||||
return fmt.Errorf("step set default track year based on album's : %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ package listenbrainz
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/tls"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -31,17 +30,7 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewClient() *Client {
|
func NewClient() *Client {
|
||||||
// disable post-quantum key exchange (Kyber) to avoid "connection reset by peer" errors.
|
return NewClientCustom(http.DefaultClient)
|
||||||
// listenbrainz's server can't handle the larger TLS ClientHello
|
|
||||||
// https://github.com/golang/go/issues/70139
|
|
||||||
return NewClientCustom(&http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
TLSClientConfig: &tls.Config{
|
|
||||||
MinVersion: tls.VersionTLS12,
|
|
||||||
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256, tls.CurveP384},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientCustom(httpClient *http.Client) *Client {
|
func NewClientCustom(httpClient *http.Client) *Client {
|
||||||
|
|||||||
@@ -134,9 +134,6 @@ func (s *Store) Read(relPath string) (*Playlist, error) {
|
|||||||
if strings.HasPrefix(line, "#") {
|
if strings.HasPrefix(line, "#") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !filepath.IsAbs(line) {
|
|
||||||
line = filepath.Join(filepath.Dir(absPath), line)
|
|
||||||
}
|
|
||||||
playlist.Items = append(playlist.Items, line)
|
playlist.Items = append(playlist.Items, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +186,6 @@ func (s *Store) Write(relPath string, playlist *Playlist) error {
|
|||||||
fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment))
|
fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment))
|
||||||
fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic)))
|
fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic)))
|
||||||
for _, line := range playlist.Items {
|
for _, line := range playlist.Items {
|
||||||
if rel, err := filepath.Rel(filepath.Dir(absPath), line); err == nil {
|
|
||||||
line = rel
|
|
||||||
}
|
|
||||||
fmt.Fprintln(file, line)
|
fmt.Fprintln(file, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ Example comment
|
|||||||
It has multiple lines 👍
|
It has multiple lines 👍
|
||||||
`,
|
`,
|
||||||
Items: []string{
|
Items: []string{
|
||||||
"/music/item 1.flac",
|
"item 1.flac",
|
||||||
"/music/item 2.flac",
|
"item 2.flac",
|
||||||
"/music/item 3.flac",
|
"item 3.flac",
|
||||||
},
|
},
|
||||||
IsPublic: true,
|
IsPublic: true,
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-17
@@ -81,17 +81,13 @@ func (p *Podcasts) AddNewPodcast(rssURL string, feed *gofeed.Feed) (*db.Podcast,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("find unique podcast dir: %w", err)
|
return nil, fmt.Errorf("find unique podcast dir: %w", err)
|
||||||
}
|
}
|
||||||
var author string
|
|
||||||
if feed.ITunesExt != nil {
|
|
||||||
author = feed.ITunesExt.Author
|
|
||||||
}
|
|
||||||
podcast := db.Podcast{
|
podcast := db.Podcast{
|
||||||
Description: feed.Description,
|
Description: feed.Description,
|
||||||
ImageURL: "",
|
ImageURL: "",
|
||||||
Title: feed.Title,
|
Title: feed.Title,
|
||||||
URL: rssURL,
|
URL: rssURL,
|
||||||
RootDir: rootDir,
|
RootDir: rootDir,
|
||||||
Author: author,
|
Author: feed.ITunesExt.Author,
|
||||||
}
|
}
|
||||||
if feed.Image != nil {
|
if feed.Image != nil {
|
||||||
podcast.ImageURL = feed.Image.URL
|
podcast.ImageURL = feed.Image.URL
|
||||||
@@ -230,10 +226,6 @@ func (p *Podcasts) isAudio(rawItemURL string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *gofeed.Item) *db.PodcastEpisode {
|
func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *gofeed.Item) *db.PodcastEpisode {
|
||||||
author := podcast.Author
|
|
||||||
if item.ITunesExt != nil {
|
|
||||||
author = cmp.Or(item.ITunesExt.Author, podcast.Author)
|
|
||||||
}
|
|
||||||
return &db.PodcastEpisode{
|
return &db.PodcastEpisode{
|
||||||
PodcastID: podcast.ID,
|
PodcastID: podcast.ID,
|
||||||
Description: item.Description,
|
Description: item.Description,
|
||||||
@@ -243,7 +235,7 @@ func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *
|
|||||||
PublishDate: item.PublishedParsed,
|
PublishDate: item.PublishedParsed,
|
||||||
AudioURL: audio,
|
AudioURL: audio,
|
||||||
Status: db.PodcastEpisodeStatusSkipped,
|
Status: db.PodcastEpisodeStatusSkipped,
|
||||||
Artist: cmp.Or(author),
|
Artist: cmp.Or(item.ITunesExt.Author, podcast.Author),
|
||||||
Album: podcast.Title,
|
Album: podcast.Title,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -516,13 +508,6 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
podcastEpisode.Status = db.PodcastEpisodeStatusError
|
|
||||||
_ = p.db.Save(podcastEpisode).Error
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if resp.StatusCode/100 != 2 {
|
if resp.StatusCode/100 != 2 {
|
||||||
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
|
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
|
||||||
}
|
}
|
||||||
@@ -544,6 +529,13 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
podcastEpisode.Status = db.PodcastEpisodeStatusError
|
||||||
|
_ = p.db.Save(podcastEpisode).Error
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if _, err := io.Copy(file, resp.Body); err != nil {
|
if _, err := io.Copy(file, resp.Body); err != nil {
|
||||||
return fmt.Errorf("writing podcast episode: %w", err)
|
return fmt.Errorf("writing podcast episode: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,6 @@ func (s *Scanner) ExecuteWatch(ctx context.Context) error {
|
|||||||
case event := <-watcher.Events:
|
case event := <-watcher.Events:
|
||||||
if event.Op&(fsnotify.Remove) == fsnotify.Remove {
|
if event.Op&(fsnotify.Remove) == fsnotify.Remove {
|
||||||
batchClean = true
|
batchClean = true
|
||||||
batchT.Reset(batchInterval)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if event.Op&(fsnotify.Create|fsnotify.Write) == 0 {
|
if event.Op&(fsnotify.Create|fsnotify.Write) == 0 {
|
||||||
@@ -570,7 +569,6 @@ func populateTrack(tx *db.DB, scanEmbeddedCover bool, album *db.Album, track *db
|
|||||||
track.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
|
track.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
|
||||||
track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
|
track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
|
||||||
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
|
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
|
||||||
track.TagYear = tags.MustYear(trags)
|
|
||||||
|
|
||||||
track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
|
track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
|
||||||
track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
|
track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ type Controller struct {
|
|||||||
dbc *db.DB
|
dbc *db.DB
|
||||||
scanner *scanner.Scanner
|
scanner *scanner.Scanner
|
||||||
musicPaths []MusicPath
|
musicPaths []MusicPath
|
||||||
|
defaultMusicPath string
|
||||||
podcastsPath string
|
podcastsPath string
|
||||||
cacheAudioPath string
|
cacheAudioPath string
|
||||||
cacheCoverPath string
|
cacheCoverPath string
|
||||||
@@ -72,13 +73,14 @@ type Controller struct {
|
|||||||
resolveProxyPath ProxyPathResolver
|
resolveProxyPath ProxyPathResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, tagReader tags.Reader, resolveProxyPath ProxyPathResolver) (*Controller, error) {
|
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, defaultMusicPath string, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, tagReader tags.Reader, resolveProxyPath ProxyPathResolver) (*Controller, error) {
|
||||||
c := Controller{
|
c := Controller{
|
||||||
ServeMux: http.NewServeMux(),
|
ServeMux: http.NewServeMux(),
|
||||||
|
|
||||||
dbc: dbc,
|
dbc: dbc,
|
||||||
scanner: scannr,
|
scanner: scannr,
|
||||||
musicPaths: musicPaths,
|
musicPaths: musicPaths,
|
||||||
|
defaultMusicPath: defaultMusicPath,
|
||||||
podcastsPath: podcastsPath,
|
podcastsPath: podcastsPath,
|
||||||
cacheAudioPath: cacheAudioPath,
|
cacheAudioPath: cacheAudioPath,
|
||||||
cacheCoverPath: cacheCoverPath,
|
cacheCoverPath: cacheCoverPath,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func (c *Controller) ServeGetIndexes(r *http.Request) *spec.Response {
|
|||||||
Select("id").
|
Select("id").
|
||||||
Model(&db.Album{}).
|
Model(&db.Album{}).
|
||||||
Where("parent_id IS NULL")
|
Where("parent_id IS NULL")
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
rootQ = rootQ.
|
rootQ = rootQ.
|
||||||
Where("root_dir=?", m)
|
Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ func (c *Controller) ServeGetAlbumList(r *http.Request) *spec.Response {
|
|||||||
return spec.NewError(10, "unknown value %q for parameter 'type'", v)
|
return spec.NewError(10, "unknown value %q for parameter 'type'", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("root_dir=?", m)
|
q = q.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
var folders []*db.Album
|
var folders []*db.Album
|
||||||
@@ -220,7 +220,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
|
|||||||
Select("id").
|
Select("id").
|
||||||
Model(&db.Album{}).
|
Model(&db.Album{}).
|
||||||
Where("parent_id IS NULL")
|
Where("parent_id IS NULL")
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
rootQ = rootQ.Where("root_dir=?", m)
|
rootQ = rootQ.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
|
|||||||
Preload("AlbumRating", "user_id=?", user.ID).
|
Preload("AlbumRating", "user_id=?", user.ID).
|
||||||
Offset(params.GetOrInt("albumOffset", 0)).
|
Offset(params.GetOrInt("albumOffset", 0)).
|
||||||
Limit(params.GetOrInt("albumCount", 20))
|
Limit(params.GetOrInt("albumCount", 20))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("root_dir=?", m)
|
q = q.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&albums).Error; err != nil {
|
if err := q.Find(&albums).Error; err != nil {
|
||||||
@@ -287,7 +287,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
|
|||||||
Preload("TrackRating", "user_id=?", user.ID).
|
Preload("TrackRating", "user_id=?", user.ID).
|
||||||
Offset(params.GetOrInt("songOffset", 0)).
|
Offset(params.GetOrInt("songOffset", 0)).
|
||||||
Limit(params.GetOrInt("songCount", 20))
|
Limit(params.GetOrInt("songCount", 20))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.
|
q = q.
|
||||||
Joins("JOIN albums ON albums.id=tracks.album_id").
|
Joins("JOIN albums ON albums.id=tracks.album_id").
|
||||||
Where("albums.root_dir=?", m)
|
Where("albums.root_dir=?", m)
|
||||||
@@ -320,44 +320,56 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
|
|||||||
results := &spec.Starred{}
|
results := &spec.Starred{}
|
||||||
|
|
||||||
// "artists"
|
// "artists"
|
||||||
rootQ := c.dbc.
|
var artists []*db.Artist
|
||||||
Select("id").
|
|
||||||
Model(&db.Album{}).
|
|
||||||
Where("parent_id IS NULL")
|
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
|
||||||
rootQ = rootQ.Where("root_dir=?", m)
|
|
||||||
}
|
|
||||||
|
|
||||||
var artists []*db.Album
|
|
||||||
q := c.dbc.
|
q := c.dbc.
|
||||||
Where(`parent_id IN ?`, rootQ.SubQuery()).
|
Select("artists.*, count(albums.id) album_count").
|
||||||
Joins("JOIN album_stars ON albums.id=album_stars.album_id").
|
Joins("JOIN artist_stars ON artist_stars.artist_id=artists.id").
|
||||||
Where("album_stars.user_id=?", user.ID).
|
Where("artist_stars.user_id=?", user.ID).
|
||||||
Preload("AlbumStar", "user_id=?", user.ID).
|
Joins("JOIN artist_appearances ON artist_appearances.artist_id=artists.id").
|
||||||
Preload("AlbumRating", "user_id=?", user.ID)
|
Joins("JOIN albums ON albums.id=artist_appearances.album_id").
|
||||||
|
Order("artist_stars.star_date DESC").
|
||||||
|
Preload("ArtistStar", "user_id=?", user.ID).
|
||||||
|
Preload("ArtistRating", "user_id=?", user.ID).
|
||||||
|
Preload("Info").
|
||||||
|
Group("artists.id")
|
||||||
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
|
q = q.Where("albums.root_dir=?", m)
|
||||||
|
}
|
||||||
if err := q.Find(&artists).Error; err != nil {
|
if err := q.Find(&artists).Error; err != nil {
|
||||||
return spec.NewError(0, "find artists: %v", err)
|
return spec.NewError(0, "find artists: %v", err)
|
||||||
}
|
}
|
||||||
for _, a := range artists {
|
for _, a := range artists {
|
||||||
results.Artists = append(results.Artists, spec.NewDirectoryByFolder(a, nil))
|
results.Artists = append(results.Artists, spec.NewArtistByTags(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
// "albums"
|
// "albums"
|
||||||
var albums []*db.Album
|
var albums []*db.Album
|
||||||
q = c.dbc.
|
q = c.dbc.Where("parent_id IS NOT NULL").
|
||||||
Joins("JOIN album_artists ON album_artists.album_id=albums.id").
|
Joins("JOIN album_stars ON albums.id=album_stars.album_id AND album_stars.user_id=?", user.ID)
|
||||||
Joins("JOIN album_stars ON albums.id=album_stars.album_id").
|
q = q.Order("album_stars.star_date DESC")
|
||||||
Where("album_stars.user_id=?", user.ID).
|
|
||||||
|
q = q.
|
||||||
Preload("AlbumStar", "user_id=?", user.ID).
|
Preload("AlbumStar", "user_id=?", user.ID).
|
||||||
Preload("AlbumRating", "user_id=?", user.ID)
|
Preload("AlbumRating", "user_id=?", user.ID)
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
|
||||||
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("root_dir=?", m)
|
q = q.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
q.
|
||||||
|
Select("albums.*, count(tracks.id) child_count, sum(tracks.length) duration").
|
||||||
|
Joins("LEFT JOIN tracks ON tracks.album_id=albums.id").
|
||||||
|
Group("albums.id").
|
||||||
|
Joins("JOIN album_artists ON album_artists.album_id=albums.id").
|
||||||
|
Preload("Parent").
|
||||||
|
Preload("AlbumStar", "user_id=?", user.ID).
|
||||||
|
Preload("AlbumRating", "user_id=?", user.ID)
|
||||||
|
|
||||||
if err := q.Find(&albums).Error; err != nil {
|
if err := q.Find(&albums).Error; err != nil {
|
||||||
return spec.NewError(0, "find albums: %v", err)
|
return spec.NewError(0, "find albums: %v", err)
|
||||||
}
|
}
|
||||||
for _, a := range albums {
|
for _, a := range albums {
|
||||||
results.Albums = append(results.Albums, spec.NewTCAlbumByFolder(a))
|
results.Albums = append(results.Albums, spec.NewAlbumByFolder(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
// tracks
|
// tracks
|
||||||
@@ -369,7 +381,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
|
|||||||
Preload("Artists").
|
Preload("Artists").
|
||||||
Preload("TrackStar", "user_id=?", user.ID).
|
Preload("TrackStar", "user_id=?", user.ID).
|
||||||
Preload("TrackRating", "user_id=?", user.ID)
|
Preload("TrackRating", "user_id=?", user.ID)
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.
|
q = q.
|
||||||
Joins("JOIN albums ON albums.id=tracks.album_id").
|
Joins("JOIN albums ON albums.id=tracks.album_id").
|
||||||
Where("albums.root_dir=?", m)
|
Where("albums.root_dir=?", m)
|
||||||
|
|||||||
@@ -28,12 +28,13 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
|
|||||||
q := c.dbc.
|
q := c.dbc.
|
||||||
Select("*, count(album_artists.album_id) album_count").
|
Select("*, count(album_artists.album_id) album_count").
|
||||||
Joins("JOIN album_artists ON album_artists.artist_id=artists.id").
|
Joins("JOIN album_artists ON album_artists.artist_id=artists.id").
|
||||||
|
Joins("LEFT JOIN artist_stars ON artist_stars.artist_id=artists.id").
|
||||||
Preload("ArtistStar", "user_id=?", user.ID).
|
Preload("ArtistStar", "user_id=?", user.ID).
|
||||||
Preload("ArtistRating", "user_id=?", user.ID).
|
Preload("ArtistRating", "user_id=?", user.ID).
|
||||||
Preload("Info").
|
Preload("Info").
|
||||||
Group("artists.id").
|
Group("artists.id").
|
||||||
Order("artists.name COLLATE NOCASE")
|
Order("artists.name COLLATE NOCASE")
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.
|
q = q.
|
||||||
Joins("JOIN albums ON albums.id=album_artists.album_id").
|
Joins("JOIN albums ON albums.id=album_artists.album_id").
|
||||||
Where("albums.root_dir=?", m)
|
Where("albums.root_dir=?", m)
|
||||||
@@ -186,7 +187,7 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
|
|||||||
default:
|
default:
|
||||||
return spec.NewError(10, "unknown value %q for parameter 'type'", listType)
|
return spec.NewError(10, "unknown value %q for parameter 'type'", listType)
|
||||||
}
|
}
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("root_dir=?", m)
|
q = q.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
var albums []*db.Album
|
var albums []*db.Album
|
||||||
@@ -254,7 +255,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
|
|||||||
Preload("Info").
|
Preload("Info").
|
||||||
Offset(params.GetOrInt("artistOffset", 0)).
|
Offset(params.GetOrInt("artistOffset", 0)).
|
||||||
Limit(params.GetOrInt("artistCount", 20))
|
Limit(params.GetOrInt("artistCount", 20))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("albums.root_dir=?", m)
|
q = q.Where("albums.root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&artists).Error; err != nil {
|
if err := q.Find(&artists).Error; err != nil {
|
||||||
@@ -283,7 +284,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
|
|||||||
q = q.
|
q = q.
|
||||||
Offset(params.GetOrInt("albumOffset", 0)).
|
Offset(params.GetOrInt("albumOffset", 0)).
|
||||||
Limit(params.GetOrInt("albumCount", 20))
|
Limit(params.GetOrInt("albumCount", 20))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("root_dir=?", m)
|
q = q.Where("root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&albums).Error; err != nil {
|
if err := q.Find(&albums).Error; err != nil {
|
||||||
@@ -311,7 +312,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
|
|||||||
}
|
}
|
||||||
q = q.Offset(params.GetOrInt("songOffset", 0)).
|
q = q.Offset(params.GetOrInt("songOffset", 0)).
|
||||||
Limit(params.GetOrInt("songCount", 20))
|
Limit(params.GetOrInt("songCount", 20))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.
|
q = q.
|
||||||
Joins("JOIN albums ON albums.id=tracks.album_id").
|
Joins("JOIN albums ON albums.id=tracks.album_id").
|
||||||
Where("albums.root_dir=?", m)
|
Where("albums.root_dir=?", m)
|
||||||
@@ -482,7 +483,7 @@ func (c *Controller) ServeGetSongsByGenre(r *http.Request) *spec.Response {
|
|||||||
Preload("TrackRating", "user_id=?", user.ID).
|
Preload("TrackRating", "user_id=?", user.ID).
|
||||||
Offset(params.GetOrInt("offset", 0)).
|
Offset(params.GetOrInt("offset", 0)).
|
||||||
Limit(params.GetOrInt("count", 10))
|
Limit(params.GetOrInt("count", 10))
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("albums.root_dir=?", m)
|
q = q.Where("albums.root_dir=?", m)
|
||||||
}
|
}
|
||||||
q = q.Group("tracks.id")
|
q = q.Group("tracks.id")
|
||||||
@@ -523,7 +524,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
|
|||||||
Preload("ArtistRating", "user_id=?", user.ID).
|
Preload("ArtistRating", "user_id=?", user.ID).
|
||||||
Preload("Info").
|
Preload("Info").
|
||||||
Group("artists.id")
|
Group("artists.id")
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("albums.root_dir=?", m)
|
q = q.Where("albums.root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&artists).Error; err != nil {
|
if err := q.Find(&artists).Error; err != nil {
|
||||||
@@ -544,7 +545,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
|
|||||||
Preload("AlbumStar", "user_id=?", user.ID).
|
Preload("AlbumStar", "user_id=?", user.ID).
|
||||||
Preload("AlbumRating", "user_id=?", user.ID).
|
Preload("AlbumRating", "user_id=?", user.ID).
|
||||||
Preload("Play", "user_id=?", user.ID)
|
Preload("Play", "user_id=?", user.ID)
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("albums.root_dir=?", m)
|
q = q.Where("albums.root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&albums).Error; err != nil {
|
if err := q.Find(&albums).Error; err != nil {
|
||||||
@@ -565,7 +566,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
|
|||||||
Preload("Artists").
|
Preload("Artists").
|
||||||
Preload("TrackStar", "user_id=?", user.ID).
|
Preload("TrackStar", "user_id=?", user.ID).
|
||||||
Preload("TrackRating", "user_id=?", user.ID)
|
Preload("TrackRating", "user_id=?", user.ID)
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.
|
q = q.
|
||||||
Joins("JOIN albums ON albums.id=tracks.album_id").
|
Joins("JOIN albums ON albums.id=tracks.album_id").
|
||||||
Where("albums.root_dir=?", m)
|
Where("albums.root_dir=?", m)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
|
|||||||
return spec.NewError(0, "error updating stats: %v", err)
|
return spec.NewError(0, "error updating stats: %v", err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return spec.NewError(0, "can't scrobble type %s", id.Type)
|
return spec.NewError(10, "can't scrobble type %s", id.Type)
|
||||||
}
|
}
|
||||||
|
|
||||||
if scrobbleTrack.Track == "" {
|
if scrobbleTrack.Track == "" {
|
||||||
@@ -334,7 +334,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
|
|||||||
q = q.Joins("JOIN track_genres ON track_genres.track_id=tracks.id")
|
q = q.Joins("JOIN track_genres ON track_genres.track_id=tracks.id")
|
||||||
q = q.Joins("JOIN genres ON genres.id=track_genres.genre_id AND genres.name=?", genre)
|
q = q.Joins("JOIN genres ON genres.id=track_genres.genre_id AND genres.name=?", genre)
|
||||||
}
|
}
|
||||||
if m := getMusicFolder(c.musicPaths, params); m != "" {
|
if m := getMusicFolder(c, params); m != "" {
|
||||||
q = q.Where("albums.root_dir=?", m)
|
q = q.Where("albums.root_dir=?", m)
|
||||||
}
|
}
|
||||||
if err := q.Find(&tracks).Error; err != nil {
|
if err := q.Find(&tracks).Error; err != nil {
|
||||||
@@ -777,10 +777,11 @@ func scrobbleStatsUpdatePodcastEpisode(dbc *db.DB, peID int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMusicFolder(musicPaths []MusicPath, p params.Params) string {
|
func getMusicFolder(c *Controller, p params.Params) string {
|
||||||
|
musicPaths := c.musicPaths
|
||||||
idx, err := p.GetInt("musicFolderId")
|
idx, err := p.GetInt("musicFolderId")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return c.defaultMusicPath
|
||||||
}
|
}
|
||||||
if idx < 0 || idx >= len(musicPaths) {
|
if idx < 0 || idx >= len(musicPaths) {
|
||||||
return os.DevNull
|
return os.DevNull
|
||||||
|
|||||||
@@ -14,13 +14,10 @@ import (
|
|||||||
func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response {
|
func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response {
|
||||||
params := r.Context().Value(CtxParams).(params.Params)
|
params := r.Context().Value(CtxParams).(params.Params)
|
||||||
isIncludeEpisodes := params.GetOrBool("includeEpisodes", true)
|
isIncludeEpisodes := params.GetOrBool("includeEpisodes", true)
|
||||||
id, err := params.GetID("id")
|
id, _ := params.GetID("id")
|
||||||
if err != nil {
|
|
||||||
return spec.NewError(10, "failed get podcast(s): %s", err)
|
|
||||||
}
|
|
||||||
podcasts, err := c.podcasts.GetPodcastOrAll(id.Value, isIncludeEpisodes)
|
podcasts, err := c.podcasts.GetPodcastOrAll(id.Value, isIncludeEpisodes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return spec.NewError(70, "failed get podcast(s): %s", err)
|
return spec.NewError(10, "failed get podcast(s): %s", err)
|
||||||
}
|
}
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.Podcasts = &spec.Podcasts{}
|
sub.Podcasts = &spec.Podcasts{}
|
||||||
@@ -36,7 +33,7 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
|
|||||||
count := params.GetOrInt("count", 10)
|
count := params.GetOrInt("count", 10)
|
||||||
episodes, err := c.podcasts.GetNewestPodcastEpisodes(count)
|
episodes, err := c.podcasts.GetNewestPodcastEpisodes(count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return spec.NewError(0, "failed get podcast(s): %s", err)
|
return spec.NewError(10, "failed get podcast(s): %s", err)
|
||||||
}
|
}
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.NewestPodcasts = &spec.NewestPodcasts{}
|
sub.NewestPodcasts = &spec.NewestPodcasts{}
|
||||||
@@ -53,7 +50,7 @@ func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response
|
|||||||
return spec.NewError(10, "please provide a valid podcast episode id")
|
return spec.NewError(10, "please provide a valid podcast episode id")
|
||||||
}
|
}
|
||||||
if err := c.podcasts.DownloadEpisode(id.Value); err != nil {
|
if err := c.podcasts.DownloadEpisode(id.Value); err != nil {
|
||||||
return spec.NewError(0, "failed to download episode: %s", err)
|
return spec.NewError(10, "failed to download episode: %s", err)
|
||||||
}
|
}
|
||||||
return spec.NewResponse()
|
return spec.NewResponse()
|
||||||
}
|
}
|
||||||
@@ -68,10 +65,10 @@ func (c *Controller) ServeCreatePodcastChannel(r *http.Request) *spec.Response {
|
|||||||
fp := gofeed.NewParser()
|
fp := gofeed.NewParser()
|
||||||
feed, err := fp.ParseURL(rssURL)
|
feed, err := fp.ParseURL(rssURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return spec.NewError(0, "failed to parse feed: %s", err)
|
return spec.NewError(10, "failed to parse feed: %s", err)
|
||||||
}
|
}
|
||||||
if _, err = c.podcasts.AddNewPodcast(rssURL, feed); err != nil {
|
if _, err = c.podcasts.AddNewPodcast(rssURL, feed); err != nil {
|
||||||
return spec.NewError(0, "failed to add feed: %s", err)
|
return spec.NewError(10, "failed to add feed: %s", err)
|
||||||
}
|
}
|
||||||
return spec.NewResponse()
|
return spec.NewResponse()
|
||||||
}
|
}
|
||||||
@@ -82,7 +79,7 @@ func (c *Controller) ServeRefreshPodcasts(r *http.Request) *spec.Response {
|
|||||||
return spec.NewError(50, "user not admin")
|
return spec.NewError(50, "user not admin")
|
||||||
}
|
}
|
||||||
if err := c.podcasts.RefreshPodcasts(); err != nil {
|
if err := c.podcasts.RefreshPodcasts(); err != nil {
|
||||||
return spec.NewError(0, "failed to refresh feeds: %s", err)
|
return spec.NewError(10, "failed to refresh feeds: %s", err)
|
||||||
}
|
}
|
||||||
return spec.NewResponse()
|
return spec.NewResponse()
|
||||||
}
|
}
|
||||||
@@ -98,7 +95,7 @@ func (c *Controller) ServeDeletePodcastChannel(r *http.Request) *spec.Response {
|
|||||||
return spec.NewError(10, "please provide a valid podcast id")
|
return spec.NewError(10, "please provide a valid podcast id")
|
||||||
}
|
}
|
||||||
if err := c.podcasts.DeletePodcast(id.Value); err != nil {
|
if err := c.podcasts.DeletePodcast(id.Value); err != nil {
|
||||||
return spec.NewError(70, "failed to delete podcast: %s", err)
|
return spec.NewError(10, "failed to delete podcast: %s", err)
|
||||||
}
|
}
|
||||||
return spec.NewResponse()
|
return spec.NewResponse()
|
||||||
}
|
}
|
||||||
@@ -114,7 +111,7 @@ func (c *Controller) ServeDeletePodcastEpisode(r *http.Request) *spec.Response {
|
|||||||
return spec.NewError(10, "please provide a valid podcast episode id")
|
return spec.NewError(10, "please provide a valid podcast episode id")
|
||||||
}
|
}
|
||||||
if err := c.podcasts.DeletePodcastEpisode(id.Value); err != nil {
|
if err := c.podcasts.DeletePodcastEpisode(id.Value); err != nil {
|
||||||
return spec.NewError(70, "failed to delete podcast: %s", err)
|
return spec.NewError(10, "failed to delete podcast: %s", err)
|
||||||
}
|
}
|
||||||
return spec.NewResponse()
|
return spec.NewResponse()
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
|
|||||||
|
|
||||||
reader, err := coverFor(c.dbc, c.artistInfoCache, c.playlistStore, c.tagReader, id)
|
reader, err := coverFor(c.dbc, c.artistInfoCache, c.playlistStore, c.tagReader, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return spec.NewError(70, "couldn't find cover %q: %v", id, err)
|
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
|
||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
|
|||||||
resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos)
|
resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos)
|
||||||
|
|
||||||
if err := imaging.Save(resized, cachePath); err != nil {
|
if err := imaging.Save(resized, cachePath); err != nil {
|
||||||
return spec.NewError(0, "saving cover %q: %v", id, err)
|
return spec.NewError(10, "saving cover %q: %v", id, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
serve(cachePath)
|
serve(cachePath)
|
||||||
|
|||||||
@@ -6,14 +6,22 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"go.senan.xyz/gonic/db"
|
"go.senan.xyz/gonic/db"
|
||||||
|
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAlbumByFolder(f *db.Album) *Album {
|
func NewAlbumByFolder(f *db.Album) *Album {
|
||||||
|
artist := ""
|
||||||
|
var parentSID *specid.ID
|
||||||
|
if f.Parent != nil {
|
||||||
|
artist = f.Parent.RightPath
|
||||||
|
parentSID = f.ParentSID()
|
||||||
|
}
|
||||||
|
|
||||||
a := &Album{
|
a := &Album{
|
||||||
Artist: f.Parent.RightPath,
|
Artist: artist,
|
||||||
ID: f.SID(),
|
ID: f.SID(),
|
||||||
IsDir: true,
|
IsDir: true,
|
||||||
ParentID: f.ParentSID(),
|
ParentID: parentSID,
|
||||||
Album: f.RightPath,
|
Album: f.RightPath,
|
||||||
Name: f.RightPath,
|
Name: f.RightPath,
|
||||||
Title: f.RightPath,
|
Title: f.RightPath,
|
||||||
@@ -79,13 +87,13 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
|
|||||||
),
|
),
|
||||||
ParentID: parent.SID(),
|
ParentID: parent.SID(),
|
||||||
Duration: t.Length,
|
Duration: t.Length,
|
||||||
|
Year: parent.TagYear,
|
||||||
Bitrate: t.Bitrate,
|
Bitrate: t.Bitrate,
|
||||||
IsDir: false,
|
IsDir: false,
|
||||||
Type: "music",
|
Type: "music",
|
||||||
MusicBrainzID: t.TagBrainzID,
|
MusicBrainzID: t.TagBrainzID,
|
||||||
CreatedAt: t.CreatedAt,
|
CreatedAt: t.CreatedAt,
|
||||||
AverageRating: formatRating(t.AverageRating),
|
AverageRating: formatRating(t.AverageRating),
|
||||||
Year: t.TagYear,
|
|
||||||
}
|
}
|
||||||
if trCh.Title == "" {
|
if trCh.Title == "" {
|
||||||
trCh.Title = t.Filename
|
trCh.Title = t.Filename
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
|
|||||||
DiscNumber: t.TagDiscNumber,
|
DiscNumber: t.TagDiscNumber,
|
||||||
Type: "music",
|
Type: "music",
|
||||||
MusicBrainzID: t.TagBrainzID,
|
MusicBrainzID: t.TagBrainzID,
|
||||||
|
Year: album.TagYear,
|
||||||
AverageRating: formatRating(t.AverageRating),
|
AverageRating: formatRating(t.AverageRating),
|
||||||
TranscodeMeta: TranscodeMeta{},
|
TranscodeMeta: TranscodeMeta{},
|
||||||
Year: t.TagYear,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -442,8 +442,8 @@ type Bookmark struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Starred struct {
|
type Starred struct {
|
||||||
Artists []*Directory `xml:"artist,omitempty" json:"artist,omitempty"`
|
Artists []*Artist `xml:"artist,omitempty" json:"artist,omitempty"`
|
||||||
Albums []*TrackChild `xml:"album,omitempty" json:"album,omitempty"`
|
Albums []*Album `xml:"album,omitempty" json:"album,omitempty"`
|
||||||
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
|
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ type InternetRadioStation struct {
|
|||||||
ID *specid.ID `xml:"id,attr" json:"id"`
|
ID *specid.ID `xml:"id,attr" json:"id"`
|
||||||
Name string `xml:"name,attr" json:"name"`
|
Name string `xml:"name,attr" json:"name"`
|
||||||
StreamURL string `xml:"streamUrl,attr" json:"streamUrl"`
|
StreamURL string `xml:"streamUrl,attr" json:"streamUrl"`
|
||||||
HomepageURL string `xml:"homePageUrl,attr" json:"homePageUrl"`
|
HomepageURL string `xml:"homepageUrl,attr" json:"homepageUrl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Lyrics struct {
|
type Lyrics struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user