19 Commits
Author SHA1 Message Date
sentriz 3964c04419 feat: scan and return track contributors
Release / Lint and test (push) Successful in 3m1s
Release / Run Release Please (push) Failing after 9s
Release / Build, tag, and publish Docker image (push) Has been skipped
Release / Notify IRC (push) Has been skipped
Release / Build binaries (386, linux) (push) Has been skipped
Release / Build binaries (386, windows) (push) Has been skipped
Release / Build binaries (amd64, darwin) (push) Has been skipped
Release / Build binaries (amd64, linux) (push) Has been skipped
Release / Build binaries (amd64, windows) (push) Has been skipped
Release / Build binaries (arm64, darwin) (push) Has been skipped
Release / Build binaries (arm64, linux) (push) Has been skipped
2026-04-23 18:42:29 +01:00
sentriz f55cc3fe43 chore(deps)!: bump to go1.26
Release-As: 0.21.0
2026-04-23 18:42:05 +01:00
sentriz 61124b562c update gitignore 2026-04-21 17:23:09 +01:00
sentriz fd15ea9881 add dependabot.yml 2026-04-21 12:58:09 +01:00
sentriz ec457fb380 fix(lastfm): don't replace cached artist image with empty on refresh
last.fm intermittently omits the og:image meta tag from artist pages.
previously this would overwrite a good cached image URL with empty, leaving artists without
artwork until the next cache cycle
2026-04-14 10:37:46 +01:00
sentriz 5daf95cdeb fix(scanner): reduce sqlite lock contention during scans
closes #678
2026-04-03 13:56:31 +01:00
sentriz 0f98064bca fix(subsonic): return averageRating as float
fixes #677
2026-03-27 15:11:54 +00:00
sentriz bf8469cbf8 feat(subsonic): sort genres alphabetically by default 2026-03-27 14:45:30 +00:00
sentriz dec400022d fix(subsonic): unambiguate all columns 2026-03-27 14:45:30 +00:00
Eric Munson f5eecae4ef feat(docs): add Music Assistant to list of tested applications (#676)
Signed-off-by: Eric B Munson <eric@munsonfam.org>
2026-03-22 12:35:09 +01:00
Eric Munson 192ee10b3f feat(podcast): ensure that any error path out of doPodcastDownload sets status (#672)
Some error paths out of this function are not setting the podcast status
to 'error'. Move the deferred error checking earlier to ensure the
status is set.

Signed-off-by: Eric B Munson <eric@munsonfam.org>
2026-03-11 16:37:53 +00:00
Florian Sorko 9473ec7539 fix(podcast): fix crash if itunes extensions are missing (#668)
I came across this issue when I started to use a custom RSS
generator that works fine for e.g. the Apple Podcasts app
but results in a crash in gonic.

I found these nil pointer dereferences by looking at the stacktraces
only.
No time was spent looking for additional locations were this might need to
be fixed.

The custom generator if that helps
https://gist.github.com/diepfote/59aaf5eb8ea3e2d7bcdd97b8efd2a472
2026-03-10 21:27:35 +00:00
Eric Munson 1b770c95d8 feat(subsonic): make error codes match Open Subsonic spec (#671)
There were a number of error codes being returned that did not match the
the code given by the spec. Primarily this was the use of error code 10
(missing input parameter) when 70 (data not found) was the more
appropriate return. Though several uses of 10 are actually 0 (internal
server or unspecified error).

Signed-off-by: Eric B Munson <eric@munsonfam.org>
2026-03-10 19:56:47 +00:00
sentriz 798e7f875a feat(playlist): use relative paths in m3u playlists
write playlist item paths relative to the playlist file directory, an resolve relative paths back to absolute on read

closes #537
closes #529
2026-03-09 15:26:21 +00:00
sentriz 65c4674da0 fix(scanner): reset batch timer on fsnotify Remove events
fixes #637
2026-03-09 14:57:12 +00:00
sentriz e535e7888c fix(subsonic): update homepage URL casing
closes #664
2026-03-09 14:49:01 +00:00
sentriz ad65a9ab3e update readme
closes #667
2026-03-09 14:46:20 +00:00
Kynn | CherryblueandSenan Kelly 5e916d0f4c feat: support track level year tags (#661)
* [ PR Year @ Track-level ] This resolves issue #549

* Update db/migrations.go

Co-authored-by: Senan Kelly <senan@senan.xyz>

* [ PR #661 ] Fixes proposed by Sentriz (file indentation, simpler call to functions)

* [ PR #661 ] Fix File indentation for construct_by_folder

* [ PR #661 ] Set known tracks year field to their parent (album) year value ; until next deep scan.

* [ PR #661 ] Fix database field names in sql query

* Update db/migrations.go

Co-authored-by: Senan Kelly <senan@senan.xyz>

* Update db/migrations.go

Co-authored-by: Senan Kelly <senan@senan.xyz>

---------

Co-authored-by: Senan Kelly <senan@senan.xyz>
2026-02-24 21:00:11 +01:00
sentriz b2674f8e5a fix(listenbrainz): disable post-quantum TLS to avoid connection reset errors
listenbrainz's server can't handle the larger TLS ClientHello from
Go's post-quantum key exchange (Kyber). Explicitly set classic curve
preferences to avoid "connection reset by peer" errors.

https://github.com/golang/go/issues/70139
2026-02-24 15:50:38 +01:00
41 changed files with 777 additions and 728 deletions

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
version: 2
multi-ecosystem-groups:
all:
schedule:
interval: weekly
updates:
- package-ecosystem: docker
directory: /
multi-ecosystem-group: all
patterns: ["*"]
- package-ecosystem: github-actions
directory: /
multi-ecosystem-group: all
patterns: ["*"]
- package-ecosystem: gomod
directory: /
multi-ecosystem-group: all
patterns: ["*"]
+3 -1
View File
@@ -1,5 +1,4 @@
*.db
*.db.*.bak
*db-wal
*db-shm
*.sql
@@ -13,3 +12,6 @@ dist
*.swp
.tags*
*.test
.env
config
genre-tree
+2 -2
View File
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:1.25-alpine3.22 AS builder
FROM --platform=$BUILDPLATFORM golang:1.26-alpine3.23 AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /src
@@ -12,7 +12,7 @@ RUN \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/ ./cmd/...
FROM alpine:3.22
FROM alpine:3.23
LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic
RUN apk add -U --no-cache \
ffmpeg \
+1 -11
View File
@@ -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
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
- newer salt and token auth
- 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)
- 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), [music-assistant](https://www.music-assistant.io/), [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
@@ -52,7 +52,6 @@ password can then be changed from the web interface
| env var | command line arg | description |
| ----------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `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_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 |
@@ -76,15 +75,6 @@ password can then be changed from the web interface
| `GONIC_TRANSCODE_CACHE_SIZE` | `-transcode-cache-size` | **optional** size of the transcode cache in MB (0 = no limit) |
| `GONIC_TRANSCODE_EJECT_INTERVAL` | `-transcode-eject-interval` | **optional** interval (in minutes) to eject transcode cache (0 = never) |
| `GONIC_EXPVAR` | `-expvar` | **optional** enable the /debug/vars endpoint (exposes useful debugging attributes as well as database stats) |
| `GONIC_LDAP_FQDN` | `-ldap-fqdn` | **optional** the name of the server to connect to (required for LDAP) |
| `GONIC_LDAP_PORT` | `-ldap-port` | **optional** what port the LDAP server is hosted on (_default_ `389`) |
| `GONIC_LDAP_TLS` | `-ldap-tls` | **optional** whether gonic will connect to the LDAP server using TLS (_default_ `false`) |
| `GONIC_LDAP_BASE_DN` | `-ldap-base-dn` | **optional** the base DN for LDAP objects (required for LDAP, escaping the commas might be necessary if using environmental variable) |
| `GONIC_LDAP_USERNAME_ATTR` | `-ldap-username-attr` | **optional** attribute used by the LDAP server for usernames, gets prepended to BaseDN (_default_ `uid`) |
| `GONIC_LDAP_BIND_USER` | `-ldap-bind-user` | **optional** the bind user to bind to LDAP with (required for LDAP) |
| `GONIC_LDAP_BIND_PASS` | `-ldap-bind-pass` | **optional** the password of the LDAP bind user (required for LDAP) |
| `GONIC_LDAP_FILTER` | `-ldap-filter` | **optional** the filter to select LDAP objects with (escaping the commas might be necessary if using environmental variable) |
| `GONIC_LDAP_ADMIN_FILTER` | `-ldap-admin-filter` | **optional** the filter to select LDAP admin objects with (escaping the commas might be necessary if using environmental variable) (_default_ `(memberof=cn=admin)`) |
## multi valued tags (v0.16+)
+2 -24
View File
@@ -39,7 +39,6 @@ import (
"go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/listenbrainz"
"go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/podcast"
@@ -63,7 +62,6 @@ func main() {
var confMusicPaths pathAliases
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")
@@ -85,26 +83,6 @@ func main() {
confExcludePattern := flag.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)")
var ldapConfig ldap.Config
var ldapStore = make(ldap.LDAPStore)
flag.StringVar(&ldapConfig.BindUser, "ldap-bind-user", "", "the bind user to bind to LDAP with (required for LDAP)")
flag.StringVar(&ldapConfig.BindPass, "ldap-bind-pass", "", "the password of the LDAP bind user (required for LDAP)")
flag.StringVar(&ldapConfig.BaseDN, "ldap-base-dn", "", "the base DN for LDAP objects (required for LDAP)")
flag.StringVar(&ldapConfig.UsernameAttr, "ldap-username-attr", "uid", "attribute used by the LDAP server for usernames, gets prepended to BaseDN (optional)")
flag.StringVar(&ldapConfig.Filter, "ldap-filter", "", "the filter to select LDAP objects with (optional)")
flag.StringVar(&ldapConfig.AdminFilter, "ldap-admin-filter", "(memberof=cn=admin)", "the filter to select LDAP objects with (optional)")
flag.StringVar(&ldapConfig.FQDN, "ldap-fqdn", "", "the name of the server to connect to (required for LDAP)")
flag.UintVar(&ldapConfig.Port, "ldap-port", 389, "what port the LDAP server is hosted on (optional)")
flag.BoolVar(&ldapConfig.TLS, "ldap-tls", false, "whether gonic will connect to the LDAP server using TLS (optional)")
if ldapConfig.FQDN != "" {
if ldapConfig.BindUser == "" || ldapConfig.BindPass == "" || ldapConfig.BaseDN == "" {
log.Fatal("a server was provided for an LDAP connection, but configuration is incomplete")
}
}
var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for multi-valued genre scanning (optional)")
flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for multi-valued track artist scanning (optional)")
@@ -274,11 +252,11 @@ func main() {
return url.String()
}
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig, ldapStore)
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath)
if err != nil {
log.Panicf("error creating admin controller: %v\n", err)
}
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *defaultMusicPath, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath, ldapConfig, ldapStore)
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath)
if err != nil {
log.Panicf("error creating subsonic controller: %v\n", err)
}
+46 -11
View File
@@ -54,19 +54,34 @@ func NewMock(opts url.Values) (*DB, error) {
}
func (db *DB) InsertBulkLeftMany(table string, head []string, left int, col []int) error {
if len(col) == 0 {
rows := make([][]any, len(col))
for i, c := range col {
rows[i] = []any{c}
}
return db.InsertBulkLeftManyRows(table, head, left, rows)
}
func (db *DB) InsertBulkLeftManyRows(table string, head []string, left int, rows [][]any) error {
if len(rows) == 0 {
return nil
}
var rows []string
var values []any
for _, c := range col {
rows = append(rows, "(?, ?)")
values = append(values, left, c)
tail := len(head) - 1
placeholder := "(?" + strings.Repeat(", ?", tail) + ")"
placeholders := make([]string, len(rows))
values := make([]any, 0, len(rows)*len(head))
for i, r := range rows {
if len(r) != tail {
return fmt.Errorf("row %d has %d values, expected %d", i, len(r), tail)
}
placeholders[i] = placeholder
values = append(values, left)
values = append(values, r...)
}
q := fmt.Sprintf("INSERT OR IGNORE INTO %q (%s) VALUES %s",
table,
strings.Join(head, ", "),
strings.Join(rows, ", "),
strings.Join(placeholders, ", "),
)
return db.Exec(q, values...).Error
}
@@ -127,15 +142,15 @@ func (db *DB) TransactionChunked(data []int64, cb func(*DB, []int64) error) erro
}
// https://sqlite.org/limits.html
const size = 999
return db.Transaction(func(tx *DB) error {
for i := 0; i < len(data); i += size {
end := min(i+size, len(data))
if err := cb(tx, data[i:end]); err != nil {
if err := db.Transaction(func(tx *DB) error {
return cb(tx, data[i:end])
}); err != nil {
return err
}
}
return nil
})
}
type SettingKey string
@@ -213,6 +228,7 @@ type Track struct {
Album *Album
AlbumID int `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
Artists []*Artist `gorm:"many2many:track_artists"`
Contributors []*TrackContributor `gorm:"foreignkey:track_id"`
Genres []*Genre `gorm:"many2many:track_genres"`
Size int `sql:"default: null"`
Length int `sql:"default: null"`
@@ -224,6 +240,7 @@ type Track struct {
TagDiscNumber int `sql:"default: null"`
TagBrainzID string `sql:"default: null"`
TagLyrics string `sql:"default: null"`
TagYear int `sql:"default: null"`
ReplayGainTrackGain float32
ReplayGainTrackPeak float32
@@ -287,7 +304,7 @@ type User struct {
ID int `gorm:"primary_key"`
CreatedAt time.Time
Name string `gorm:"not null; unique_index" sql:"default: null"`
Password string `sql:"default: null"`
Password string `gorm:"not null" sql:"default: null"`
LastFMSession string `sql:"default: null"`
ListenBrainzURL string `sql:"default: null"`
ListenBrainzToken string `sql:"default: null"`
@@ -403,6 +420,24 @@ type TrackArtist struct {
ArtistID int `gorm:"not null; unique_index:idx_track_id_artist_id" sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
}
type ContributorRole string
const (
ContributorRoleComposer ContributorRole = "composer"
ContributorRoleLyricist ContributorRole = "lyricist"
ContributorRoleRemixer ContributorRole = "remixer"
ContributorRoleConductor ContributorRole = "conductor"
ContributorRoleProducer ContributorRole = "producer"
ContributorRoleArranger ContributorRole = "arranger"
)
type TrackContributor struct {
TrackID int `gorm:"not null; unique_index:idx_track_contributor" sql:"default: null; type:int REFERENCES tracks(id) ON DELETE CASCADE"`
ArtistID int `gorm:"not null; unique_index:idx_track_contributor" sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
Role ContributorRole `gorm:"not null; unique_index:idx_track_contributor" sql:"default: null"`
Artist *Artist
}
type ArtistAppearances struct {
ArtistID int `gorm:"not null; unique_index:idx_artist_id_album_id" sql:"default: null; type:int REFERENCES artists(id) ON DELETE CASCADE"`
AlbumID int `gorm:"not null; unique_index:idx_artist_id_album_id" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
+25
View File
@@ -83,6 +83,8 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
construct(ctx, "202602061800", migrateAddTrackYear),
construct(ctx, "202604231200", migrateAddTrackContributors),
}
return gormigrate.
@@ -879,3 +881,26 @@ func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(AlbumDiscTitle{}).Error
}
func migrateAddTrackContributors(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(TrackContributor{}).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
}
-1
View File
@@ -7,7 +7,6 @@ import (
// Cgo-free Wasm database
_ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
// Cgo-free Wasm tagger
"go.senan.xyz/gonic/tags/taglib"
+14 -16
View File
@@ -1,6 +1,6 @@
module go.senan.xyz/gonic
go 1.25
go 1.26.0
require (
github.com/Masterminds/sprig v2.22.0+incompatible
@@ -13,18 +13,17 @@ require (
github.com/env25/mpdlrc v0.7.4
github.com/fatih/structs v1.1.0
github.com/fsnotify/fsnotify v1.9.0
github.com/go-ldap/ldap/v3 v3.4.6
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0
github.com/gorilla/securecookie v1.1.2
github.com/gorilla/sessions v1.4.0
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
github.com/josephburnett/jd v1.9.2
github.com/mattn/go-sqlite3 v1.14.33
github.com/mattn/go-sqlite3 v1.14.42
github.com/microcosm-cc/bluemonday v1.0.27
github.com/mitchellh/mapstructure v1.5.0
github.com/mmcdole/gofeed v1.3.0
github.com/ncruces/go-sqlite3 v0.30.4
github.com/ncruces/go-sqlite3 v0.33.3
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
@@ -32,22 +31,20 @@ require (
github.com/stretchr/testify v1.11.1
go.senan.xyz/flagconf v0.1.11
go.senan.xyz/taglib v0.11.1
go.senan.xyz/wrtag v0.20.0
golang.org/x/net v0.49.0
golang.org/x/sync v0.19.0
go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb
golang.org/x/net v0.53.0
golang.org/x/sync v0.20.0
gopkg.in/gormigrate.v1 v1.6.0
)
require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/PuerkitoBio/goquery v1.11.0 // indirect
github.com/PuerkitoBio/goquery v1.12.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-openapi/jsonpointer v0.23.1 // indirect
github.com/go-openapi/swag/jsonname v0.26.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
@@ -62,13 +59,14 @@ require (
github.com/mmcdole/goxpp v1.1.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0 // indirect
github.com/ncruces/julianday v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tetratelabs/wazero v1.11.0 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/image v0.35.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/image v0.39.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.36.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
+30 -40
View File
@@ -1,6 +1,4 @@
cloud.google.com/go v0.33.1/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
@@ -8,10 +6,8 @@ github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.11.0 h1:jZ7pwMQXIITcUXNH83LLk+txlaEy6NVOfTuP43xxfqw=
github.com/PuerkitoBio/goquery v1.11.0/go.mod h1:wQHgxUOU3JGuj3oD/QFfxUdlzW6xPHfqyHre6VMY4DQ=
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo=
github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
@@ -41,16 +37,12 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4=
github.com/go-openapi/jsonpointer v0.23.1/go.mod h1:iWRmZTrGn7XwYhtPt/fvdSFj1OfNBngqRT2UG3BxSqY=
github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w=
github.com/go-openapi/swag/jsonname v0.26.0/go.mod h1:urBBR8bZNoDYGr653ynhIx+gTeIz0ARZxHkAPktJK2M=
github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLuq0ePx4=
github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@@ -65,7 +57,6 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
@@ -112,8 +103,8 @@ github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0=
github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo=
github.com/mattn/go-sqlite3 v1.14.42/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -131,8 +122,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ncruces/go-sqlite3 v0.30.4 h1:j9hEoOL7f9ZoXl8uqXVniaq1VNwlWAXihZbTvhqPPjA=
github.com/ncruces/go-sqlite3 v0.30.4/go.mod h1:7WR20VSC5IZusKhUdiR9y1NsUqnZgqIYCmKKoMEYg68=
github.com/ncruces/go-sqlite3 v0.33.3 h1:6jCR3KuGvJSEwhaQrkHDGeIe2qCQ6nOUDNsPz7ZIotw=
github.com/ncruces/go-sqlite3 v0.33.3/go.mod h1:t2Osfw0wcKzJTgv2EvrkTtVLqlbKTA5Yvwb2ypAlBcY=
github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0 h1:ymE9H30x1AyW5VfMNkJC9teuI2W1jjMsQS7kc6zl6Tg=
github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0/go.mod h1:/H3+JykPsfSlvKbOxNSx9kKwm3ecqQGzyCs1e9KkNsU=
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@@ -150,11 +143,8 @@ github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 h1:sLILANWN76ja66/K4k/mBqJuCjDZaM67w+Ru6rEB0s0=
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
@@ -164,8 +154,8 @@ go.senan.xyz/flagconf v0.1.11 h1:ApA9DpoSrfVQlLt8spKJC3fOT7oTEZ2/MmBGMnb9mt4=
go.senan.xyz/flagconf v0.1.11/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
go.senan.xyz/taglib v0.11.1 h1:S3mO5e3HRRG0Ehw1jLUodYbAJK8TtqdOoNgqkC0D3uU=
go.senan.xyz/taglib v0.11.1/go.mod h1:qyTl978MnGeZ/ny4d/t0ErLXxysA+39X4+SNSCk56Zs=
go.senan.xyz/wrtag v0.20.0 h1:Q57ITuEl3TuRuOIkerCL+y4O3WrCqC1lUrewHtluUjc=
go.senan.xyz/wrtag v0.20.0/go.mod h1:1h39mVCOu6mqeQGYVToCvMhegBRCpOt6FO7g69EvuSM=
go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb h1:hFxxWH6MlgcHZQv2BpkQ1KSp8MSbXMHtN338/HfSzdY=
go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb/go.mod h1:sWPfwc3FM2O9Ka/l46vDp+/XwLCgywukxgfZipaWrKw=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -175,11 +165,11 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I=
golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk=
golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww=
golang.org/x/image v0.39.0/go.mod h1:sIbmppfU+xFLPIG0FoVUTvyBMmgng1/XAMhQ2ft0hpA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@@ -199,8 +189,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -208,8 +198,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -224,8 +214,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -244,16 +234,16 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+2 -1
View File
@@ -80,8 +80,9 @@ func (a *ArtistInfoCache) Lookup(ctx context.Context, artist *db.Artist) (*db.Ar
}
artistInfo.SetSimilarArtists(similar)
url, _ := a.lastfmClient.StealArtistImage(info.URL)
if url, _ := a.lastfmClient.StealArtistImage(info.URL); url != "" {
artistInfo.ImageURL = url
}
topTracksResponse, err := a.lastfmClient.ArtistGetTopTracks(artist.Name)
if err != nil {
+9 -5
View File
@@ -10,6 +10,7 @@ import (
"net/url"
"sort"
"strconv"
"strings"
"time"
"github.com/andybalholm/cascadia"
@@ -203,6 +204,9 @@ func (c *Client) StealArtistImage(artistURL string) (string, error) {
return "", fmt.Errorf("get artist url: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode/100 != 2 {
return "", fmt.Errorf("get artist url: %s", resp.Status)
}
node, err := html.Parse(resp.Body)
if err != nil {
@@ -340,12 +344,12 @@ func GetParamSignature(params url.Values, secret string) string {
paramKeys = append(paramKeys, k)
}
sort.Strings(paramKeys)
toHash := ""
var toHash strings.Builder
for _, k := range paramKeys {
toHash += k
toHash += params[k][0]
toHash.WriteString(k)
toHash.WriteString(params[k][0])
}
toHash += secret
hash := md5.Sum([]byte(toHash))
toHash.WriteString(secret)
hash := md5.Sum([]byte(toHash.String()))
return hex.EncodeToString(hash[:])
}
-225
View File
@@ -1,225 +0,0 @@
package ldap
import (
"errors"
"fmt"
"log"
"time"
"go.senan.xyz/gonic/db"
"github.com/go-ldap/ldap/v3"
)
// LDAPStore maps users to a cached password
type LDAPStore map[string]CachedLDAPpassword
// Add caches a password username set.
func (store LDAPStore) Add(username, password string) {
store[username] = CachedLDAPpassword{
Password: password,
ExpiresAt: time.Now().Add(time.Hour * 8), // Keep the password valid for 8 hours.
}
}
// IsValid checks if a user's password is stored in the cache and checks if a
// given password is valid.
func (store LDAPStore) IsValid(username, password string) bool {
cached, ok := store[username]
if !ok {
return false
}
if cached.Password != password {
return false
}
return cached.IsValid()
}
// CachedLDAPpassword stores an LDAP user's password and a time at which the
// server should no longer accept it.
type CachedLDAPpassword struct {
Password string
ExpiresAt time.Time
}
func (password CachedLDAPpassword) IsValid() bool {
return password.ExpiresAt.After(time.Now())
}
// Cofig stores the user's LDAP server options.
type Config struct {
BindUser string
BindPass string
BaseDN string
UsernameAttr string
Filter string
AdminFilter string
FQDN string
Port uint
TLS bool
}
func (c Config) IsSetup() bool {
// This is basically checking if LDAP is setup, if ldapFQDN isn't set we can
// assume that the user hasn't configured LDAP.
return c.FQDN != ""
}
func CheckLDAPcreds(username string, password string, dbc *db.DB, config Config, store LDAPStore) (bool, error) {
if !config.IsSetup() {
return false, nil
}
if store.IsValid(username, password) {
log.Println("Password authenticated via cache!")
return true, nil
}
log.Println("Checking password against LDAP server ...")
// Now, we can try to connect to the LDAP server.
l, err := createLDAPconnection(config)
if err != nil {
// Return a generic error.
log.Println("Failed to connect to LDAP server:", err)
return false, errors.New("failed to connect to LDAP server")
}
defer l.Close()
// Create the user if it doesn't exist on the database already.
err = createUserFromLDAP(username, dbc, config, l)
if err != nil {
log.Println("Failed to create user from LDAP:", err)
return false, err
}
// After we have a connection, let's try binding
_, err = l.SimpleBind(&ldap.SimpleBindRequest{
Username: fmt.Sprintf("%s=%s,%s", config.UsernameAttr, username, config.BaseDN),
Password: password,
})
if err == nil {
// Authentication was OK
store.Add(username, password)
return true, nil
}
log.Println("Failed to bind to LDAP server:", err)
return false, nil
}
// Creates a user from creds
func createUserFromLDAP(username string, dbc *db.DB, config Config, l *ldap.Conn) error {
user := dbc.GetUserByName(username)
if user != nil {
return nil
}
if !config.IsSetup() {
return nil
}
isAdmin := doesLDAPAdminExist(username, config, l)
log.Println(username, isAdmin)
if !doesLDAPUserExist(username, config, l) {
return errors.New("no such user")
}
newUser := db.User{
Name: username,
Password: "", // no password because we want auth to fail.
IsAdmin: isAdmin,
}
err := dbc.Create(&newUser).Error
if err != nil {
return err
}
log.Println("User created via LDAP:", username)
return nil
}
// doesLDAPAdminExist checks if an admin exists on the server.
func doesLDAPAdminExist(username string, config Config, l *ldap.Conn) bool {
filter := fmt.Sprintf("(&(%s=%s)%s)", config.UsernameAttr, ldap.EscapeFilter(username), config.AdminFilter)
searchReq := ldap.NewSearchRequest(
config.BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
filter,
[]string{"dn"},
nil,
)
result, err := l.Search(searchReq)
if err != nil {
log.Println("failed to query LDAP server:", err)
return false
}
if len(result.Entries) == 1 {
return true
}
return false
}
// doesLDAPUserExist checks if a user exists on the server.
func doesLDAPUserExist(username string, config Config, l *ldap.Conn) bool {
filter := fmt.Sprintf("(&(%s=%s)%s)", config.UsernameAttr, ldap.EscapeFilter(username), config.Filter)
searchReq := ldap.NewSearchRequest(
config.BaseDN,
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
filter,
[]string{"dn"},
nil,
)
result, err := l.Search(searchReq)
if err != nil {
log.Println("failed to query LDAP server:", err)
return false
}
if len(result.Entries) == 1 {
return true
}
return false
}
// Creates a connection to an LDAP server.
func createLDAPconnection(config Config) (*ldap.Conn, error) {
protocol := "ldap"
if config.TLS {
protocol = "ldaps"
}
// Now, we can try to connect to the LDAP server.
l, err := ldap.DialURL(fmt.Sprintf("%s://%s:%d", protocol, config.FQDN, config.Port))
if err != nil {
// Warn the server and return the error.
log.Println("Failed to connect to LDAP server", err)
return nil, err
}
// After we have a connection, let's try binding
_, err = l.SimpleBind(&ldap.SimpleBindRequest{
Username: fmt.Sprintf("%s=%s,%s", config.UsernameAttr, config.BindUser, config.BaseDN),
Password: config.BindPass,
})
if err != nil {
log.Println("Failed to bind to LDAP:", err)
return nil, errors.New("wrong username or password")
}
return l, nil
}
+12 -1
View File
@@ -2,6 +2,7 @@ package listenbrainz
import (
"bytes"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
@@ -30,7 +31,17 @@ type Client struct {
}
func NewClient() *Client {
return NewClientCustom(http.DefaultClient)
// disable post-quantum key exchange (Kyber) to avoid "connection reset by peer" errors.
// 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 {
+6
View File
@@ -134,6 +134,9 @@ func (s *Store) Read(relPath string) (*Playlist, error) {
if strings.HasPrefix(line, "#") {
continue
}
if !filepath.IsAbs(line) {
line = filepath.Join(filepath.Dir(absPath), line)
}
playlist.Items = append(playlist.Items, line)
}
@@ -186,6 +189,9 @@ func (s *Store) Write(relPath string, playlist *Playlist) error {
fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment))
fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic)))
for _, line := range playlist.Items {
if rel, err := filepath.Rel(filepath.Dir(absPath), line); err == nil {
line = rel
}
fmt.Fprintln(file, line)
}
+3 -3
View File
@@ -32,9 +32,9 @@ Example comment
It has multiple lines 👍
`,
Items: []string{
"item 1.flac",
"item 2.flac",
"item 3.flac",
"/music/item 1.flac",
"/music/item 2.flac",
"/music/item 3.flac",
},
IsPublic: true,
}
+17 -9
View File
@@ -81,13 +81,17 @@ func (p *Podcasts) AddNewPodcast(rssURL string, feed *gofeed.Feed) (*db.Podcast,
if err != nil {
return nil, fmt.Errorf("find unique podcast dir: %w", err)
}
var author string
if feed.ITunesExt != nil {
author = feed.ITunesExt.Author
}
podcast := db.Podcast{
Description: feed.Description,
ImageURL: "",
Title: feed.Title,
URL: rssURL,
RootDir: rootDir,
Author: feed.ITunesExt.Author,
Author: author,
}
if feed.Image != nil {
podcast.ImageURL = feed.Image.URL
@@ -226,6 +230,10 @@ func (p *Podcasts) isAudio(rawItemURL string) (bool, error) {
}
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{
PodcastID: podcast.ID,
Description: item.Description,
@@ -235,7 +243,7 @@ func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *
PublishDate: item.PublishedParsed,
AudioURL: audio,
Status: db.PodcastEpisodeStatusSkipped,
Artist: cmp.Or(item.ITunesExt.Author, podcast.Author),
Artist: cmp.Or(author),
Album: podcast.Title,
}
}
@@ -508,6 +516,13 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
}
defer resp.Body.Close()
defer func() {
if err != nil {
podcastEpisode.Status = db.PodcastEpisodeStatusError
_ = p.db.Save(podcastEpisode).Error
}
}()
if resp.StatusCode/100 != 2 {
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
}
@@ -529,13 +544,6 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
}
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 {
return fmt.Errorf("writing podcast episode: %w", err)
}
+65 -5
View File
@@ -188,6 +188,7 @@ func (s *Scanner) ExecuteWatch(ctx context.Context) error {
case event := <-watcher.Events:
if event.Op&(fsnotify.Remove) == fsnotify.Remove {
batchClean = true
batchT.Reset(batchInterval)
break
}
if event.Op&(fsnotify.Create|fsnotify.Write) == 0 {
@@ -371,20 +372,30 @@ func (s *Scanner) scanDir(st *State, absPath string) error {
return nil
}
return s.db.Transaction(func(tx *db.DB) error {
var discTitles = map[int]string{}
// read tags outside the transaction to avoid holding db locks during disk i/o
type trackTagData struct {
trackUpdate
trprops tags.Properties
trags tags.Tags
}
tagData := make([]trackTagData, 0, len(trackUpdates))
for _, t := range trackUpdates {
trprops, trags, err := s.tagReader.Read(t.absPath)
if err != nil {
return fmt.Errorf("read %q: %w: %w", t.basename, err, ErrReadingTags)
}
tagData = append(tagData, trackTagData{trackUpdate: t, trprops: trprops, trags: trags})
}
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, trprops, trags, t.basename, t.absPath); err != nil {
return s.db.Transaction(func(tx *db.DB) error {
var discTitles = map[int]string{}
for _, t := range tagData {
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, t.trprops, t.trags, t.basename, t.absPath); err != nil {
return fmt.Errorf("populate track %q: %w", t.basename, err)
}
discNum := cmp.Or(tags.ParseInt(normtag.Get(trags, normtag.DiscNumber)), 1)
discSubtitle := normtag.Get(trags, "DISCSUBTITLE")
discNum := cmp.Or(tags.ParseInt(normtag.Get(t.trags, normtag.DiscNumber)), 1)
discSubtitle := normtag.Get(t.trags, "DISCSUBTITLE")
if _, exists := discTitles[discNum]; !exists && discSubtitle != "" {
discTitles[discNum] = discSubtitle
@@ -474,6 +485,14 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
return fmt.Errorf("populate track artists: %w", err)
}
contributorIDs, err := populateTrackContributors(tx, track, trags)
if err != nil {
return fmt.Errorf("populate track contributors: %w", err)
}
if err := populateArtistAppearances(tx, album, contributorIDs); err != nil {
return fmt.Errorf("populate contributor appearances: %w", err)
}
// possible album level embedded covers come only from the first track
if i == 0 {
if err := populateAlbumEmbeddedCover(tx, s.scanEmbeddedCover, album, track, trprops); err != nil {
@@ -569,6 +588,7 @@ func populateTrack(tx *db.DB, scanEmbeddedCover bool, album *db.Album, track *db
track.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
track.TagYear = tags.MustYear(trags)
track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
@@ -674,6 +694,46 @@ func populateAlbumArtists(tx *db.DB, album *db.Album, albumArtistIDs []int) erro
return nil
}
//nolint:gochecknoglobals
var contributorTagKeys = []struct {
keys []string
role db.ContributorRole
}{
{[]string{normtag.Remixers, normtag.Remixer}, db.ContributorRoleRemixer},
{[]string{normtag.Composers, normtag.Composer}, db.ContributorRoleComposer},
{[]string{normtag.Lyricists, normtag.Lyricist}, db.ContributorRoleLyricist},
{[]string{normtag.Conductors, normtag.Conductor}, db.ContributorRoleConductor},
{[]string{normtag.Producers, normtag.Producer}, db.ContributorRoleProducer},
{[]string{normtag.Arrangers, normtag.Arranger}, db.ContributorRoleArranger},
}
func populateTrackContributors(tx *db.DB, track *db.Track, trags tags.Tags) ([]int, error) {
if err := tx.Where("track_id=?", track.ID).Delete(db.TrackContributor{}).Error; err != nil {
return nil, fmt.Errorf("delete old track contributors: %w", err)
}
var rows [][]any
var artistIDs []int
for _, rk := range contributorTagKeys {
for _, name := range tags.FirstValues(trags, rk.keys...) {
if name == "" {
continue
}
artist, err := populateArtist(tx, name)
if err != nil {
return nil, fmt.Errorf("populate contributor artist: %w", err)
}
rows = append(rows, []any{artist.ID, string(rk.role)})
artistIDs = append(artistIDs, artist.ID)
}
}
if err := tx.InsertBulkLeftManyRows("track_contributors", []string{"track_id", "artist_id", "role"}, track.ID, rows); err != nil {
return nil, fmt.Errorf("insert bulk track contributors: %w", err)
}
return artistIDs, nil
}
func populateTrackArtists(tx *db.DB, track *db.Track, trackArtistIDs []int) error {
if err := tx.Where("track_id=?", track.ID).Delete(db.TrackArtist{}).Error; err != nil {
return fmt.Errorf("delete old track artists: %w", err)
+1 -1
View File
@@ -26,7 +26,7 @@ func FuzzScanner(f *testing.F) {
m := mockfs.New(t)
const toAdd = 1000
for i := 0; i < toAdd; i++ {
for i := range toAdd {
path := fmt.Sprintf("artist-%d/album-%d/track-%d.flac", i/6, i/3, i)
m.AddTrack(path)
m.SetTags(path, func(tags *mockfs.TagInfo) {
+68
View File
@@ -461,6 +461,74 @@ func TestMultiFolderWithSharedArtist(t *testing.T) {
}
}
func TestTrackContributors(t *testing.T) {
t.Parallel()
m := mockfs.New(t)
m.AddTrack("artist-a/album-a/track-1.flac")
m.SetTags("artist-a/album-a/track-1.flac", func(tags *mockfs.TagInfo) {
normtag.Set(tags.Tags, normtag.Artist, "artist-a")
normtag.Set(tags.Tags, normtag.AlbumArtist, "artist-a")
normtag.Set(tags.Tags, normtag.Album, "album-a")
normtag.Set(tags.Tags, normtag.Title, "track-1")
normtag.Set(tags.Tags, normtag.Composers, "comp-a", "comp-b")
normtag.Set(tags.Tags, normtag.Remixer, "rem-a")
normtag.Set(tags.Tags, "LYRICIST", "lyr-a")
normtag.Set(tags.Tags, "PRODUCER", "prod-a")
})
m.ScanAndClean()
var track db.Track
require.NoError(t, m.DB().Preload("Contributors.Artist").Where("tag_title=?", "track-1").First(&track).Error)
type pair struct {
Role db.ContributorRole
Artist string
}
var got []pair
for _, c := range track.Contributors {
got = append(got, pair{Role: c.Role, Artist: c.Artist.Name})
}
assert.ElementsMatch(t, []pair{
{db.ContributorRoleComposer, "comp-a"},
{db.ContributorRoleComposer, "comp-b"},
{db.ContributorRoleRemixer, "rem-a"},
{db.ContributorRoleLyricist, "lyr-a"},
{db.ContributorRoleProducer, "prod-a"},
}, got)
// contributor artists should also show up on the album via artist_appearances
for _, name := range []string{"comp-a", "comp-b", "rem-a", "lyr-a", "prod-a"} {
var count int
require.NoError(t, m.DB().
Model(&db.ArtistAppearances{}).
Joins("JOIN artists ON artists.id=artist_appearances.artist_id").
Where("artists.name=?", name).
Count(&count).Error)
assert.Equal(t, 1, count, "expected %q in artist_appearances", name)
}
// re-scanning with a changed composer list should clear the stale row (comp-b)
// and add the new one (comp-c). other roles stay since their tags didn't change.
m.SetTags("artist-a/album-a/track-1.flac", func(tags *mockfs.TagInfo) {
normtag.Set(tags.Tags, normtag.Composers, "comp-a", "comp-c")
})
m.ScanAndClean()
require.NoError(t, m.DB().Preload("Contributors.Artist").Where("tag_title=?", "track-1").First(&track).Error)
got = got[:0]
for _, c := range track.Contributors {
got = append(got, pair{Role: c.Role, Artist: c.Artist.Name})
}
assert.ElementsMatch(t, []pair{
{db.ContributorRoleComposer, "comp-a"},
{db.ContributorRoleComposer, "comp-c"},
{db.ContributorRoleRemixer, "rem-a"},
{db.ContributorRoleLyricist, "lyr-a"},
{db.ContributorRoleProducer, "prod-a"},
}, got)
}
func TestSymlinkedAlbum(t *testing.T) {
t.Parallel()
m := mockfs.NewWithDirs(t, []string{"scan"})
+1 -6
View File
@@ -27,7 +27,6 @@ import (
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/handlerutil"
"go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/podcast"
"go.senan.xyz/gonic/scanner"
"go.senan.xyz/gonic/server/ctrladmin/adminui"
@@ -49,13 +48,11 @@ type Controller struct {
podcasts *podcast.Podcasts
lastfmClient *lastfm.Client
resolveProxyPath ProxyPathResolver
ldapConfig ldap.Config
ldapStore ldap.LDAPStore
}
type ProxyPathResolver func(in string) string
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config, ldapStore ldap.LDAPStore) (*Controller, error) {
func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts *podcast.Podcasts, lastfmClient *lastfm.Client, resolveProxyPath ProxyPathResolver) (*Controller, error) {
c := Controller{
ServeMux: http.NewServeMux(),
@@ -65,8 +62,6 @@ func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts
podcasts: podcasts,
lastfmClient: lastfmClient,
resolveProxyPath: resolveProxyPath,
ldapConfig: ldapConfig,
ldapStore: ldapStore,
}
resp := respHandler(adminui.TemplatesFS, resolveProxyPath)
+2 -22
View File
@@ -1,48 +1,28 @@
package ctrladmin
import (
"log"
"net/http"
"github.com/gorilla/sessions"
"go.senan.xyz/gonic/ldap"
)
func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
session := r.Context().Value(CtxSession).(*sessions.Session)
username := r.FormValue("username")
password := r.FormValue("password")
user := c.dbc.GetUserByName(username)
if username == "" || password == "" {
sessAddFlashW(session, []string{"please provide username and password"})
sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return
}
if c.ldapConfig.IsSetup() {
ok, err := ldap.CheckLDAPcreds(username, password, c.dbc, c.ldapConfig, c.ldapStore)
if err != nil {
log.Println("Failed to check LDAP credentials:", err)
sessAddFlashW(session, []string{"failed to check LDAP credentials"})
sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return
} else if !ok {
user := c.dbc.GetUserByName(username)
if user == nil || password != user.Password {
sessAddFlashW(session, []string{"invalid username / password"})
sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return
}
} else if user == nil || user.Password != password {
sessAddFlashW(session, []string{"invalid username / password"})
sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return
}
user = c.dbc.GetUserByName(username)
// put the user name into the session. future endpoints after this one
// are wrapped with WithUserSession() which will get the name from the
// session and put the row into the request context
+7 -54
View File
@@ -10,7 +10,6 @@ import (
"io"
"log"
"net/http"
"strings"
"time"
"go.senan.xyz/gonic/db"
@@ -19,7 +18,6 @@ import (
"go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/podcast"
"go.senan.xyz/gonic/scanner"
@@ -58,7 +56,6 @@ type Controller struct {
dbc *db.DB
scanner *scanner.Scanner
musicPaths []MusicPath
defaultMusicPath string
podcastsPath string
cacheAudioPath string
cacheCoverPath string
@@ -75,14 +72,13 @@ type Controller struct {
resolveProxyPath ProxyPathResolver
}
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, ldapConfig ldap.Config, ldapStore ldap.LDAPStore) (*Controller, error) {
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) {
c := Controller{
ServeMux: http.NewServeMux(),
dbc: dbc,
scanner: scannr,
musicPaths: musicPaths,
defaultMusicPath: defaultMusicPath,
podcastsPath: podcastsPath,
cacheAudioPath: cacheAudioPath,
cacheCoverPath: cacheCoverPath,
@@ -102,7 +98,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, defaultMus
chain := handlerutil.Chain(
withParams,
withRequiredParams,
withUser(dbc, ldapConfig, ldapStore),
withUser(dbc),
)
chainRaw := handlerutil.Chain(
chain,
@@ -233,82 +229,39 @@ func withRequiredParams(next http.Handler) http.Handler {
})
}
func withUser(dbc *db.DB, ldapConfig ldap.Config, ldapStore ldap.LDAPStore) handlerutil.Middleware {
func withUser(dbc *db.DB) handlerutil.Middleware {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
params := r.Context().Value(CtxParams).(params.Params)
// ignoring errors here, a middleware has already ensured they exist
username, _ := params.Get("u")
passwordHex, _ := params.Get("p")
password, _ := params.Get("p")
token, _ := params.Get("t")
salt, _ := params.Get("s")
passwordAuth := token == "" && salt == ""
tokenAuth := passwordHex == ""
tokenAuth := password == ""
if tokenAuth == passwordAuth {
_ = writeResp(w, r, spec.NewError(10,
"please provide `t` and `s`, or just `p`"))
return
}
var password string
if passwordAuth && passwordHex != "" {
if strings.HasPrefix(passwordHex, "enc:") {
raw := strings.TrimPrefix(passwordHex, "enc:")
decoded, err := hex.DecodeString(raw)
if err != nil {
log.Println("Failed to decode hex password:", err)
_ = writeResp(w, r, spec.NewError(40, "invalid password encoding"))
return
}
password = string(decoded)
} else {
// if not prefixed with "enc:", treat as plain text
password = passwordHex
}
}
user := dbc.GetUserByName(username)
if ldapConfig.IsSetup() {
// Complete auth using LDAP
log.Println("Authenticating using LDAP ...")
ok, err := ldap.CheckLDAPcreds(username, password, dbc, ldapConfig, ldapStore)
if err != nil {
log.Println("Failed to check LDAP creds:", err)
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
return
}
if !ok {
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
return
}
withUser := context.WithValue(r.Context(), CtxUser, user)
next.ServeHTTP(w, r.WithContext(withUser))
return
}
log.Println("Authenticating using built-in ...")
if user == nil {
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
_ = writeResp(w, r, spec.NewError(40,
"invalid username %q", username))
return
}
var credsOk bool
if tokenAuth {
credsOk = checkCredsToken(user.Password, token, salt)
} else {
credsOk = checkCredsBasic(user.Password, password)
}
if !credsOk {
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
return
}
withUser := context.WithValue(r.Context(), CtxUser, user)
next.ServeHTTP(w, r.WithContext(withUser))
})
+1
View File
@@ -44,6 +44,7 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Find(&track, "id=?", bookmark.EntryID).
Error
if err != nil {
+8 -8
View File
@@ -25,7 +25,7 @@ func (c *Controller) ServeGetIndexes(r *http.Request) *spec.Response {
Select("id").
Model(&db.Album{}).
Where("parent_id IS NULL")
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
rootQ = rootQ.
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)
}
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("root_dir=?", m)
}
var folders []*db.Album
@@ -220,7 +220,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
Select("id").
Model(&db.Album{}).
Where("parent_id IS NULL")
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); 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).
Offset(params.GetOrInt("albumOffset", 0)).
Limit(params.GetOrInt("albumCount", 20))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("root_dir=?", m)
}
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).
Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.
Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m)
@@ -324,7 +324,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Select("id").
Model(&db.Album{}).
Where("parent_id IS NULL")
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
rootQ = rootQ.Where("root_dir=?", m)
}
@@ -350,7 +350,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Where("album_stars.user_id=?", user.ID).
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("root_dir=?", m)
}
if err := q.Find(&albums).Error; err != nil {
@@ -369,7 +369,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.
Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m)
+24 -15
View File
@@ -33,7 +33,7 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
Preload("Info").
Group("artists.id").
Order("artists.name COLLATE NOCASE")
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.
Joins("JOIN albums ON albums.id=album_artists.album_id").
Where("albums.root_dir=?", m)
@@ -113,6 +113,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
return db.
Order("tracks.tag_disc_number, tracks.tag_track_number").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID)
}).
@@ -154,24 +155,24 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
q = q.Joins("JOIN artists ON artists.id=album_artists.artist_id")
q = q.Order("artists.name")
case "alphabeticalByName":
q = q.Order("tag_title")
q = q.Order("albums.tag_title")
case "byYear":
y1, y2 := params.GetOrInt("fromYear", 1800),
params.GetOrInt("toYear", 2200)
// support some clients sending wrong order like DSub
q = q.Where("tag_year BETWEEN ? AND ?", min(y1, y2), max(y1, y2))
q = q.Order("tag_year DESC")
q = q.Where("albums.tag_year BETWEEN ? AND ?", min(y1, y2), max(y1, y2))
q = q.Order("albums.tag_year DESC")
case "byGenre":
genre, _ := params.Get("genre")
q = q.Joins("JOIN album_genres ON album_genres.album_id=albums.id")
q = q.Joins("JOIN genres ON genres.id=album_genres.genre_id AND genres.name=?", genre)
q = q.Order("tag_title")
q = q.Order("albums.tag_title")
case "frequent":
user := r.Context().Value(CtxUser).(*db.User)
q = q.Joins("JOIN plays ON albums.id=plays.album_id AND plays.user_id=?", user.ID)
q = q.Order("plays.length DESC")
case "newest":
q = q.Order("created_at DESC")
q = q.Order("albums.created_at DESC")
case "random":
q = q.Order(gorm.Expr("random()"))
case "recent":
@@ -179,14 +180,14 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
q = q.Order("plays.time DESC")
case "starred":
q = q.Joins("JOIN album_stars ON albums.id=album_stars.album_id AND album_stars.user_id=?", user.ID)
q = q.Order("tag_title")
q = q.Order("albums.tag_title")
case "highest":
q = q.Joins("JOIN album_ratings ON album_ratings.album_id=albums.id AND album_ratings.user_id=?", user.ID)
q = q.Order("album_ratings.rating DESC")
default:
return spec.NewError(10, "unknown value %q for parameter 'type'", listType)
}
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("root_dir=?", m)
}
var albums []*db.Album
@@ -254,7 +255,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("Info").
Offset(params.GetOrInt("artistOffset", 0)).
Limit(params.GetOrInt("artistCount", 20))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("albums.root_dir=?", m)
}
if err := q.Find(&artists).Error; err != nil {
@@ -283,7 +284,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
q = q.
Offset(params.GetOrInt("albumOffset", 0)).
Limit(params.GetOrInt("albumCount", 20))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("root_dir=?", m)
}
if err := q.Find(&albums).Error; err != nil {
@@ -300,6 +301,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("Album.Artists").
Preload("Genres").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID)
switch {
@@ -311,7 +313,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
}
q = q.Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.
Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m)
@@ -452,6 +454,7 @@ func (c *Controller) ServeGetGenres(_ *http.Request) *spec.Response {
(SELECT count(1) FROM album_genres WHERE genre_id=genres.id) album_count,
(SELECT count(1) FROM track_genres WHERE genre_id=genres.id) track_count`).
Group("genres.id").
Order("genres.name").
Find(&genres)
sub := spec.NewResponse()
sub.Genres = &spec.Genres{
@@ -478,11 +481,12 @@ func (c *Controller) ServeGetSongsByGenre(r *http.Request) *spec.Response {
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Offset(params.GetOrInt("offset", 0)).
Limit(params.GetOrInt("count", 10))
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("albums.root_dir=?", m)
}
q = q.Group("tracks.id")
@@ -523,7 +527,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Preload("ArtistRating", "user_id=?", user.ID).
Preload("Info").
Group("artists.id")
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("albums.root_dir=?", m)
}
if err := q.Find(&artists).Error; err != nil {
@@ -544,7 +548,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("albums.root_dir=?", m)
}
if err := q.Find(&albums).Error; err != nil {
@@ -563,9 +567,10 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.
Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m)
@@ -636,6 +641,7 @@ func (c *Controller) ServeGetTopSongs(r *http.Request) *spec.Response {
Where("artists.id=?", artist.ID).
Preload("Album").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Group("tracks.id").
@@ -745,6 +751,7 @@ func getSimilarSongsFromTrack(c *Controller, id specid.ID, params params.Params,
Select("tracks.*").
Preload("Album").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames).
@@ -798,6 +805,7 @@ func getSimilarSongsFromArtist(c *Controller, id specid.ID, params params.Params
err = c.dbc.
Preload("Album").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Joins("JOIN track_artists ON track_artists.track_id=tracks.id").
@@ -866,6 +874,7 @@ func getSimilarSongsFromAlbum(c *Controller, id specid.ID, params params.Params,
Select("tracks.*").
Preload("Album").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames).
+7 -6
View File
@@ -100,7 +100,7 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
return spec.NewError(0, "error updating stats: %v", err)
}
default:
return spec.NewError(10, "can't scrobble type %s", id.Type)
return spec.NewError(0, "can't scrobble type %s", id.Type)
}
if scrobbleTrack.Track == "" {
@@ -293,6 +293,7 @@ func (c *Controller) ServeGetSong(r *http.Request) *spec.Response {
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
First(&track).
@@ -320,6 +321,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Joins("JOIN albums ON tracks.album_id=albums.id").
@@ -334,7 +336,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 genres ON genres.id=track_genres.genre_id AND genres.name=?", genre)
}
if m := getMusicFolder(c, params); m != "" {
if m := getMusicFolder(c.musicPaths, params); m != "" {
q = q.Where("albums.root_dir=?", m)
}
if err := q.Find(&tracks).Error; err != nil {
@@ -398,7 +400,7 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
switch id.Type {
case specid.Track:
var track db.Track
if err := c.dbc.Where("id=?", id.Value).Preload("Album").Preload("Album.Artists").Preload("Artists").Find(&track).Error; err != nil {
if err := c.dbc.Where("id=?", id.Value).Preload("Album").Preload("Album.Artists").Preload("Artists").Preload("Contributors.Artist").Find(&track).Error; err != nil {
return nil, fmt.Errorf("load track: %w", err)
}
ret = append(ret, spec.NewTrackByTags(&track, track.Album))
@@ -777,11 +779,10 @@ func scrobbleStatsUpdatePodcastEpisode(dbc *db.DB, peID int) error {
return nil
}
func getMusicFolder(c *Controller, p params.Params) string {
musicPaths := c.musicPaths
func getMusicFolder(musicPaths []MusicPath, p params.Params) string {
idx, err := p.GetInt("musicFolderId")
if err != nil {
return c.defaultMusicPath
return ""
}
if idx < 0 || idx >= len(musicPaths) {
return os.DevNull
+12 -9
View File
@@ -14,11 +14,14 @@ import (
func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
isIncludeEpisodes := params.GetOrBool("includeEpisodes", true)
id, _ := params.GetID("id")
podcasts, err := c.podcasts.GetPodcastOrAll(id.Value, isIncludeEpisodes)
id, err := params.GetID("id")
if err != nil {
return spec.NewError(10, "failed get podcast(s): %s", err)
}
podcasts, err := c.podcasts.GetPodcastOrAll(id.Value, isIncludeEpisodes)
if err != nil {
return spec.NewError(70, "failed get podcast(s): %s", err)
}
sub := spec.NewResponse()
sub.Podcasts = &spec.Podcasts{}
for _, podcast := range podcasts {
@@ -33,7 +36,7 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
count := params.GetOrInt("count", 10)
episodes, err := c.podcasts.GetNewestPodcastEpisodes(count)
if err != nil {
return spec.NewError(10, "failed get podcast(s): %s", err)
return spec.NewError(0, "failed get podcast(s): %s", err)
}
sub := spec.NewResponse()
sub.NewestPodcasts = &spec.NewestPodcasts{}
@@ -50,7 +53,7 @@ func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response
return spec.NewError(10, "please provide a valid podcast episode id")
}
if err := c.podcasts.DownloadEpisode(id.Value); err != nil {
return spec.NewError(10, "failed to download episode: %s", err)
return spec.NewError(0, "failed to download episode: %s", err)
}
return spec.NewResponse()
}
@@ -65,10 +68,10 @@ func (c *Controller) ServeCreatePodcastChannel(r *http.Request) *spec.Response {
fp := gofeed.NewParser()
feed, err := fp.ParseURL(rssURL)
if err != nil {
return spec.NewError(10, "failed to parse feed: %s", err)
return spec.NewError(0, "failed to parse feed: %s", err)
}
if _, err = c.podcasts.AddNewPodcast(rssURL, feed); err != nil {
return spec.NewError(10, "failed to add feed: %s", err)
return spec.NewError(0, "failed to add feed: %s", err)
}
return spec.NewResponse()
}
@@ -79,7 +82,7 @@ func (c *Controller) ServeRefreshPodcasts(r *http.Request) *spec.Response {
return spec.NewError(50, "user not admin")
}
if err := c.podcasts.RefreshPodcasts(); err != nil {
return spec.NewError(10, "failed to refresh feeds: %s", err)
return spec.NewError(0, "failed to refresh feeds: %s", err)
}
return spec.NewResponse()
}
@@ -95,7 +98,7 @@ func (c *Controller) ServeDeletePodcastChannel(r *http.Request) *spec.Response {
return spec.NewError(10, "please provide a valid podcast id")
}
if err := c.podcasts.DeletePodcast(id.Value); err != nil {
return spec.NewError(10, "failed to delete podcast: %s", err)
return spec.NewError(70, "failed to delete podcast: %s", err)
}
return spec.NewResponse()
}
@@ -111,7 +114,7 @@ func (c *Controller) ServeDeletePodcastEpisode(r *http.Request) *spec.Response {
return spec.NewError(10, "please provide a valid podcast episode id")
}
if err := c.podcasts.DeletePodcastEpisode(id.Value); err != nil {
return spec.NewError(10, "failed to delete podcast: %s", err)
return spec.NewError(70, "failed to delete podcast: %s", err)
}
return spec.NewResponse()
}
+2 -2
View File
@@ -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)
if err != nil {
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
return spec.NewError(70, "couldn't find cover %q: %v", id, err)
}
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)
if err := imaging.Save(resized, cachePath); err != nil {
return spec.NewError(10, "saving cover %q: %v", id, err)
return spec.NewError(0, "saving cover %q: %v", id, err)
}
serve(cachePath)
@@ -20,7 +20,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
TrackCount: f.ChildCount,
Duration: f.Duration,
Created: f.CreatedAt,
AverageRating: formatRating(f.AverageRating),
AverageRating: f.AverageRating,
ReleaseTypes: []string{},
}
if f.AlbumStar != nil {
@@ -44,7 +44,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
Title: f.RightPath,
ParentID: f.ParentSID(),
CreatedAt: f.CreatedAt,
AverageRating: formatRating(f.AverageRating),
AverageRating: f.AverageRating,
Year: f.TagYear,
}
if f.AlbumStar != nil {
@@ -79,13 +79,13 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
),
ParentID: parent.SID(),
Duration: t.Length,
Year: parent.TagYear,
Bitrate: t.Bitrate,
IsDir: false,
Type: "music",
MusicBrainzID: t.TagBrainzID,
CreatedAt: t.CreatedAt,
AverageRating: formatRating(t.AverageRating),
AverageRating: t.AverageRating,
Year: t.TagYear,
}
if trCh.Title == "" {
trCh.Title = t.Filename
@@ -170,7 +170,7 @@ func NewArtistByFolder(f *db.Album) *Artist {
ID: f.SID(),
Name: f.RightPath,
AlbumCount: f.ChildCount,
AverageRating: formatRating(f.AverageRating),
AverageRating: f.AverageRating,
}
if f.AlbumStar != nil {
a.Starred = &f.AlbumStar.StarDate
@@ -192,7 +192,7 @@ func NewDirectoryByFolder(f *db.Album, children []*TrackChild) *Directory {
Name: f.RightPath,
Children: children,
ParentID: f.ParentSID(),
AverageRating: formatRating(f.AverageRating),
AverageRating: f.AverageRating,
}
if f.AlbumStar != nil {
d.Starred = &f.AlbumStar.StarDate
+31 -10
View File
@@ -3,7 +3,9 @@ package spec
import (
"cmp"
"path/filepath"
"slices"
"sort"
"strings"
"go.senan.xyz/gonic/db"
)
@@ -22,7 +24,7 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
Genres: []*GenreRef{},
Year: a.TagYear,
Tracks: []*TrackChild{},
AverageRating: formatRating(a.AverageRating),
AverageRating: a.AverageRating,
IsCompilation: a.TagCompilation,
ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
DiscTitles: []*DiscTitle{},
@@ -97,9 +99,9 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
DiscNumber: t.TagDiscNumber,
Type: "music",
MusicBrainzID: t.TagBrainzID,
Year: album.TagYear,
AverageRating: formatRating(t.AverageRating),
AverageRating: t.AverageRating,
TranscodeMeta: TranscodeMeta{},
Year: t.TagYear,
}
switch {
@@ -118,12 +120,8 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
ret.UserRating = t.TrackRating.Rating
}
sort.Slice(t.Artists, func(i, j int) bool {
return t.Artists[i].ID < t.Artists[j].ID
})
sort.Slice(album.Artists, func(i, j int) bool {
return album.Artists[i].ID < album.Artists[j].ID
})
slices.SortFunc(t.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.ID) })
slices.SortFunc(album.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.ID) })
switch {
case len(t.Artists) > 0:
@@ -145,6 +143,29 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
for _, a := range album.Artists {
ret.AlbumArtists = append(ret.AlbumArtists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
slices.SortStableFunc(t.Contributors, func(a, b *db.TrackContributor) int {
return cmp.Or(
cmp.Compare(a.Role, b.Role),
cmp.Compare(a.ArtistID, b.ArtistID),
)
})
var composers []string
for _, c := range t.Contributors {
if c.Artist == nil {
continue
}
ret.Contributors = append(ret.Contributors, &Contributor{
Role: string(c.Role),
Artist: &ArtistRef{ID: c.Artist.SID(), Name: c.Artist.Name},
})
if c.Role == db.ContributorRoleComposer {
composers = append(composers, c.Artist.Name)
}
}
ret.DisplayComposer = strings.Join(composers, ", ")
if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 {
ret.ReplayGain = &ReplayGain{
TrackGain: t.ReplayGainTrackGain,
@@ -162,7 +183,7 @@ func NewArtistByTags(a *db.Artist) *Artist {
Name: a.Name,
AlbumCount: a.AlbumCount,
Albums: []*Album{},
AverageRating: formatRating(a.AverageRating),
AverageRating: a.AverageRating,
}
if a.Info != nil && a.Info.ImageURL != "" {
r.CoverID = a.SID()
+14 -12
View File
@@ -125,6 +125,12 @@ type GenreRef struct {
Name string `xml:"name,attr" json:"name"`
}
// https://opensubsonic.netlify.app/docs/responses/contributor/
type Contributor struct {
Role string `xml:"role,attr" json:"role"`
Artist *ArtistRef `xml:"artist" json:"artist"`
}
type DiscTitle struct {
Disc int `xml:"disc,attr" json:"disc"`
Title string `xml:"title,attr" json:"title"`
@@ -165,7 +171,7 @@ type Album struct {
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
AverageRating string `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
AverageRating float64 `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
}
type RandomTracks struct {
@@ -204,6 +210,9 @@ type TrackChild struct {
AlbumArtists []*ArtistRef `xml:"albumArtists" json:"albumArtists"`
AlbumDisplayArtist string `xml:"displayAlbumArtist,attr" json:"displayAlbumArtist"`
Contributors []*Contributor `xml:"contributors" json:"contributors"`
DisplayComposer string `xml:"displayComposer,attr" json:"displayComposer"`
Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
@@ -228,7 +237,7 @@ type TrackChild struct {
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
AverageRating string `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
AverageRating float64 `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
ReplayGain *ReplayGain `xml:"replayGain" json:"replayGain"`
@@ -249,7 +258,7 @@ type Artist struct {
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
AverageRating string `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
AverageRating float64 `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
}
type Indexes struct {
@@ -269,7 +278,7 @@ type Directory struct {
Name string `xml:"name,attr,omitempty" json:"name"`
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
AverageRating string `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
AverageRating float64 `xml:"averageRating,attr,omitempty" json:"averageRating,omitempty"`
Children []*TrackChild `xml:"child,omitempty" json:"child,omitempty"`
}
@@ -473,7 +482,7 @@ type InternetRadioStation struct {
ID *specid.ID `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"`
StreamURL string `xml:"streamUrl,attr" json:"streamUrl"`
HomepageURL string `xml:"homepageUrl,attr" json:"homepageUrl"`
HomepageURL string `xml:"homePageUrl,attr" json:"homePageUrl"`
}
type Lyrics struct {
@@ -507,13 +516,6 @@ type OpenSubsonicExtension struct {
type OpenSubsonicExtensions []OpenSubsonicExtension
func formatRating(rating float64) string {
if rating == 0 {
return ""
}
return fmt.Sprintf("%.2f", rating)
}
func formatExt(ext string) string {
return strings.TrimPrefix(ext, ".")
}
+74 -74
View File
@@ -8,55 +8,17 @@
"albumList": {
"album": [
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-7",
"id": "al-8",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"title": "album-1",
"album": "album-1",
"parent": "al-6",
"isDir": true,
"coverArt": "al-7",
"name": "album-0",
"coverArt": "al-8",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -84,17 +46,17 @@
"discTitles": null
},
{
"id": "al-4",
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -103,17 +65,17 @@
"discTitles": null
},
{
"id": "al-8",
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"title": "album-0",
"album": "album-0",
"parent": "al-6",
"isDir": true,
"coverArt": "al-8",
"name": "album-1",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -140,25 +102,6 @@
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-10",
"isDir": true,
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
@@ -177,6 +120,63 @@
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-10",
"isDir": true,
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
}
]
}
+83 -83
View File
@@ -8,79 +8,16 @@
"albumList2": {
"album": [
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
"id": "al-8",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-2",
"album": "album-2",
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-0",
"album": "album-0",
"coverArt": "al-3",
"name": "album-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-8",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -134,16 +71,16 @@
"discTitles": []
},
{
"id": "al-8",
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-1",
"album": "album-1",
"coverArt": "al-8",
"name": "album-1",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-0",
"album": "album-0",
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -155,15 +92,15 @@
"discTitles": []
},
{
"id": "al-4",
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
@@ -195,6 +132,69 @@
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-2",
"album": "album-2",
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
@@ -33,6 +33,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -61,6 +63,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -89,6 +93,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -20,6 +20,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -48,6 +50,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -76,6 +80,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -17,6 +17,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-3",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -34,6 +36,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-4",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -51,6 +55,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-5",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
+40
View File
@@ -17,6 +17,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -47,6 +49,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -77,6 +81,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -107,6 +113,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -137,6 +145,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -167,6 +177,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -197,6 +209,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -227,6 +241,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -257,6 +273,8 @@
"displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -287,6 +305,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -317,6 +337,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -347,6 +369,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -377,6 +401,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -407,6 +433,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -437,6 +465,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -467,6 +497,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -497,6 +529,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -527,6 +561,8 @@
"displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -557,6 +593,8 @@
"displayArtist": "artist-2",
"albumArtists": [{ "id": "ar-3", "name": "artist-2" }],
"displayAlbumArtist": "artist-2",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-11",
@@ -587,6 +625,8 @@
"displayArtist": "artist-2",
"albumArtists": [{ "id": "ar-3", "name": "artist-2" }],
"displayAlbumArtist": "artist-2",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-11",
+18
View File
@@ -14,6 +14,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-3",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -31,6 +33,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-4",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -48,6 +52,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-5",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -65,6 +71,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-7",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -82,6 +90,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-8",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -99,6 +109,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-9",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -116,6 +128,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-11",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -133,6 +147,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-12",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
@@ -150,6 +166,8 @@
"displayArtist": "",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-13",
"created": "2019-11-30T00:00:00Z",
"isDir": true,
+40
View File
@@ -17,6 +17,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -45,6 +47,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -73,6 +77,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-3",
@@ -101,6 +107,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -129,6 +137,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -157,6 +167,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-4",
@@ -185,6 +197,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -213,6 +227,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -241,6 +257,8 @@
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-5",
@@ -269,6 +287,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -297,6 +317,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -325,6 +347,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-7",
@@ -353,6 +377,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -381,6 +407,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -409,6 +437,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-8",
@@ -437,6 +467,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -465,6 +497,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -493,6 +527,8 @@
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-9",
@@ -521,6 +557,8 @@
"displayArtist": "artist-2",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-11",
@@ -549,6 +587,8 @@
"displayArtist": "artist-2",
"albumArtists": null,
"displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100,
"contentType": "audio/flac",
"coverArt": "al-11",
+12 -12
View File
@@ -33,6 +33,15 @@ const (
FallbackGenre = "Unknown Genre"
)
func FirstValues(p Tags, keys ...string) []string {
for _, k := range keys {
if v := normtag.Values(p, k); len(v) > 0 {
return v
}
}
return nil
}
func MustAlbum(p Tags) string {
if r := normtag.Get(p, normtag.Album); r != "" {
return r
@@ -48,10 +57,7 @@ func MustArtist(p Tags) string {
}
func MustArtists(p Tags) []string {
if r := normtag.Values(p, normtag.Artists); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.Artist); len(r) > 0 {
if r := FirstValues(p, normtag.Artists, normtag.Artist); len(r) > 0 {
return r
}
return []string{FallbackArtist}
@@ -65,10 +71,7 @@ func MustAlbumArtist(p Tags) string {
}
func MustAlbumArtists(p Tags) []string {
if r := normtag.Values(p, normtag.AlbumArtists); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.AlbumArtist); len(r) > 0 {
if r := FirstValues(p, normtag.AlbumArtists, normtag.AlbumArtist); len(r) > 0 {
return r
}
return []string{MustArtist(p)}
@@ -82,10 +85,7 @@ func MustGenre(p Tags) string {
}
func MustGenres(p Tags) []string {
if r := normtag.Values(p, normtag.Genres); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.Genre); len(r) > 0 {
if r := FirstValues(p, normtag.Genres, normtag.Genre); len(r) > 0 {
return r
}
return []string{FallbackGenre}