132 Commits
Author SHA1 Message Date
yaemiku 4c33d3f2f4 Merge branch 'default_music_folder' 2026-04-26 03:58:21 +02:00
yaemiku b2c317a449 Merge branch 'ldap_auth' 2026-04-26 03:58:13 +02:00
yaemiku c2e2e037a2 Merge branch 'master' into default_music_folder 2026-04-26 03:57:41 +02:00
yaemiku 1e59ef9a81 Merge branch 'master' into ldap_auth 2026-04-26 03:42:56 +02:00
yaemiku 28ca45c6a1 Merge branch 'default_music_folder' 2026-04-26 03:10:03 +02:00
yaemiku a6349ecbed Merge branch 'ldap_auth' 2026-04-26 03:09:52 +02:00
yaemiku 094ab2e458 Merge branch 'master' into ldap_auth 2026-04-26 03:02:46 +02:00
yaemiku 0f469d7eac Merge branch 'master' into default_music_folder 2026-04-26 03:02:02 +02:00
Eric Munson f79af9c6a8 feat(podcast): ensure that any error path out of doPodcastDownload sets status (#672)
Release / Lint and test (push) Successful in 2m44s
Release / Run Release Please (push) Failing after 15s
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
Release / Build, tag, and publish Docker image (push) Has been skipped
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-04-26 03:00:56 +02:00
Florian Sorko 8df5f95a3d 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-04-26 03:00:55 +02:00
Eric Munson 3c46097df3 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-04-26 03:00:54 +02:00
sentriz 13098660d2 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-04-26 03:00:53 +02:00
sentriz fb3fb745f8 fix(scanner): reset batch timer on fsnotify Remove events
fixes #637
2026-04-26 03:00:52 +02:00
sentriz ee43c4db00 fix(subsonic): update homepage URL casing
closes #664
2026-04-26 03:00:51 +02:00
sentriz da5f2ca01c update readme
closes #667
2026-04-26 03:00:50 +02:00
Kynn | CherryblueandSenan Kelly e4a07750e4 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-04-26 03:00:49 +02:00
sentriz d42ce531c6 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-04-26 03:00:48 +02:00
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
yaemiku ac2f8c57ac Merge branch 'master' 2026-03-11 22:19:55 +01:00
yaemiku 88edd8b546 Merge branch 'master' into ldap_auth 2026-03-11 22:19:10 +01:00
yaemiku 002a38f7a6 Merge branch 'master' into default_music_folder 2026-03-11 22:15:20 +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
yaemiku 2888fb2153 Merge branch 'master' 2026-02-19 03:26:22 +01:00
yaemiku a7929ecb38 Merge branch 'master' into default_music_folder 2026-02-19 03:26:10 +01:00
yaemiku 9c258bd316 Merge branch 'master' into ldap_auth 2026-02-19 03:25:57 +01:00
yaemiku 4305601c9e Merge branch 'ldap_auth' 2026-02-19 03:09:24 +01:00
yaemiku a63df166b0 Add default music path flag 2026-02-19 02:51:10 +01:00
yaemiku bb8a68fe77 Enable a flag to change username attribute in LDAP 2026-02-19 00:22:34 +01:00
sentriz 25a061f44e fix(listenbrainz): disable keep-alive to avoid connection reset errors 2026-02-17 15:36:20 +00:00
yaemiku 1e99bb4a0a README LDAP env vars entries 2026-02-15 05:50:41 +01:00
yaemiku 9e331dd459 Move LDAP store out of the global variable 2026-02-15 05:01:16 +01:00
yaemiku ae99e76fc7 Merge branch 'master' into ldap_auth 2026-02-14 03:58:30 +01:00
yaemiku 4837448092 Merge remote-tracking branch 'origin' into ldap_auth 2026-02-14 03:54:36 +01:00
yaemiku eccc957fd1 Merge branch 'master' into ldap_auth
Nightly Release / Check latest commit (push) Successful in 6s
Nightly Release / Lint and test (push) Has been skipped
Nightly Release / Build and release Docker image (push) Has been skipped
2025-10-12 11:06:18 +02:00
yaemiku 6fba25ca0b ldap login logic, subsonic api hex encrypted password 2025-09-21 08:02:10 +02:00
yaemiku e5c192c83c Merge branch 'master' into ldap_auth 2025-09-21 06:37:41 +02:00
Daniel Hall d9facdcca6 Merge branch 'master' into ldap_auth 2024-09-08 10:59:37 -07:00
Daniel Hall 21b562b5fe style: Made invalid auth chain less chain-y 2024-06-26 15:54:39 -07:00
Daniel Hall 758c4c7279 lint: Fixed ineffassign on Add 2024-06-26 15:49:41 -07:00
Daniel Hall 4c5c015190 go mod tidy 2024-06-26 15:34:15 -07:00
Daniel Hall 7159e1ca09 fix: Fixed conf music path check 2024-06-26 15:33:54 -07:00
betapictoris f812c15fa1 Merge branch 'master' into ldap_auth 2024-06-10 23:00:54 -07:00
betapictoris dc98b6aa50 Merge branch 'sentriz:master' into ldap_auth 2024-04-08 19:00:41 -07:00
Daniel Hall e2415e944c Do session change on failed LDAP check 2024-04-08 18:13:16 -07:00
Daniel Hall 0f7e24b39b Fixed filter params 2024-04-08 13:52:04 -07:00
Daniel Hall f5195f15c4 Fix password check for local users 2024-04-07 12:55:29 -07:00
Daniel Hall fccf01642f Added LDAP password cache 2024-04-07 12:29:45 -07:00
Daniel Hall 5638ef5df7 Added LDAP admin filter 2024-04-07 11:24:26 -07:00
Daniel Hall 6ca68b2c26 Only allow use of subsonic API with one auth method 2024-04-07 10:43:07 -07:00
Daniel Hall b36f26e32a Have LDAP read from config 2024-04-07 10:18:00 -07:00
Daniel Hall 995c566131 Readded gofeed dep 2024-04-07 09:55:46 -07:00
Daniel Hall 6eddc2a1a9 Made withUser return a middleware and take dbc 2024-04-07 09:40:25 -07:00
betapictoris 6d7c605578 Merge branch 'master' into ldap_auth 2024-04-01 10:49:18 -07:00
Daniel Hall 6bf39cc0c4 Removed LDAP config from admin templates 2024-04-01 10:45:55 -07:00
Daniel Hall 8ba05ef14d Reverted home template 2024-04-01 10:42:11 -07:00
Daniel Hall dc3682dc8f Removed LDAP web UI 2024-04-01 10:40:42 -07:00
Daniel Hall 3cf6d0a28b Added LDAP config 2024-04-01 10:33:59 -07:00
Daniel Hall c531666eb6 Bump LDAP deps 2024-04-01 10:13:33 -07:00
Daniel 02fd31452d Merge branch 'sentriz:master' into ldap_auth 2024-02-28 13:57:45 -08:00
Daniel 9a97fa4b22 Merge branch 'master' into ldap_auth 2024-02-23 11:00:55 -08:00
Daniel 8d4c22ad2f Merge branch 'master' into ldap_auth 2024-02-22 07:35:53 -08:00
Daniel Hall 0d85e0ce02 Stopped opening up a second connection when creating a user from LDAP 2024-02-18 09:44:26 -08:00
Daniel Hall 8793a36364 Rewrote if-else to switch for LDAP results 2024-02-17 22:38:19 -08:00
Daniel Hall ac31258f88 Removed unnecessary trailing newline 2024-02-17 22:29:29 -08:00
Daniel Hall 683525aad2 Removed unused password parameter from createUserFromLDAP 2024-02-17 22:27:57 -08:00
Daniel Hall bc62b213a5 Lower-cased and removed punctuation for errors
Fixes linting
2024-02-17 22:27:08 -08:00
Daniel Hall f6ecd6d39b Added dashboard login for LDAP users 2024-02-17 22:23:38 -08:00
Daniel Hall fdceb555bf Removed unused logs 2024-02-17 22:23:12 -08:00
Daniel Hall 6301cb25bc Fix User struct from having not null passwords
This is required for LDAP auth to work, blank passwords don't work anyway.
2024-02-17 22:13:52 -08:00
Daniel Hall 408d325c2c Move LDAP into a seperate file 2024-02-17 22:12:56 -08:00
Daniel e944817f8b Merge with upstream
Merge pull request #1 from BetaPictoris/master
2024-02-15 11:00:04 -08:00
Daniel f8b0fbbfa2 Merge branch 'ldap_auth' into master 2024-02-15 10:59:33 -08:00
Daniel 90b5324179 gofmt handlers 2023-12-08 23:15:51 -08:00
Daniel 05149961b5 Used log to log instead of fmt 2023-12-08 23:15:10 -08:00
Daniel 84e29da258 Merge branch 'master' into ldap_auth 2023-12-08 23:12:25 -08:00
Daniel 7c6e1957fb Simplified code using gofmt 2023-12-08 23:10:26 -08:00
Daniel df42923f7b Made LDAP query log message match others 2023-12-08 23:04:13 -08:00
Daniel 4799fb2441 Update go-ldap/ldap to v3 2023-12-01 12:31:24 -08:00
Daniel 322aa0747a Made WithUser middleware private 2023-11-30 14:23:51 -08:00
Daniel 7558bb3f23 Merge branch 'master' into ldap_auth 2023-11-11 17:12:27 -08:00
Daniel e770eaa07a Fixed old references to use the new style
Readded goldap
Fixed `c.DB` to `c.dbc`
Fixed `WithUser`
2023-11-10 13:58:33 -08:00
Daniel a24b7c07cb Merge branch master into ldap_auth 2023-11-10 13:47:47 -08:00
BetaPictoris c03e10454c Fixed merge conflicts 2023-10-28 17:05:50 -07:00
BetaPictoris a99d63ab12 Fixed nil password causing invalid dereferences 2023-10-27 16:02:47 -07:00
BetaPictoris 667cf731fd Extract out LDAP connection creation 2023-10-27 15:48:41 -07:00
BetaPictoris 38ea72bbc6 Only try to login if there is exactly 1 user, otherwise return an error. 2023-10-27 10:53:43 -07:00
BetaPictoris d6d51ed9f7 Update username error message to match Subsonic API 2023-10-27 10:50:33 -07:00
beta 9e5b8d4ac8 Fixed newLDAPUser being reset 2023-09-09 09:55:29 -07:00
beta 238856ad73 Fixed newLDAPUser def 2023-09-09 09:49:48 -07:00
beta 7de6cf1e9e Fixed use of newLDAPUser 2023-09-09 09:48:54 -07:00
beta e7d6fdab69 Fixed bug where two requests got merged 2023-09-09 09:37:36 -07:00
beta 94027dcf9b Fixed variable defs 2023-09-09 09:28:57 -07:00
beta 46dac6d463 Check errors in ldap do handler 2023-09-09 09:27:12 -07:00
Daniel fc08e0a171 Merge branch 'sentriz:master' into ldap_auth 2023-09-05 02:53:33 +00:00
Daniel c317046fc9 Merge branch 'sentriz:master' into ldap_auth 2023-08-15 15:39:05 -07:00
BetaPictoris a558947da6 Fixed SetSetting err checking 2023-08-06 03:20:29 -07:00
BetaPictoris e5f815c79e Fixed filter labels 2023-08-06 03:14:43 -07:00
BetaPictoris 80f5facbd2 Added c.DB.SetSetting (errcheck) 2023-08-06 03:12:36 -07:00
BetaPictoris 23d23c7c6a Fixed r param revive 2023-08-06 03:04:59 -07:00
BetaPictoris 1fd8c9b2c3 Fix else if (gocritic) 2023-08-06 03:02:13 -07:00
BetaPictoris 9c56bf61ab Fixed for LDAP connection 2023-08-06 03:00:00 -07:00
BetaPictoris 79b28ef653 Fixed ineffassign to 2023-08-06 02:58:40 -07:00
BetaPictoris d8338590fd Added LDAP user creation 2023-08-06 02:54:17 -07:00
BetaPictoris fdb2ec66de Added LDAP auth if there is a user 2023-08-06 01:33:21 -07:00
BetaPictoris 6c8f5fa968 Added go-ldap dep 2023-08-06 00:43:20 -07:00
BetaPictoris 6602495032 Added a way of disabling LDAP auth 2023-08-06 00:40:26 -07:00
BetaPictoris 6b2f853b3c Removed eURL file 2023-08-05 22:12:13 -07:00
BetaPictoris 23e797e62a Addd default value for LDAP config page 2023-08-05 22:11:05 -07:00
BetaPictoris 1fab192195 Added TODO 2023-08-05 18:48:01 -07:00
BetaPictoris 98be763e37 Added saving of LDAP settings 2023-08-05 18:46:47 -07:00
BetaPictoris 830ab090fd Fixed typo 2023-08-05 18:42:27 -07:00
BetaPictoris 13bb999bd5 Made TLS checkbox work.
TODO: Make the styles match the rest of the page and move them out of inline.
2023-08-05 17:06:37 -07:00
BetaPictoris ae9f95aa75 Added LDAP route 2023-08-05 16:43:03 -07:00
BetaPictoris c5b35a6ff1 Added LDAP config template 2023-08-05 16:30:54 -07:00
BetaPictoris cf3f6666e0 Added LDAP link 2023-08-05 15:19:10 -07:00
41 changed files with 1092 additions and 377 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: ["*"]
+4
View File
@@ -1,4 +1,5 @@
*.db *.db
*.db.*.bak
*db-wal *db-wal
*db-shm *db-shm
*.sql *.sql
@@ -12,3 +13,6 @@ dist
*.swp *.swp
.tags* .tags*
*.test *.test
.env
config
genre-tree
+2 -2
View File
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1 # 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 TARGETOS
ARG TARGETARCH ARG TARGETARCH
WORKDIR /src WORKDIR /src
@@ -12,7 +12,7 @@ RUN \
--mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/ ./cmd/... 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 LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic
RUN apk add -U --no-cache \ RUN apk add -U --no-cache \
ffmpeg \ ffmpeg \
+10 -1
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 - support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below) - written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
- newer salt and token auth - newer salt and token auth
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [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 ## installation
@@ -76,6 +76,15 @@ 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_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_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_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+) ## multi valued tags (v0.16+)
+23 -2
View File
@@ -39,6 +39,7 @@ import (
"go.senan.xyz/gonic/infocache/artistinfocache" "go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/jukebox" "go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/lastfm" "go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/listenbrainz" "go.senan.xyz/gonic/listenbrainz"
"go.senan.xyz/gonic/playlist" "go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/podcast" "go.senan.xyz/gonic/podcast"
@@ -84,6 +85,26 @@ func main() {
confExcludePattern := flag.String("exclude-pattern", "", "regex pattern to exclude files from scan (optional)") 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 var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for multi-valued genre scanning (optional)") 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)") flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for multi-valued track artist scanning (optional)")
@@ -253,11 +274,11 @@ func main() {
return url.String() return url.String()
} }
ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath) ctrlAdmin, err := ctrladmin.New(dbc, sessDB, scannr, podcast, lastfmClient, resolveProxyPath, ldapConfig, ldapStore)
if err != nil { if err != nil {
log.Panicf("error creating admin controller: %v\n", err) log.Panicf("error creating admin controller: %v\n", err)
} }
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *defaultMusicPath, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath) ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *defaultMusicPath, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath, ldapConfig, ldapStore)
if err != nil { if err != nil {
log.Panicf("error creating subsonic controller: %v\n", err) log.Panicf("error creating subsonic controller: %v\n", err)
} }
+64 -29
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 { 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 return nil
} }
var rows []string tail := len(head) - 1
var values []any placeholder := "(?" + strings.Repeat(", ?", tail) + ")"
for _, c := range col {
rows = append(rows, "(?, ?)") placeholders := make([]string, len(rows))
values = append(values, left, c) 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", q := fmt.Sprintf("INSERT OR IGNORE INTO %q (%s) VALUES %s",
table, table,
strings.Join(head, ", "), strings.Join(head, ", "),
strings.Join(rows, ", "), strings.Join(placeholders, ", "),
) )
return db.Exec(q, values...).Error 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 // https://sqlite.org/limits.html
const size = 999 const size = 999
return db.Transaction(func(tx *DB) error { for i := 0; i < len(data); i += size {
for i := 0; i < len(data); i += size { end := min(i+size, len(data))
end := min(i+size, len(data)) if err := db.Transaction(func(tx *DB) error {
if err := cb(tx, data[i:end]); err != nil { return cb(tx, data[i:end])
return err }); err != nil {
} return err
} }
return nil }
}) return nil
} }
type SettingKey string type SettingKey string
@@ -211,19 +226,21 @@ type Track struct {
Filename string `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null"` Filename string `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null"`
FilenameUDec string `sql:"default: null"` FilenameUDec string `sql:"default: null"`
Album *Album Album *Album
AlbumID int `gorm:"not null; unique_index:idx_folder_filename" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"` 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"` Artists []*Artist `gorm:"many2many:track_artists"`
Genres []*Genre `gorm:"many2many:track_genres"` Contributors []*TrackContributor `gorm:"foreignkey:track_id"`
Size int `sql:"default: null"` Genres []*Genre `gorm:"many2many:track_genres"`
Length int `sql:"default: null"` Size int `sql:"default: null"`
Bitrate int `sql:"default: null"` Length int `sql:"default: null"`
TagTitle string `sql:"default: null"` Bitrate int `sql:"default: null"`
TagTitleUDec string `sql:"default: null"` TagTitle string `sql:"default: null"`
TagTrackArtist string `sql:"default: null"` TagTitleUDec string `sql:"default: null"`
TagTrackNumber int `sql:"default: null"` TagTrackArtist string `sql:"default: null"`
TagDiscNumber int `sql:"default: null"` TagTrackNumber int `sql:"default: null"`
TagBrainzID string `sql:"default: null"` TagDiscNumber int `sql:"default: null"`
TagLyrics string `sql:"default: null"` TagBrainzID string `sql:"default: null"`
TagLyrics string `sql:"default: null"`
TagYear int `sql:"default: null"`
ReplayGainTrackGain float32 ReplayGainTrackGain float32
ReplayGainTrackPeak float32 ReplayGainTrackPeak float32
@@ -287,7 +304,7 @@ type User struct {
ID int `gorm:"primary_key"` ID int `gorm:"primary_key"`
CreatedAt time.Time CreatedAt time.Time
Name string `gorm:"not null; unique_index" sql:"default: null"` Name string `gorm:"not null; unique_index" sql:"default: null"`
Password string `gorm:"not null" sql:"default: null"` Password string `sql:"default: null"`
LastFMSession string `sql:"default: null"` LastFMSession string `sql:"default: null"`
ListenBrainzURL string `sql:"default: null"` ListenBrainzURL string `sql:"default: null"`
ListenBrainzToken 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"` 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 { 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"` 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"` 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, "202509301448", migrateAddTrackEmbeddedCover),
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt), construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
construct(ctx, "202601201000", migrateAddAlbumDiscTitles), construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
construct(ctx, "202602061800", migrateAddTrackYear),
construct(ctx, "202604231200", migrateAddTrackContributors),
} }
return gormigrate. return gormigrate.
@@ -879,3 +881,26 @@ func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error { func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(AlbumDiscTitle{}).Error return tx.AutoMigrate(AlbumDiscTitle{}).Error
} }
func 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 // Cgo-free Wasm database
_ "github.com/ncruces/go-sqlite3/driver" _ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
// Cgo-free Wasm tagger // Cgo-free Wasm tagger
"go.senan.xyz/gonic/tags/taglib" "go.senan.xyz/gonic/tags/taglib"
+17 -13
View File
@@ -1,6 +1,6 @@
module go.senan.xyz/gonic module go.senan.xyz/gonic
go 1.25 go 1.26.0
require ( require (
github.com/Masterminds/sprig v2.22.0+incompatible github.com/Masterminds/sprig v2.22.0+incompatible
@@ -13,17 +13,18 @@ require (
github.com/env25/mpdlrc v0.7.4 github.com/env25/mpdlrc v0.7.4
github.com/fatih/structs v1.1.0 github.com/fatih/structs v1.1.0
github.com/fsnotify/fsnotify v1.9.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/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/gorilla/securecookie v1.1.2 github.com/gorilla/securecookie v1.1.2
github.com/gorilla/sessions v1.4.0 github.com/gorilla/sessions v1.4.0
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414 github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
github.com/josephburnett/jd v1.9.2 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/microcosm-cc/bluemonday v1.0.27
github.com/mitchellh/mapstructure v1.5.0 github.com/mitchellh/mapstructure v1.5.0
github.com/mmcdole/gofeed v1.3.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/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
@@ -31,20 +32,22 @@ require (
github.com/stretchr/testify v1.11.1 github.com/stretchr/testify v1.11.1
go.senan.xyz/flagconf v0.1.11 go.senan.xyz/flagconf v0.1.11
go.senan.xyz/taglib v0.11.1 go.senan.xyz/taglib v0.11.1
go.senan.xyz/wrtag v0.20.0 go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb
golang.org/x/net v0.49.0 golang.org/x/net v0.53.0
golang.org/x/sync v0.19.0 golang.org/x/sync v0.20.0
gopkg.in/gormigrate.v1 v1.6.0 gopkg.in/gormigrate.v1 v1.6.0
) )
require ( require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // 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/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect github.com/go-asn1-ber/asn1-ber v1.5.5 // 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/context v1.1.2 // indirect
github.com/gorilla/css v1.0.1 // indirect github.com/gorilla/css v1.0.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect github.com/huandu/xstrings v1.5.0 // indirect
@@ -59,13 +62,14 @@ require (
github.com/mmcdole/goxpp v1.1.1 // indirect github.com/mmcdole/goxpp v1.1.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // 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/ncruces/julianday v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tetratelabs/wazero v1.11.0 // indirect github.com/tetratelabs/wazero v1.11.0 // indirect
golang.org/x/crypto v0.47.0 // indirect golang.org/x/crypto v0.50.0 // indirect
golang.org/x/image v0.35.0 // indirect golang.org/x/image v0.39.0 // indirect
golang.org/x/sys v0.40.0 // indirect golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.33.0 // indirect golang.org/x/text v0.36.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
+42 -28
View File
@@ -1,4 +1,6 @@
cloud.google.com/go v0.33.1/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 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 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
@@ -6,8 +8,10 @@ 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 h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= 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.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.11.0 h1:jZ7pwMQXIITcUXNH83LLk+txlaEy6NVOfTuP43xxfqw= github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo=
github.com/PuerkitoBio/goquery v1.11.0/go.mod h1:wQHgxUOU3JGuj3oD/QFfxUdlzW6xPHfqyHre6VMY4DQ= github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ=
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/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= 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 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA= github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
@@ -37,12 +41,16 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= 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 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4= github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80= github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI= github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag= github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4=
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= 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.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 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@@ -57,6 +65,7 @@ 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/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 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= 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 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
@@ -103,8 +112,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-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.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.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0= github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo=
github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= 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 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -122,8 +131,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/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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 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.33.3 h1:6jCR3KuGvJSEwhaQrkHDGeIe2qCQ6nOUDNsPz7ZIotw=
github.com/ncruces/go-sqlite3 v0.30.4/go.mod h1:7WR20VSC5IZusKhUdiR9y1NsUqnZgqIYCmKKoMEYg68= 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 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g= github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@@ -141,8 +152,11 @@ 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 h1:sLILANWN76ja66/K4k/mBqJuCjDZaM67w+Ru6rEB0s0=
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo= 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.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.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.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 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA= github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
@@ -152,8 +166,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/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 h1:S3mO5e3HRRG0Ehw1jLUodYbAJK8TtqdOoNgqkC0D3uU=
go.senan.xyz/taglib v0.11.1/go.mod h1:qyTl978MnGeZ/ny4d/t0ErLXxysA+39X4+SNSCk56Zs= 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.30.1-0.20260423121427-fec4b6e433cb h1:hFxxWH6MlgcHZQv2BpkQ1KSp8MSbXMHtN338/HfSzdY=
go.senan.xyz/wrtag v0.20.0/go.mod h1:1h39mVCOu6mqeQGYVToCvMhegBRCpOt6FO7g69EvuSM= 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-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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -163,11 +177,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.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.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= 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.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A= 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.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I= golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww=
golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk= 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.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.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@@ -187,8 +201,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.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= 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.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= 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-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.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -196,8 +210,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.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.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.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= 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-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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -212,8 +226,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.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.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.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= 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/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-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -232,16 +246,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.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.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.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= 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-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.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.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.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= 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.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.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= 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= 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= 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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+3 -2
View File
@@ -80,8 +80,9 @@ func (a *ArtistInfoCache) Lookup(ctx context.Context, artist *db.Artist) (*db.Ar
} }
artistInfo.SetSimilarArtists(similar) artistInfo.SetSimilarArtists(similar)
url, _ := a.lastfmClient.StealArtistImage(info.URL) if url, _ := a.lastfmClient.StealArtistImage(info.URL); url != "" {
artistInfo.ImageURL = url artistInfo.ImageURL = url
}
topTracksResponse, err := a.lastfmClient.ArtistGetTopTracks(artist.Name) topTracksResponse, err := a.lastfmClient.ArtistGetTopTracks(artist.Name)
if err != nil { if err != nil {
+9 -5
View File
@@ -10,6 +10,7 @@ import (
"net/url" "net/url"
"sort" "sort"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/andybalholm/cascadia" "github.com/andybalholm/cascadia"
@@ -203,6 +204,9 @@ func (c *Client) StealArtistImage(artistURL string) (string, error) {
return "", fmt.Errorf("get artist url: %w", err) return "", fmt.Errorf("get artist url: %w", err)
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode/100 != 2 {
return "", fmt.Errorf("get artist url: %s", resp.Status)
}
node, err := html.Parse(resp.Body) node, err := html.Parse(resp.Body)
if err != nil { if err != nil {
@@ -340,12 +344,12 @@ func GetParamSignature(params url.Values, secret string) string {
paramKeys = append(paramKeys, k) paramKeys = append(paramKeys, k)
} }
sort.Strings(paramKeys) sort.Strings(paramKeys)
toHash := "" var toHash strings.Builder
for _, k := range paramKeys { for _, k := range paramKeys {
toHash += k toHash.WriteString(k)
toHash += params[k][0] toHash.WriteString(params[k][0])
} }
toHash += secret toHash.WriteString(secret)
hash := md5.Sum([]byte(toHash)) hash := md5.Sum([]byte(toHash.String()))
return hex.EncodeToString(hash[:]) return hex.EncodeToString(hash[:])
} }
+225
View File
@@ -0,0 +1,225 @@
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 ( import (
"bytes" "bytes"
"crypto/tls"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@@ -30,7 +31,17 @@ type Client struct {
} }
func NewClient() *Client { 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 { 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, "#") { if strings.HasPrefix(line, "#") {
continue continue
} }
if !filepath.IsAbs(line) {
line = filepath.Join(filepath.Dir(absPath), line)
}
playlist.Items = append(playlist.Items, line) playlist.Items = append(playlist.Items, line)
} }
@@ -186,6 +189,9 @@ func (s *Store) Write(relPath string, playlist *Playlist) error {
fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment)) fmt.Fprintln(file, encodeAttr(attrCommment, playlist.Comment))
fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic))) fmt.Fprintln(file, encodeAttr(attrIsPublic, fmt.Sprint(playlist.IsPublic)))
for _, line := range playlist.Items { for _, line := range playlist.Items {
if rel, err := filepath.Rel(filepath.Dir(absPath), line); err == nil {
line = rel
}
fmt.Fprintln(file, line) fmt.Fprintln(file, line)
} }
+3 -3
View File
@@ -32,9 +32,9 @@ Example comment
It has multiple lines 👍 It has multiple lines 👍
`, `,
Items: []string{ Items: []string{
"item 1.flac", "/music/item 1.flac",
"item 2.flac", "/music/item 2.flac",
"item 3.flac", "/music/item 3.flac",
}, },
IsPublic: true, IsPublic: true,
} }
+17 -9
View File
@@ -81,13 +81,17 @@ func (p *Podcasts) AddNewPodcast(rssURL string, feed *gofeed.Feed) (*db.Podcast,
if err != nil { if err != nil {
return nil, fmt.Errorf("find unique podcast dir: %w", err) return nil, fmt.Errorf("find unique podcast dir: %w", err)
} }
var author string
if feed.ITunesExt != nil {
author = feed.ITunesExt.Author
}
podcast := db.Podcast{ podcast := db.Podcast{
Description: feed.Description, Description: feed.Description,
ImageURL: "", ImageURL: "",
Title: feed.Title, Title: feed.Title,
URL: rssURL, URL: rssURL,
RootDir: rootDir, RootDir: rootDir,
Author: feed.ITunesExt.Author, Author: author,
} }
if feed.Image != nil { if feed.Image != nil {
podcast.ImageURL = feed.Image.URL 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 { func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *gofeed.Item) *db.PodcastEpisode {
author := podcast.Author
if item.ITunesExt != nil {
author = cmp.Or(item.ITunesExt.Author, podcast.Author)
}
return &db.PodcastEpisode{ return &db.PodcastEpisode{
PodcastID: podcast.ID, PodcastID: podcast.ID,
Description: item.Description, Description: item.Description,
@@ -235,7 +243,7 @@ func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *
PublishDate: item.PublishedParsed, PublishDate: item.PublishedParsed,
AudioURL: audio, AudioURL: audio,
Status: db.PodcastEpisodeStatusSkipped, Status: db.PodcastEpisodeStatusSkipped,
Artist: cmp.Or(item.ITunesExt.Author, podcast.Author), Artist: cmp.Or(author),
Album: podcast.Title, Album: podcast.Title,
} }
} }
@@ -508,6 +516,13 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
} }
defer resp.Body.Close() defer resp.Body.Close()
defer func() {
if err != nil {
podcastEpisode.Status = db.PodcastEpisodeStatusError
_ = p.db.Save(podcastEpisode).Error
}
}()
if resp.StatusCode/100 != 2 { if resp.StatusCode/100 != 2 {
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status) return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
} }
@@ -529,13 +544,6 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
} }
defer file.Close() defer file.Close()
defer func() {
if err != nil {
podcastEpisode.Status = db.PodcastEpisodeStatusError
_ = p.db.Save(podcastEpisode).Error
}
}()
if _, err := io.Copy(file, resp.Body); err != nil { if _, err := io.Copy(file, resp.Body); err != nil {
return fmt.Errorf("writing podcast episode: %w", err) return fmt.Errorf("writing podcast episode: %w", err)
} }
+69 -9
View File
@@ -188,6 +188,7 @@ func (s *Scanner) ExecuteWatch(ctx context.Context) error {
case event := <-watcher.Events: case event := <-watcher.Events:
if event.Op&(fsnotify.Remove) == fsnotify.Remove { if event.Op&(fsnotify.Remove) == fsnotify.Remove {
batchClean = true batchClean = true
batchT.Reset(batchInterval)
break break
} }
if event.Op&(fsnotify.Create|fsnotify.Write) == 0 { if event.Op&(fsnotify.Create|fsnotify.Write) == 0 {
@@ -371,20 +372,30 @@ func (s *Scanner) scanDir(st *State, absPath string) error {
return nil return nil
} }
// 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})
}
return s.db.Transaction(func(tx *db.DB) error { return s.db.Transaction(func(tx *db.DB) error {
var discTitles = map[int]string{} var discTitles = map[int]string{}
for _, t := range trackUpdates { for _, t := range tagData {
trprops, trags, err := s.tagReader.Read(t.absPath) if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, t.trprops, t.trags, t.basename, t.absPath); err != nil {
if err != nil {
return fmt.Errorf("read %q: %w: %w", t.basename, err, ErrReadingTags)
}
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, trprops, trags, t.basename, t.absPath); err != nil {
return fmt.Errorf("populate track %q: %w", t.basename, err) return fmt.Errorf("populate track %q: %w", t.basename, err)
} }
discNum := cmp.Or(tags.ParseInt(normtag.Get(trags, normtag.DiscNumber)), 1) discNum := cmp.Or(tags.ParseInt(normtag.Get(t.trags, normtag.DiscNumber)), 1)
discSubtitle := normtag.Get(trags, "DISCSUBTITLE") discSubtitle := normtag.Get(t.trags, "DISCSUBTITLE")
if _, exists := discTitles[discNum]; !exists && discSubtitle != "" { if _, exists := discTitles[discNum]; !exists && discSubtitle != "" {
discTitles[discNum] = 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) 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 // possible album level embedded covers come only from the first track
if i == 0 { if i == 0 {
if err := populateAlbumEmbeddedCover(tx, s.scanEmbeddedCover, album, track, trprops); err != nil { 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.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber)) track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID) track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
track.TagYear = tags.MustYear(trags)
track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain)) track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak)) track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
@@ -674,6 +694,46 @@ func populateAlbumArtists(tx *db.DB, album *db.Album, albumArtistIDs []int) erro
return nil 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 { 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 { if err := tx.Where("track_id=?", track.ID).Delete(db.TrackArtist{}).Error; err != nil {
return fmt.Errorf("delete old track artists: %w", err) 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) m := mockfs.New(t)
const toAdd = 1000 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) path := fmt.Sprintf("artist-%d/album-%d/track-%d.flac", i/6, i/3, i)
m.AddTrack(path) m.AddTrack(path)
m.SetTags(path, func(tags *mockfs.TagInfo) { 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) { func TestSymlinkedAlbum(t *testing.T) {
t.Parallel() t.Parallel()
m := mockfs.NewWithDirs(t, []string{"scan"}) m := mockfs.NewWithDirs(t, []string{"scan"})
+6 -1
View File
@@ -27,6 +27,7 @@ import (
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/handlerutil" "go.senan.xyz/gonic/handlerutil"
"go.senan.xyz/gonic/lastfm" "go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/podcast" "go.senan.xyz/gonic/podcast"
"go.senan.xyz/gonic/scanner" "go.senan.xyz/gonic/scanner"
"go.senan.xyz/gonic/server/ctrladmin/adminui" "go.senan.xyz/gonic/server/ctrladmin/adminui"
@@ -48,11 +49,13 @@ type Controller struct {
podcasts *podcast.Podcasts podcasts *podcast.Podcasts
lastfmClient *lastfm.Client lastfmClient *lastfm.Client
resolveProxyPath ProxyPathResolver resolveProxyPath ProxyPathResolver
ldapConfig ldap.Config
ldapStore ldap.LDAPStore
} }
type ProxyPathResolver func(in string) string 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) (*Controller, error) { 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) {
c := Controller{ c := Controller{
ServeMux: http.NewServeMux(), ServeMux: http.NewServeMux(),
@@ -62,6 +65,8 @@ func New(dbc *db.DB, sessDB *gormstore.Store, scanner *scanner.Scanner, podcasts
podcasts: podcasts, podcasts: podcasts,
lastfmClient: lastfmClient, lastfmClient: lastfmClient,
resolveProxyPath: resolveProxyPath, resolveProxyPath: resolveProxyPath,
ldapConfig: ldapConfig,
ldapStore: ldapStore,
} }
resp := respHandler(adminui.TemplatesFS, resolveProxyPath) resp := respHandler(adminui.TemplatesFS, resolveProxyPath)
+22 -2
View File
@@ -1,28 +1,48 @@
package ctrladmin package ctrladmin
import ( import (
"log"
"net/http" "net/http"
"github.com/gorilla/sessions" "github.com/gorilla/sessions"
"go.senan.xyz/gonic/ldap"
) )
func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) { func (c *Controller) ServeLoginDo(w http.ResponseWriter, r *http.Request) {
session := r.Context().Value(CtxSession).(*sessions.Session) session := r.Context().Value(CtxSession).(*sessions.Session)
username := r.FormValue("username") username := r.FormValue("username")
password := r.FormValue("password") password := r.FormValue("password")
user := c.dbc.GetUserByName(username)
if username == "" || password == "" { if username == "" || password == "" {
sessAddFlashW(session, []string{"please provide username and password"}) sessAddFlashW(session, []string{"please provide username and password"})
sessLogSave(session, w, r) sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther) http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return return
} }
user := c.dbc.GetUserByName(username)
if user == nil || password != user.Password { 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 {
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"}) sessAddFlashW(session, []string{"invalid username / password"})
sessLogSave(session, w, r) sessLogSave(session, w, r)
http.Redirect(w, r, r.Referer(), http.StatusSeeOther) http.Redirect(w, r, r.Referer(), http.StatusSeeOther)
return return
} }
user = c.dbc.GetUserByName(username)
// put the user name into the session. future endpoints after this one // put the user name into the session. future endpoints after this one
// are wrapped with WithUserSession() which will get the name from the // are wrapped with WithUserSession() which will get the name from the
// session and put the row into the request context // session and put the row into the request context
+53 -8
View File
@@ -10,6 +10,7 @@ import (
"io" "io"
"log" "log"
"net/http" "net/http"
"strings"
"time" "time"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
@@ -18,6 +19,7 @@ import (
"go.senan.xyz/gonic/infocache/artistinfocache" "go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/jukebox" "go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/lastfm" "go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/ldap"
"go.senan.xyz/gonic/playlist" "go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/podcast" "go.senan.xyz/gonic/podcast"
"go.senan.xyz/gonic/scanner" "go.senan.xyz/gonic/scanner"
@@ -73,7 +75,7 @@ type Controller struct {
resolveProxyPath ProxyPathResolver 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) (*Controller, error) { func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, defaultMusicPath string, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, tagReader tags.Reader, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config, ldapStore ldap.LDAPStore) (*Controller, error) {
c := Controller{ c := Controller{
ServeMux: http.NewServeMux(), ServeMux: http.NewServeMux(),
@@ -100,7 +102,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, defaultMus
chain := handlerutil.Chain( chain := handlerutil.Chain(
withParams, withParams,
withRequiredParams, withRequiredParams,
withUser(dbc), withUser(dbc, ldapConfig, ldapStore),
) )
chainRaw := handlerutil.Chain( chainRaw := handlerutil.Chain(
chain, chain,
@@ -231,39 +233,82 @@ func withRequiredParams(next http.Handler) http.Handler {
}) })
} }
func withUser(dbc *db.DB) handlerutil.Middleware { func withUser(dbc *db.DB, ldapConfig ldap.Config, ldapStore ldap.LDAPStore) handlerutil.Middleware {
return func(next http.Handler) http.Handler { return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
params := r.Context().Value(CtxParams).(params.Params) params := r.Context().Value(CtxParams).(params.Params)
// ignoring errors here, a middleware has already ensured they exist // ignoring errors here, a middleware has already ensured they exist
username, _ := params.Get("u") username, _ := params.Get("u")
password, _ := params.Get("p") passwordHex, _ := params.Get("p")
token, _ := params.Get("t") token, _ := params.Get("t")
salt, _ := params.Get("s") salt, _ := params.Get("s")
passwordAuth := token == "" && salt == "" passwordAuth := token == "" && salt == ""
tokenAuth := password == "" tokenAuth := passwordHex == ""
if tokenAuth == passwordAuth { if tokenAuth == passwordAuth {
_ = writeResp(w, r, spec.NewError(10, _ = writeResp(w, r, spec.NewError(10,
"please provide `t` and `s`, or just `p`")) "please provide `t` and `s`, or just `p`"))
return 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) user := dbc.GetUserByName(username)
if user == nil {
_ = writeResp(w, r, spec.NewError(40, if ldapConfig.IsSetup() {
"invalid username %q", username)) // 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 return
} }
log.Println("Authenticating using built-in ...")
if user == nil {
_ = writeResp(w, r, spec.NewError(40, "invalid password"))
return
}
var credsOk bool var credsOk bool
if tokenAuth { if tokenAuth {
credsOk = checkCredsToken(user.Password, token, salt) credsOk = checkCredsToken(user.Password, token, salt)
} else { } else {
credsOk = checkCredsBasic(user.Password, password) credsOk = checkCredsBasic(user.Password, password)
} }
if !credsOk { if !credsOk {
_ = writeResp(w, r, spec.NewError(40, "invalid password")) _ = writeResp(w, r, spec.NewError(40, "invalid password"))
return return
} }
withUser := context.WithValue(r.Context(), CtxUser, user) withUser := context.WithValue(r.Context(), CtxUser, user)
next.ServeHTTP(w, r.WithContext(withUser)) 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").
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Find(&track, "id=?", bookmark.EntryID). Find(&track, "id=?", bookmark.EntryID).
Error Error
if err != nil { if err != nil {
+19 -31
View File
@@ -320,56 +320,44 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
results := &spec.Starred{} results := &spec.Starred{}
// "artists" // "artists"
var artists []*db.Artist rootQ := c.dbc.
q := c.dbc. Select("id").
Select("artists.*, count(albums.id) album_count"). Model(&db.Album{}).
Joins("JOIN artist_stars ON artist_stars.artist_id=artists.id"). Where("parent_id IS NULL")
Where("artist_stars.user_id=?", user.ID).
Joins("JOIN artist_appearances ON artist_appearances.artist_id=artists.id").
Joins("JOIN albums ON albums.id=artist_appearances.album_id").
Order("artist_stars.star_date DESC").
Preload("ArtistStar", "user_id=?", user.ID).
Preload("ArtistRating", "user_id=?", user.ID).
Preload("Info").
Group("artists.id")
if m := getMusicFolder(c, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) rootQ = rootQ.Where("root_dir=?", m)
} }
var artists []*db.Album
q := c.dbc.
Where(`parent_id IN ?`, rootQ.SubQuery()).
Joins("JOIN album_stars ON albums.id=album_stars.album_id").
Where("album_stars.user_id=?", user.ID).
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID)
if err := q.Find(&artists).Error; err != nil { if err := q.Find(&artists).Error; err != nil {
return spec.NewError(0, "find artists: %v", err) return spec.NewError(0, "find artists: %v", err)
} }
for _, a := range artists { for _, a := range artists {
results.Artists = append(results.Artists, spec.NewArtistByTags(a)) results.Artists = append(results.Artists, spec.NewDirectoryByFolder(a, nil))
} }
// "albums" // "albums"
var albums []*db.Album var albums []*db.Album
q = c.dbc.Where("parent_id IS NOT NULL"). q = c.dbc.
Joins("JOIN album_stars ON albums.id=album_stars.album_id AND album_stars.user_id=?", user.ID) Joins("JOIN album_artists ON album_artists.album_id=albums.id").
q = q.Order("album_stars.star_date DESC") Joins("JOIN album_stars ON albums.id=album_stars.album_id").
Where("album_stars.user_id=?", user.ID).
q = q.
Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID) Preload("AlbumRating", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
q.
Select("albums.*, count(tracks.id) child_count, sum(tracks.length) duration").
Joins("LEFT JOIN tracks ON tracks.album_id=albums.id").
Group("albums.id").
Joins("JOIN album_artists ON album_artists.album_id=albums.id").
Preload("Parent").
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID)
if err := q.Find(&albums).Error; err != nil { if err := q.Find(&albums).Error; err != nil {
return spec.NewError(0, "find albums: %v", err) return spec.NewError(0, "find albums: %v", err)
} }
for _, a := range albums { for _, a := range albums {
results.Albums = append(results.Albums, spec.NewAlbumByFolder(a)) results.Albums = append(results.Albums, spec.NewTCAlbumByFolder(a))
} }
// tracks // tracks
+15 -7
View File
@@ -28,7 +28,6 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
q := c.dbc. q := c.dbc.
Select("*, count(album_artists.album_id) album_count"). Select("*, count(album_artists.album_id) album_count").
Joins("JOIN album_artists ON album_artists.artist_id=artists.id"). Joins("JOIN album_artists ON album_artists.artist_id=artists.id").
Joins("LEFT JOIN artist_stars ON artist_stars.artist_id=artists.id").
Preload("ArtistStar", "user_id=?", user.ID). Preload("ArtistStar", "user_id=?", user.ID).
Preload("ArtistRating", "user_id=?", user.ID). Preload("ArtistRating", "user_id=?", user.ID).
Preload("Info"). Preload("Info").
@@ -114,6 +113,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
return db. return db.
Order("tracks.tag_disc_number, tracks.tag_track_number"). Order("tracks.tag_disc_number, tracks.tag_track_number").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID) Preload("TrackRating", "user_id=?", user.ID)
}). }).
@@ -155,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.Joins("JOIN artists ON artists.id=album_artists.artist_id")
q = q.Order("artists.name") q = q.Order("artists.name")
case "alphabeticalByName": case "alphabeticalByName":
q = q.Order("tag_title") q = q.Order("albums.tag_title")
case "byYear": case "byYear":
y1, y2 := params.GetOrInt("fromYear", 1800), y1, y2 := params.GetOrInt("fromYear", 1800),
params.GetOrInt("toYear", 2200) params.GetOrInt("toYear", 2200)
// support some clients sending wrong order like DSub // support some clients sending wrong order like DSub
q = q.Where("tag_year BETWEEN ? AND ?", min(y1, y2), max(y1, y2)) q = q.Where("albums.tag_year BETWEEN ? AND ?", min(y1, y2), max(y1, y2))
q = q.Order("tag_year DESC") q = q.Order("albums.tag_year DESC")
case "byGenre": case "byGenre":
genre, _ := params.Get("genre") genre, _ := params.Get("genre")
q = q.Joins("JOIN album_genres ON album_genres.album_id=albums.id") 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.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": case "frequent":
user := r.Context().Value(CtxUser).(*db.User) 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.Joins("JOIN plays ON albums.id=plays.album_id AND plays.user_id=?", user.ID)
q = q.Order("plays.length DESC") q = q.Order("plays.length DESC")
case "newest": case "newest":
q = q.Order("created_at DESC") q = q.Order("albums.created_at DESC")
case "random": case "random":
q = q.Order(gorm.Expr("random()")) q = q.Order(gorm.Expr("random()"))
case "recent": case "recent":
@@ -180,7 +180,7 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
q = q.Order("plays.time DESC") q = q.Order("plays.time DESC")
case "starred": case "starred":
q = q.Joins("JOIN album_stars ON albums.id=album_stars.album_id AND album_stars.user_id=?", user.ID) 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": case "highest":
q = q.Joins("JOIN album_ratings ON album_ratings.album_id=albums.id AND album_ratings.user_id=?", user.ID) 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") q = q.Order("album_ratings.rating DESC")
@@ -301,6 +301,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Genres"). Preload("Genres").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID) Preload("TrackRating", "user_id=?", user.ID)
switch { switch {
@@ -453,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 album_genres WHERE genre_id=genres.id) album_count,
(SELECT count(1) FROM track_genres WHERE genre_id=genres.id) track_count`). (SELECT count(1) FROM track_genres WHERE genre_id=genres.id) track_count`).
Group("genres.id"). Group("genres.id").
Order("genres.name").
Find(&genres) Find(&genres)
sub := spec.NewResponse() sub := spec.NewResponse()
sub.Genres = &spec.Genres{ sub.Genres = &spec.Genres{
@@ -479,6 +481,7 @@ func (c *Controller) ServeGetSongsByGenre(r *http.Request) *spec.Response {
Preload("Album"). Preload("Album").
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Offset(params.GetOrInt("offset", 0)). Offset(params.GetOrInt("offset", 0)).
@@ -564,6 +567,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Preload("Album"). Preload("Album").
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID) Preload("TrackRating", "user_id=?", user.ID)
if m := getMusicFolder(c, params); m != "" { if m := getMusicFolder(c, params); m != "" {
@@ -637,6 +641,7 @@ func (c *Controller) ServeGetTopSongs(r *http.Request) *spec.Response {
Where("artists.id=?", artist.ID). Where("artists.id=?", artist.ID).
Preload("Album"). Preload("Album").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Group("tracks.id"). Group("tracks.id").
@@ -746,6 +751,7 @@ func getSimilarSongsFromTrack(c *Controller, id specid.ID, params params.Params,
Select("tracks.*"). Select("tracks.*").
Preload("Album"). Preload("Album").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames). Where("tracks.tag_title IN (?)", similarTrackNames).
@@ -799,6 +805,7 @@ func getSimilarSongsFromArtist(c *Controller, id specid.ID, params params.Params
err = c.dbc. err = c.dbc.
Preload("Album"). Preload("Album").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Joins("JOIN track_artists ON track_artists.track_id=tracks.id"). Joins("JOIN track_artists ON track_artists.track_id=tracks.id").
@@ -867,6 +874,7 @@ func getSimilarSongsFromAlbum(c *Controller, id specid.ID, params params.Params,
Select("tracks.*"). Select("tracks.*").
Preload("Album"). Preload("Album").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames). Where("tracks.tag_title IN (?)", similarTrackNames).
+4 -2
View File
@@ -100,7 +100,7 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
return spec.NewError(0, "error updating stats: %v", err) return spec.NewError(0, "error updating stats: %v", err)
} }
default: default:
return spec.NewError(10, "can't scrobble type %s", id.Type) return spec.NewError(0, "can't scrobble type %s", id.Type)
} }
if scrobbleTrack.Track == "" { if scrobbleTrack.Track == "" {
@@ -293,6 +293,7 @@ func (c *Controller) ServeGetSong(r *http.Request) *spec.Response {
Preload("Album"). Preload("Album").
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
First(&track). First(&track).
@@ -320,6 +321,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
Preload("Album"). Preload("Album").
Preload("Album.Artists"). Preload("Album.Artists").
Preload("Artists"). Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Joins("JOIN albums ON tracks.album_id=albums.id"). Joins("JOIN albums ON tracks.album_id=albums.id").
@@ -398,7 +400,7 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
switch id.Type { switch id.Type {
case specid.Track: case specid.Track:
var track db.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) return nil, fmt.Errorf("load track: %w", err)
} }
ret = append(ret, spec.NewTrackByTags(&track, track.Album)) ret = append(ret, spec.NewTrackByTags(&track, track.Album))
+12 -9
View File
@@ -14,11 +14,14 @@ import (
func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response { func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params) params := r.Context().Value(CtxParams).(params.Params)
isIncludeEpisodes := params.GetOrBool("includeEpisodes", true) isIncludeEpisodes := params.GetOrBool("includeEpisodes", true)
id, _ := params.GetID("id") id, err := params.GetID("id")
podcasts, err := c.podcasts.GetPodcastOrAll(id.Value, isIncludeEpisodes)
if err != nil { if err != nil {
return spec.NewError(10, "failed get podcast(s): %s", err) 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 := spec.NewResponse()
sub.Podcasts = &spec.Podcasts{} sub.Podcasts = &spec.Podcasts{}
for _, podcast := range podcasts { for _, podcast := range podcasts {
@@ -33,7 +36,7 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
count := params.GetOrInt("count", 10) count := params.GetOrInt("count", 10)
episodes, err := c.podcasts.GetNewestPodcastEpisodes(count) episodes, err := c.podcasts.GetNewestPodcastEpisodes(count)
if err != nil { if err != nil {
return spec.NewError(10, "failed get podcast(s): %s", err) return spec.NewError(0, "failed get podcast(s): %s", err)
} }
sub := spec.NewResponse() sub := spec.NewResponse()
sub.NewestPodcasts = &spec.NewestPodcasts{} 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") return spec.NewError(10, "please provide a valid podcast episode id")
} }
if err := c.podcasts.DownloadEpisode(id.Value); err != nil { if err := c.podcasts.DownloadEpisode(id.Value); err != nil {
return spec.NewError(10, "failed to download episode: %s", err) return spec.NewError(0, "failed to download episode: %s", err)
} }
return spec.NewResponse() return spec.NewResponse()
} }
@@ -65,10 +68,10 @@ func (c *Controller) ServeCreatePodcastChannel(r *http.Request) *spec.Response {
fp := gofeed.NewParser() fp := gofeed.NewParser()
feed, err := fp.ParseURL(rssURL) feed, err := fp.ParseURL(rssURL)
if err != nil { if err != nil {
return spec.NewError(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 { 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() return spec.NewResponse()
} }
@@ -79,7 +82,7 @@ func (c *Controller) ServeRefreshPodcasts(r *http.Request) *spec.Response {
return spec.NewError(50, "user not admin") return spec.NewError(50, "user not admin")
} }
if err := c.podcasts.RefreshPodcasts(); err != nil { if err := c.podcasts.RefreshPodcasts(); err != nil {
return spec.NewError(10, "failed to refresh feeds: %s", err) return spec.NewError(0, "failed to refresh feeds: %s", err)
} }
return spec.NewResponse() 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") return spec.NewError(10, "please provide a valid podcast id")
} }
if err := c.podcasts.DeletePodcast(id.Value); err != nil { if err := c.podcasts.DeletePodcast(id.Value); err != nil {
return spec.NewError(10, "failed to delete podcast: %s", err) return spec.NewError(70, "failed to delete podcast: %s", err)
} }
return spec.NewResponse() 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") return spec.NewError(10, "please provide a valid podcast episode id")
} }
if err := c.podcasts.DeletePodcastEpisode(id.Value); err != nil { if err := c.podcasts.DeletePodcastEpisode(id.Value); err != nil {
return spec.NewError(10, "failed to delete podcast: %s", err) return spec.NewError(70, "failed to delete podcast: %s", err)
} }
return spec.NewResponse() 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) reader, err := coverFor(c.dbc, c.artistInfoCache, c.playlistStore, c.tagReader, id)
if err != nil { 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() defer reader.Close()
@@ -107,7 +107,7 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos) resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos)
if err := imaging.Save(resized, cachePath); err != nil { if err := imaging.Save(resized, cachePath); err != nil {
return spec.NewError(10, "saving cover %q: %v", id, err) return spec.NewError(0, "saving cover %q: %v", id, err)
} }
serve(cachePath) serve(cachePath)
@@ -6,29 +6,21 @@ import (
"sort" "sort"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
) )
func NewAlbumByFolder(f *db.Album) *Album { func NewAlbumByFolder(f *db.Album) *Album {
artist := ""
var parentSID *specid.ID
if f.Parent != nil {
artist = f.Parent.RightPath
parentSID = f.ParentSID()
}
a := &Album{ a := &Album{
Artist: artist, Artist: f.Parent.RightPath,
ID: f.SID(), ID: f.SID(),
IsDir: true, IsDir: true,
ParentID: parentSID, ParentID: f.ParentSID(),
Album: f.RightPath, Album: f.RightPath,
Name: f.RightPath, Name: f.RightPath,
Title: f.RightPath, Title: f.RightPath,
TrackCount: f.ChildCount, TrackCount: f.ChildCount,
Duration: f.Duration, Duration: f.Duration,
Created: f.CreatedAt, Created: f.CreatedAt,
AverageRating: formatRating(f.AverageRating), AverageRating: f.AverageRating,
ReleaseTypes: []string{}, ReleaseTypes: []string{},
} }
if f.AlbumStar != nil { if f.AlbumStar != nil {
@@ -52,7 +44,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
Title: f.RightPath, Title: f.RightPath,
ParentID: f.ParentSID(), ParentID: f.ParentSID(),
CreatedAt: f.CreatedAt, CreatedAt: f.CreatedAt,
AverageRating: formatRating(f.AverageRating), AverageRating: f.AverageRating,
Year: f.TagYear, Year: f.TagYear,
} }
if f.AlbumStar != nil { if f.AlbumStar != nil {
@@ -87,13 +79,13 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
), ),
ParentID: parent.SID(), ParentID: parent.SID(),
Duration: t.Length, Duration: t.Length,
Year: parent.TagYear,
Bitrate: t.Bitrate, Bitrate: t.Bitrate,
IsDir: false, IsDir: false,
Type: "music", Type: "music",
MusicBrainzID: t.TagBrainzID, MusicBrainzID: t.TagBrainzID,
CreatedAt: t.CreatedAt, CreatedAt: t.CreatedAt,
AverageRating: formatRating(t.AverageRating), AverageRating: t.AverageRating,
Year: t.TagYear,
} }
if trCh.Title == "" { if trCh.Title == "" {
trCh.Title = t.Filename trCh.Title = t.Filename
@@ -178,7 +170,7 @@ func NewArtistByFolder(f *db.Album) *Artist {
ID: f.SID(), ID: f.SID(),
Name: f.RightPath, Name: f.RightPath,
AlbumCount: f.ChildCount, AlbumCount: f.ChildCount,
AverageRating: formatRating(f.AverageRating), AverageRating: f.AverageRating,
} }
if f.AlbumStar != nil { if f.AlbumStar != nil {
a.Starred = &f.AlbumStar.StarDate a.Starred = &f.AlbumStar.StarDate
@@ -200,7 +192,7 @@ func NewDirectoryByFolder(f *db.Album, children []*TrackChild) *Directory {
Name: f.RightPath, Name: f.RightPath,
Children: children, Children: children,
ParentID: f.ParentSID(), ParentID: f.ParentSID(),
AverageRating: formatRating(f.AverageRating), AverageRating: f.AverageRating,
} }
if f.AlbumStar != nil { if f.AlbumStar != nil {
d.Starred = &f.AlbumStar.StarDate d.Starred = &f.AlbumStar.StarDate
+31 -10
View File
@@ -3,7 +3,9 @@ package spec
import ( import (
"cmp" "cmp"
"path/filepath" "path/filepath"
"slices"
"sort" "sort"
"strings"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
) )
@@ -22,7 +24,7 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
Genres: []*GenreRef{}, Genres: []*GenreRef{},
Year: a.TagYear, Year: a.TagYear,
Tracks: []*TrackChild{}, Tracks: []*TrackChild{},
AverageRating: formatRating(a.AverageRating), AverageRating: a.AverageRating,
IsCompilation: a.TagCompilation, IsCompilation: a.TagCompilation,
ReleaseTypes: formatReleaseTypes(a.TagReleaseType), ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
DiscTitles: []*DiscTitle{}, DiscTitles: []*DiscTitle{},
@@ -97,9 +99,9 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
DiscNumber: t.TagDiscNumber, DiscNumber: t.TagDiscNumber,
Type: "music", Type: "music",
MusicBrainzID: t.TagBrainzID, MusicBrainzID: t.TagBrainzID,
Year: album.TagYear, AverageRating: t.AverageRating,
AverageRating: formatRating(t.AverageRating),
TranscodeMeta: TranscodeMeta{}, TranscodeMeta: TranscodeMeta{},
Year: t.TagYear,
} }
switch { switch {
@@ -118,12 +120,8 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
ret.UserRating = t.TrackRating.Rating ret.UserRating = t.TrackRating.Rating
} }
sort.Slice(t.Artists, func(i, j int) bool { slices.SortFunc(t.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.ID) })
return t.Artists[i].ID < t.Artists[j].ID slices.SortFunc(album.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.ID) })
})
sort.Slice(album.Artists, func(i, j int) bool {
return album.Artists[i].ID < album.Artists[j].ID
})
switch { switch {
case len(t.Artists) > 0: case len(t.Artists) > 0:
@@ -145,6 +143,29 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
for _, a := range album.Artists { for _, a := range album.Artists {
ret.AlbumArtists = append(ret.AlbumArtists, &ArtistRef{ID: a.SID(), Name: a.Name}) 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 { if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 {
ret.ReplayGain = &ReplayGain{ ret.ReplayGain = &ReplayGain{
TrackGain: t.ReplayGainTrackGain, TrackGain: t.ReplayGainTrackGain,
@@ -162,7 +183,7 @@ func NewArtistByTags(a *db.Artist) *Artist {
Name: a.Name, Name: a.Name,
AlbumCount: a.AlbumCount, AlbumCount: a.AlbumCount,
Albums: []*Album{}, Albums: []*Album{},
AverageRating: formatRating(a.AverageRating), AverageRating: a.AverageRating,
} }
if a.Info != nil && a.Info.ImageURL != "" { if a.Info != nil && a.Info.ImageURL != "" {
r.CoverID = a.SID() r.CoverID = a.SID()
+16 -14
View File
@@ -125,6 +125,12 @@ type GenreRef struct {
Name string `xml:"name,attr" json:"name"` 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 { type DiscTitle struct {
Disc int `xml:"disc,attr" json:"disc"` Disc int `xml:"disc,attr" json:"disc"`
Title string `xml:"title,attr" json:"title"` Title string `xml:"title,attr" json:"title"`
@@ -165,7 +171,7 @@ type Album struct {
// star / rating // star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,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 { type RandomTracks struct {
@@ -204,6 +210,9 @@ type TrackChild struct {
AlbumArtists []*ArtistRef `xml:"albumArtists" json:"albumArtists"` AlbumArtists []*ArtistRef `xml:"albumArtists" json:"albumArtists"`
AlbumDisplayArtist string `xml:"displayAlbumArtist,attr" json:"displayAlbumArtist"` 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"` Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"` ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"` CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
@@ -228,7 +237,7 @@ type TrackChild struct {
// star / rating // star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,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"` ReplayGain *ReplayGain `xml:"replayGain" json:"replayGain"`
@@ -249,7 +258,7 @@ type Artist struct {
// star / rating // star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,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 { type Indexes struct {
@@ -269,7 +278,7 @@ type Directory struct {
Name string `xml:"name,attr,omitempty" json:"name"` Name string `xml:"name,attr,omitempty" json:"name"`
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,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"` Children []*TrackChild `xml:"child,omitempty" json:"child,omitempty"`
} }
@@ -442,8 +451,8 @@ type Bookmark struct {
} }
type Starred struct { type Starred struct {
Artists []*Artist `xml:"artist,omitempty" json:"artist,omitempty"` Artists []*Directory `xml:"artist,omitempty" json:"artist,omitempty"`
Albums []*Album `xml:"album,omitempty" json:"album,omitempty"` Albums []*TrackChild `xml:"album,omitempty" json:"album,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"` Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
} }
@@ -473,7 +482,7 @@ type InternetRadioStation struct {
ID *specid.ID `xml:"id,attr" json:"id"` ID *specid.ID `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"` Name string `xml:"name,attr" json:"name"`
StreamURL string `xml:"streamUrl,attr" json:"streamUrl"` StreamURL string `xml:"streamUrl,attr" json:"streamUrl"`
HomepageURL string `xml:"homepageUrl,attr" json:"homepageUrl"` HomepageURL string `xml:"homePageUrl,attr" json:"homePageUrl"`
} }
type Lyrics struct { type Lyrics struct {
@@ -507,13 +516,6 @@ type OpenSubsonicExtension struct {
type OpenSubsonicExtensions []OpenSubsonicExtension type OpenSubsonicExtensions []OpenSubsonicExtension
func formatRating(rating float64) string {
if rating == 0 {
return ""
}
return fmt.Sprintf("%.2f", rating)
}
func formatExt(ext string) string { func formatExt(ext string) string {
return strings.TrimPrefix(ext, ".") return strings.TrimPrefix(ext, ".")
} }
+74 -74
View File
@@ -8,55 +8,17 @@
"albumList": { "albumList": {
"album": [ "album": [
{ {
"id": "al-11", "id": "al-8",
"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",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artist": "artist-1", "artist": "artist-1",
"artists": null, "artists": null,
"displayArtist": "", "displayArtist": "",
"title": "album-0", "title": "album-1",
"album": "album-0", "album": "album-1",
"parent": "al-6", "parent": "al-6",
"isDir": true, "isDir": true,
"coverArt": "al-7", "coverArt": "al-8",
"name": "album-0", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
@@ -84,17 +46,17 @@
"discTitles": null "discTitles": null
}, },
{ {
"id": "al-4", "id": "al-11",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artist": "artist-0", "artist": "artist-2",
"artists": null, "artists": null,
"displayArtist": "", "displayArtist": "",
"title": "album-1", "title": "album-0",
"album": "album-1", "album": "album-0",
"parent": "al-2", "parent": "al-10",
"isDir": true, "isDir": true,
"coverArt": "al-4", "coverArt": "al-11",
"name": "album-1", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
@@ -103,17 +65,17 @@
"discTitles": null "discTitles": null
}, },
{ {
"id": "al-8", "id": "al-7",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artist": "artist-1", "artist": "artist-1",
"artists": null, "artists": null,
"displayArtist": "", "displayArtist": "",
"title": "album-1", "title": "album-0",
"album": "album-1", "album": "album-0",
"parent": "al-6", "parent": "al-6",
"isDir": true, "isDir": true,
"coverArt": "al-8", "coverArt": "al-7",
"name": "album-1", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
@@ -140,25 +102,6 @@
"releaseTypes": [], "releaseTypes": [],
"discTitles": null "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", "id": "al-3",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
@@ -177,6 +120,63 @@
"isCompilation": false, "isCompilation": false,
"releaseTypes": [], "releaseTypes": [],
"discTitles": null "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": { "albumList2": {
"album": [ "album": [
{ {
"id": "al-12", "id": "al-8",
"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",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artistId": "ar-2", "artistId": "ar-2",
"artist": "artist-1", "artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1", "displayArtist": "artist-1",
"title": "album-2", "title": "album-1",
"album": "album-2", "album": "album-1",
"coverArt": "al-9", "coverArt": "al-8",
"name": "album-2", "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-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",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
@@ -134,16 +71,16 @@
"discTitles": [] "discTitles": []
}, },
{ {
"id": "al-8", "id": "al-3",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artistId": "ar-2", "artistId": "ar-1",
"artist": "artist-1", "artist": "artist-0",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-1", "displayArtist": "artist-0",
"title": "album-1", "title": "album-0",
"album": "album-1", "album": "album-0",
"coverArt": "al-8", "coverArt": "al-3",
"name": "album-1", "name": "album-0",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
@@ -155,15 +92,15 @@
"discTitles": [] "discTitles": []
}, },
{ {
"id": "al-4", "id": "al-12",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artistId": "ar-1", "artistId": "ar-3",
"artist": "artist-0", "artist": "artist-2",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-0", "displayArtist": "artist-2",
"title": "album-1", "title": "album-1",
"album": "album-1", "album": "album-1",
"coverArt": "al-4", "coverArt": "al-12",
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
@@ -195,6 +132,69 @@
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"], "releaseTypes": ["Album"],
"discTitles": [] "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", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -61,6 +63,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -89,6 +93,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -20,6 +20,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -48,6 +50,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -76,6 +80,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -17,6 +17,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-3", "coverArt": "al-3",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -34,6 +36,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-4", "coverArt": "al-4",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -51,6 +55,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-5", "coverArt": "al-5",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
+40
View File
@@ -17,6 +17,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -47,6 +49,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -77,6 +81,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -107,6 +113,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -137,6 +145,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -167,6 +177,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -197,6 +209,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -227,6 +241,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -257,6 +273,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": [{ "id": "ar-1", "name": "artist-0" }], "albumArtists": [{ "id": "ar-1", "name": "artist-0" }],
"displayAlbumArtist": "artist-0", "displayAlbumArtist": "artist-0",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -287,6 +305,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -317,6 +337,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -347,6 +369,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -377,6 +401,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -407,6 +433,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -437,6 +465,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -467,6 +497,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -497,6 +529,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -527,6 +561,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": [{ "id": "ar-2", "name": "artist-1" }], "albumArtists": [{ "id": "ar-2", "name": "artist-1" }],
"displayAlbumArtist": "artist-1", "displayAlbumArtist": "artist-1",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -557,6 +593,8 @@
"displayArtist": "artist-2", "displayArtist": "artist-2",
"albumArtists": [{ "id": "ar-3", "name": "artist-2" }], "albumArtists": [{ "id": "ar-3", "name": "artist-2" }],
"displayAlbumArtist": "artist-2", "displayAlbumArtist": "artist-2",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-11", "coverArt": "al-11",
@@ -587,6 +625,8 @@
"displayArtist": "artist-2", "displayArtist": "artist-2",
"albumArtists": [{ "id": "ar-3", "name": "artist-2" }], "albumArtists": [{ "id": "ar-3", "name": "artist-2" }],
"displayAlbumArtist": "artist-2", "displayAlbumArtist": "artist-2",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-11", "coverArt": "al-11",
+18
View File
@@ -14,6 +14,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-3", "coverArt": "al-3",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -31,6 +33,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-4", "coverArt": "al-4",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -48,6 +52,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-5", "coverArt": "al-5",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -65,6 +71,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-7", "coverArt": "al-7",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -82,6 +90,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-8", "coverArt": "al-8",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -99,6 +109,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-9", "coverArt": "al-9",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -116,6 +128,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-11", "coverArt": "al-11",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -133,6 +147,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-12", "coverArt": "al-12",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
@@ -150,6 +166,8 @@
"displayArtist": "", "displayArtist": "",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"coverArt": "al-13", "coverArt": "al-13",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"isDir": true, "isDir": true,
+40
View File
@@ -17,6 +17,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -45,6 +47,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -73,6 +77,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-3", "coverArt": "al-3",
@@ -101,6 +107,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -129,6 +137,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -157,6 +167,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-4", "coverArt": "al-4",
@@ -185,6 +197,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -213,6 +227,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -241,6 +257,8 @@
"displayArtist": "artist-0", "displayArtist": "artist-0",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-5", "coverArt": "al-5",
@@ -269,6 +287,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -297,6 +317,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -325,6 +347,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-7", "coverArt": "al-7",
@@ -353,6 +377,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -381,6 +407,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -409,6 +437,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-8", "coverArt": "al-8",
@@ -437,6 +467,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -465,6 +497,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -493,6 +527,8 @@
"displayArtist": "artist-1", "displayArtist": "artist-1",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-9", "coverArt": "al-9",
@@ -521,6 +557,8 @@
"displayArtist": "artist-2", "displayArtist": "artist-2",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-11", "coverArt": "al-11",
@@ -549,6 +587,8 @@
"displayArtist": "artist-2", "displayArtist": "artist-2",
"albumArtists": null, "albumArtists": null,
"displayAlbumArtist": "", "displayAlbumArtist": "",
"contributors": null,
"displayComposer": "",
"bitRate": 100, "bitRate": 100,
"contentType": "audio/flac", "contentType": "audio/flac",
"coverArt": "al-11", "coverArt": "al-11",
+12 -12
View File
@@ -33,6 +33,15 @@ const (
FallbackGenre = "Unknown Genre" 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 { func MustAlbum(p Tags) string {
if r := normtag.Get(p, normtag.Album); r != "" { if r := normtag.Get(p, normtag.Album); r != "" {
return r return r
@@ -48,10 +57,7 @@ func MustArtist(p Tags) string {
} }
func MustArtists(p Tags) []string { func MustArtists(p Tags) []string {
if r := normtag.Values(p, normtag.Artists); len(r) > 0 { if r := FirstValues(p, normtag.Artists, normtag.Artist); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.Artist); len(r) > 0 {
return r return r
} }
return []string{FallbackArtist} return []string{FallbackArtist}
@@ -65,10 +71,7 @@ func MustAlbumArtist(p Tags) string {
} }
func MustAlbumArtists(p Tags) []string { func MustAlbumArtists(p Tags) []string {
if r := normtag.Values(p, normtag.AlbumArtists); len(r) > 0 { if r := FirstValues(p, normtag.AlbumArtists, normtag.AlbumArtist); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.AlbumArtist); len(r) > 0 {
return r return r
} }
return []string{MustArtist(p)} return []string{MustArtist(p)}
@@ -82,10 +85,7 @@ func MustGenre(p Tags) string {
} }
func MustGenres(p Tags) []string { func MustGenres(p Tags) []string {
if r := normtag.Values(p, normtag.Genres); len(r) > 0 { if r := FirstValues(p, normtag.Genres, normtag.Genre); len(r) > 0 {
return r
}
if r := normtag.Values(p, normtag.Genre); len(r) > 0 {
return r return r
} }
return []string{FallbackGenre} return []string{FallbackGenre}