Merge branch 'master' into ldap_auth

This commit is contained in:
2026-02-14 03:58:30 +01:00
37 changed files with 1040 additions and 495 deletions

No files matched your search

+34
View File
@@ -1,5 +1,39 @@
# Changelog
### [0.20.1](https://www.github.com/sentriz/gonic/compare/v0.20.0...v0.20.1) (2026-01-30)
### Bug Fixes
* **playlist:** fix regression in playlist ID handling ([103a048](https://www.github.com/sentriz/gonic/commit/103a048e8497597be9b930ea9ef6d57ca755c0eb)), closes [#655](https://www.github.com/sentriz/gonic/issues/655)
## [0.20.0](https://www.github.com/sentriz/gonic/compare/v0.19.0...v0.20.0) (2026-01-22)
### Features
* add support for playlist cover art on filesystem ([aad729e](https://www.github.com/sentriz/gonic/commit/aad729e3ea79a0a542496802c815851d8e0f702a)), closes [#650](https://www.github.com/sentriz/gonic/issues/650)
* **ci:** bump golangci-lint ([79e3898](https://www.github.com/sentriz/gonic/commit/79e3898c3b47d4b3120265fa9aa6ddc22d2fbe7c))
* **db:** add an index on albums.created_at ([816e437](https://www.github.com/sentriz/gonic/commit/816e437d44b2feb40f82e8d589e3d17c0bf87b0c)), closes [#620](https://www.github.com/sentriz/gonic/issues/620)
* **gonic:** add log-db option to log queries ([75a0918](https://www.github.com/sentriz/gonic/commit/75a0918a7ef8bb6c9506de69dd4e6b6e8c35e567)), closes [#620](https://www.github.com/sentriz/gonic/issues/620)
* **scanner:** read multi valued release types ([c752a22](https://www.github.com/sentriz/gonic/commit/c752a22808527a034531418263662261fe83f9d4))
* **subsonic:** allow non admins to download podcast episodes ([c2ebe96](https://www.github.com/sentriz/gonic/commit/c2ebe9631300b54f60bf3fd12a4eae526a84d3de)), closes [#623](https://www.github.com/sentriz/gonic/issues/623)
* **subsonic:** implement getSimilarSongs for artists and albums ([#649](https://www.github.com/sentriz/gonic/issues/649)) ([db9aa2b](https://www.github.com/sentriz/gonic/commit/db9aa2b2e37903e8cce770d76bed6e568570599e))
* **subsonic:** return disc titles ([0377bfa](https://www.github.com/sentriz/gonic/commit/0377bfa696e7f5dc02497bd49b96cebeefd7ef2f))
* **taglib:** add `.ape` as a supported filetype ([82642eb](https://www.github.com/sentriz/gonic/commit/82642eb1ca4b9587fe1764bf7efe8bbb2cb28e42)), closes [#615](https://www.github.com/sentriz/gonic/issues/615)
### Bug Fixes
* **db:** enable WAL also for Wasm driver ([b67c1c1](https://www.github.com/sentriz/gonic/commit/b67c1c14d2b883f634f7aaecc0367a15ec7dab71)), closes [#620](https://www.github.com/sentriz/gonic/issues/620)
* **db:** use separate DSN for both drivers ([4696499](https://www.github.com/sentriz/gonic/commit/469649935e26ef279a4a805cd964d3b010aa8146))
* **gonic:** correct typo in command line help ([#640](https://www.github.com/sentriz/gonic/issues/640)) ([99e2ccf](https://www.github.com/sentriz/gonic/commit/99e2ccfb0f7ce038669fef2f9ff281da4174fee6))
* **podcast:** truncate filenames longer than 200 chars ([e12ab54](https://www.github.com/sentriz/gonic/commit/e12ab544c21f286ead3c84ead113be6658cef318)), closes [#624](https://www.github.com/sentriz/gonic/issues/624)
* **podcast:** validate response status code when fetching podcast audio ([2900ce5](https://www.github.com/sentriz/gonic/commit/2900ce51024e5dafdf23ca0c5a6280bd3bd48059)), closes [#639](https://www.github.com/sentriz/gonic/issues/639)
* **scanner:** clear metadata of albums who no longer have tracks ([ca59601](https://www.github.com/sentriz/gonic/commit/ca59601484371d41564f84e33af62642df6de3e5)), closes [#638](https://www.github.com/sentriz/gonic/issues/638)
* **scanner:** reset embedded cover for album when toggling `scan-embedded-cover` ([ea5e625](https://www.github.com/sentriz/gonic/commit/ea5e6252a175c6dea688c2910f7cb270b60b1c27)), closes [#619](https://www.github.com/sentriz/gonic/issues/619)
* **subsonic:** correct spec typos ([04ff7f3](https://www.github.com/sentriz/gonic/commit/04ff7f3c331445abbbcf6a64465aa523c1775386)), closes [#653](https://www.github.com/sentriz/gonic/issues/653)
## [0.19.0](https://www.github.com/sentriz/gonic/compare/v0.18.0...v0.19.0) (2025-10-11)
This release uses WebAssesmby for the [tagging](https://github.com/sentriz/go-taglib) and [database](https://github.com/ncruces/go-sqlite3) backends. This means that gonic no longer requires Cgo or external dependencies to build. As a result, static binaries will be available in the releases page, and Docker images for more architectures. Performance of scanning and tagging should also be improved.
+7
View File
@@ -340,6 +340,7 @@ type Album struct {
AlbumRating *AlbumRating
AverageRating float64 `sql:"default: null"`
Play *Play
DiscTitles []*AlbumDiscTitle
}
func (a *Album) SID() *specid.ID {
@@ -417,6 +418,12 @@ type AlbumGenre struct {
GenreID int `gorm:"not null; unique_index:idx_album_id_genre_id" sql:"default: null; type:int REFERENCES genres(id) ON DELETE CASCADE"`
}
type AlbumDiscTitle struct {
AlbumID int `gorm:"not null; unique_index:idx_album_disc" sql:"type:int REFERENCES albums(id) ON DELETE CASCADE"`
DiscNumber int `gorm:"not null; unique_index:idx_album_disc"`
Title string `gorm:"not null"`
}
type AlbumStar struct {
UserID int `gorm:"primary_key; not null" sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"`
AlbumID int `gorm:"primary_key; not null" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
+5
View File
@@ -82,6 +82,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
}
return gormigrate.
@@ -874,3 +875,7 @@ func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
CREATE INDEX idx_albums_created_at ON "albums" (created_at);
`).Error
}
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(AlbumDiscTitle{}).Error
}
+14 -12
View File
@@ -20,21 +20,21 @@ require (
github.com/gorilla/sessions v1.4.0
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
github.com/josephburnett/jd v1.9.2
github.com/mattn/go-sqlite3 v1.14.32
github.com/mattn/go-sqlite3 v1.14.33
github.com/microcosm-cc/bluemonday v1.0.27
github.com/mitchellh/mapstructure v1.5.0
github.com/mmcdole/gofeed v1.3.0
github.com/ncruces/go-sqlite3 v0.30.3
github.com/ncruces/go-sqlite3 v0.30.4
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
github.com/stretchr/testify v1.11.1
go.senan.xyz/flagconf v0.1.10
go.senan.xyz/flagconf v0.1.11
go.senan.xyz/taglib v0.11.1
go.senan.xyz/wrtag v0.19.0
golang.org/x/net v0.47.0
golang.org/x/sync v0.18.0
go.senan.xyz/wrtag v0.20.0
golang.org/x/net v0.49.0
golang.org/x/sync v0.19.0
gopkg.in/gormigrate.v1 v1.6.0
)
@@ -46,7 +46,7 @@ require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
github.com/go-openapi/jsonpointer v0.22.3 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/css v1.0.1 // indirect
@@ -55,6 +55,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
@@ -63,11 +64,12 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/julianday v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tetratelabs/wazero v1.10.1 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/image v0.33.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
github.com/tetratelabs/wazero v1.11.0 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/image v0.35.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
+34 -27
View File
@@ -45,8 +45,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
github.com/go-openapi/jsonpointer v0.22.3 h1:dKMwfV4fmt6Ah90zloTbUKWMD+0he+12XYAsPotrkn8=
github.com/go-openapi/jsonpointer v0.22.3/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo=
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
@@ -99,6 +99,12 @@ github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
@@ -106,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-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.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0=
github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
@@ -125,8 +131,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ncruces/go-sqlite3 v0.30.3 h1:X/CgWW9GzmIAkEPrifhKqf0cC15DuOVxAJaHFTTAURQ=
github.com/ncruces/go-sqlite3 v0.30.3/go.mod h1:AxKu9sRxkludimFocbktlY6LiYSkxiI5gTA8r+os/Nw=
github.com/ncruces/go-sqlite3 v0.30.4 h1:j9hEoOL7f9ZoXl8uqXVniaq1VNwlWAXihZbTvhqPPjA=
github.com/ncruces/go-sqlite3 v0.30.4/go.mod h1:7WR20VSC5IZusKhUdiR9y1NsUqnZgqIYCmKKoMEYg68=
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@@ -151,15 +157,15 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tetratelabs/wazero v1.10.1 h1:2DugeJf6VVk58KTPszlNfeeN8AhhpwcZqkJj2wwFuH8=
github.com/tetratelabs/wazero v1.10.1/go.mod h1:DRm5twOQ5Gr1AoEdSi0CLjDQF1J9ZAuyqFIjl1KKfQU=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.senan.xyz/flagconf v0.1.10 h1:IGWaX9z4uh03xopYJSwpw1u0KrwRWs8vDmFjaULFH3U=
go.senan.xyz/flagconf v0.1.10/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
go.senan.xyz/flagconf v0.1.11 h1:ApA9DpoSrfVQlLt8spKJC3fOT7oTEZ2/MmBGMnb9mt4=
go.senan.xyz/flagconf v0.1.11/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
go.senan.xyz/taglib v0.11.1 h1:S3mO5e3HRRG0Ehw1jLUodYbAJK8TtqdOoNgqkC0D3uU=
go.senan.xyz/taglib v0.11.1/go.mod h1:qyTl978MnGeZ/ny4d/t0ErLXxysA+39X4+SNSCk56Zs=
go.senan.xyz/wrtag v0.19.0 h1:/bWIbY5UVwmPPEn6FI3GQSEd5EZvOe1mECf2UriKYQU=
go.senan.xyz/wrtag v0.19.0/go.mod h1:eaHgozP2mK2OG1AtEklet8uk9fX26w835BF4A+MhtEA=
go.senan.xyz/wrtag v0.20.0 h1:Q57ITuEl3TuRuOIkerCL+y4O3WrCqC1lUrewHtluUjc=
go.senan.xyz/wrtag v0.20.0/go.mod h1:1h39mVCOu6mqeQGYVToCvMhegBRCpOt6FO7g69EvuSM=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -169,11 +175,11 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I=
golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@@ -193,8 +199,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -202,8 +208,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -218,8 +224,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -238,20 +244,21 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA=
golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/gormigrate.v1 v1.6.0 h1:XpYM6RHQPmzwY7Uyu+t+xxMXc86JYFJn4nEc9HzQjsI=
gopkg.in/gormigrate.v1 v1.6.0/go.mod h1:Lf00lQrHqfSYWiTtPcyQabsDdM6ejZaMgV0OU6JMSlw=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
+4
View File
@@ -53,6 +53,10 @@ func NewStore(basePath string) (*Store, error) {
}, nil
}
func (s *Store) BasePath() string {
return s.basePath
}
// List finds playlist items in s.basePath.
// the expected format is <base path>/<user id>/**/<playlist name>.m3u
func (s *Store) List() ([]string, error) {
+4
View File
@@ -508,6 +508,10 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
}
defer resp.Body.Close()
if resp.StatusCode/100 != 2 {
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
}
filename, err := getPodcastEpisodeFilename(podcast, podcastEpisode, resp.Header)
if err != nil {
return fmt.Errorf("get podcast episode filename: %w", err)
+46 -7
View File
@@ -2,6 +2,7 @@
package scanner
import (
"cmp"
"context"
"errors"
"fmt"
@@ -287,6 +288,11 @@ func (s *Scanner) scanDir(st *State, absPath string) error {
continue
}
// skip macOS ._ resource fork files
if strings.HasPrefix(item.Name(), "._") {
continue
}
if coverparse.IsCover(item.Name()) {
cover = coverparse.BestBetween(cover, item.Name())
continue
@@ -366,21 +372,33 @@ func (s *Scanner) scanDir(st *State, absPath string) error {
}
return s.db.Transaction(func(tx *db.DB) error {
var discTitles = map[int]string{}
for _, t := range trackUpdates {
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, t.basename, t.absPath); err != nil {
trprops, trags, err := s.tagReader.Read(t.absPath)
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)
}
discNum := cmp.Or(tags.ParseInt(normtag.Get(trags, normtag.DiscNumber)), 1)
discSubtitle := normtag.Get(trags, "DISCSUBTITLE")
if _, exists := discTitles[discNum]; !exists && discSubtitle != "" {
discTitles[discNum] = discSubtitle
}
}
if err := populateAlbumDiscTitles(tx, &album, discTitles); err != nil {
return fmt.Errorf("populate disc titles: %w", err)
}
return nil
})
}
func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db.Album, track *db.Track, timeSpec times.Timespec, basename, absPath string) error {
trprops, trags, err := s.tagReader.Read(absPath)
if err != nil {
return fmt.Errorf("%w: %w", err, ErrReadingTags)
}
func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db.Album, track *db.Track, timeSpec times.Timespec, trprops tags.Properties, trags tags.Tags, basename, absPath string) error {
genreNames := ParseMulti(s.multiValueSettings[Genre], tags.MustGenres(trags), tags.MustGenre(trags))
genreIDs, err := populateGenres(tx, genreNames)
if err != nil {
@@ -627,6 +645,24 @@ func populateAlbumGenres(tx *db.DB, album *db.Album, genreIDs []int) error {
return nil
}
func populateAlbumDiscTitles(tx *db.DB, album *db.Album, discTitles map[int]string) error {
if err := tx.Where("album_id=?", album.ID).Delete(db.AlbumDiscTitle{}).Error; err != nil {
return fmt.Errorf("delete old album disc titles: %w", err)
}
for discNum, title := range discTitles {
discTitle := db.AlbumDiscTitle{
AlbumID: album.ID,
DiscNumber: discNum,
Title: title,
}
if err := tx.Create(&discTitle).Error; err != nil {
return fmt.Errorf("create disc title: %w", err)
}
}
return nil
}
func populateAlbumArtists(tx *db.DB, album *db.Album, albumArtistIDs []int) error {
if err := tx.Where("album_id=?", album.ID).Delete(db.AlbumArtist{}).Error; err != nil {
return fmt.Errorf("delete old album artists: %w", err)
@@ -733,6 +769,9 @@ func (s *Scanner) cleanAlbumMetadata() error {
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.ArtistAppearances{}).Error; err != nil {
return err
}
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.AlbumDiscTitle{}).Error; err != nil {
return err
}
q := s.db.
Model(&db.Album{}).
+2
View File
@@ -42,6 +42,8 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
var track db.Track
err := c.dbc.
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Find(&track, "id=?", bookmark.EntryID).
Error
if err != nil {
+143 -39
View File
@@ -15,6 +15,7 @@ import (
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/handlerutil"
"go.senan.xyz/gonic/lastfm"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
@@ -107,6 +108,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
Joins("LEFT JOIN tracks ON tracks.album_id=albums.id").
Preload("Artists").
Preload("Genres").
Preload("DiscTitles").
Preload("Tracks", func(db *gorm.DB) *gorm.DB {
return db.
Order("tracks.tag_disc_number, tracks.tag_track_number").
@@ -199,6 +201,7 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
Limit(params.GetOrInt("size", 10)).
Preload("Artists").
Preload("Genres").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID).
@@ -266,6 +269,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
q = c.dbc.
Preload("Artists").
Preload("Genres").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID)
@@ -536,6 +540,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Where("album_stars.user_id=?", user.ID).
Order("album_stars.star_date DESC").
Preload("Artists").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID)
@@ -659,28 +664,75 @@ func (c *Controller) ServeGetSimilarSongs(r *http.Request) *spec.Response {
user := r.Context().Value(CtxUser).(*db.User)
count := params.GetOrInt("count", 10)
id, err := params.GetID("id")
if err != nil || id.Type != specid.Track {
return spec.NewError(10, "please provide an track `id` parameter")
if err != nil {
return spec.NewError(10, "please provide an `id` parameter")
}
var tracks []*spec.TrackChild
var sub *spec.Response
switch id.Type {
case specid.Track:
tracks, sub = getSimilarSongsFromTrack(c, id, params, user, count)
case specid.Album:
tracks, sub = getSimilarSongsFromAlbum(c, id, params, user, count)
case specid.Artist:
tracks, sub = getSimilarSongsFromArtist(c, id, params, user, count)
default:
return spec.NewError(10, "please provide a artist, album or track `id` parameter")
}
if sub != nil {
return sub
}
sub = spec.NewResponse()
sub.SimilarSongs = &spec.SimilarSongs{
Tracks: tracks,
}
return sub
}
func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
user := r.Context().Value(CtxUser).(*db.User)
count := params.GetOrInt("count", 10)
id, err := params.GetID("id")
if err != nil || id.Type != specid.Artist {
return spec.NewError(10, "please provide an artist `id` parameter")
}
tracks, sub := getSimilarSongsFromArtist(c, id, params, user, count)
if sub != nil {
return sub
}
sub = spec.NewResponse()
sub.SimilarSongsTwo = &spec.SimilarSongsTwo{
Tracks: tracks,
}
return sub
}
func getSimilarSongsFromTrack(c *Controller, id specid.ID, params params.Params, user *db.User, count int) ([]*spec.TrackChild, *spec.Response) {
var track db.Track
err = c.dbc.
err := c.dbc.
Preload("Album").
Where("id=?", id.Value).
First(&track).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "couldn't find a track with that id")
return nil, spec.NewError(70, "couldn't find a track with that id")
}
similarTracks, err := c.lastFMClient.TrackGetSimilarTracks(track.TagTrackArtist, track.TagTitle)
if err != nil {
log.Printf("error fetching similar songs from lastfm: %v", err)
return spec.NewResponse()
return nil, spec.NewResponse()
}
if len(similarTracks.Tracks) == 0 {
return spec.NewError(70, "no similar songs found for track: %v", track.TagTitle)
return nil, spec.NewError(70, "no similar songs found for track: %v", track.TagTitle)
}
similarTrackNames := make([]string, len(similarTracks.Tracks))
@@ -701,51 +753,40 @@ func (c *Controller) ServeGetSimilarSongs(r *http.Request) *spec.Response {
Find(&tracks).
Error
if err != nil {
return spec.NewError(0, "error finding tracks: %v", err)
return nil, spec.NewError(0, "error finding tracks: %v", err)
}
if len(tracks) == 0 {
return spec.NewError(70, "no similar song could be match with collection in database: %v", track.TagTitle)
}
sub := spec.NewResponse()
sub.SimilarSongs = &spec.SimilarSongs{
Tracks: make([]*spec.TrackChild, len(tracks)),
return nil, spec.NewError(70, "no similar song could be match with collection in database: %v", track.TagTitle)
}
trackChildren := make([]*spec.TrackChild, len(tracks))
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for i, track := range tracks {
sub.SimilarSongs.Tracks[i] = spec.NewTrackByTags(track, track.Album)
sub.SimilarSongs.Tracks[i].TranscodeMeta = transcodeMeta
trackChildren[i] = spec.NewTrackByTags(track, track.Album)
trackChildren[i].TranscodeMeta = transcodeMeta
}
return sub
return trackChildren, nil
}
func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
user := r.Context().Value(CtxUser).(*db.User)
count := params.GetOrInt("count", 10)
id, err := params.GetID("id")
if err != nil || id.Type != specid.Artist {
return spec.NewError(10, "please provide an artist `id` parameter")
}
func getSimilarSongsFromArtist(c *Controller, id specid.ID, params params.Params, user *db.User, count int) ([]*spec.TrackChild, *spec.Response) {
var artist db.Artist
err = c.dbc.
err := c.dbc.
Where("id=?", id.Value).
First(&artist).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "artist with id %q not found", id)
return nil, spec.NewError(70, "artist with id %q not found", id)
}
similarArtists, err := c.lastFMClient.ArtistGetSimilar(artist.Name)
if err != nil {
log.Printf("error fetching artist info from lastfm: %v", err)
return spec.NewResponse()
return nil, spec.NewResponse()
}
if len(similarArtists.Artists) == 0 {
return spec.NewError(0, "no similar artist found for: %v", artist.Name)
return nil, spec.NewError(0, "no similar artist found for: %v", artist.Name)
}
artistNames := make([]string, len(similarArtists.Artists))
@@ -768,23 +809,86 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
Find(&tracks).
Error
if err != nil {
return spec.NewError(0, "error finding tracks: %v", err)
return nil, spec.NewError(0, "error finding tracks: %v", err)
}
if len(tracks) == 0 {
return spec.NewError(70, "no similar song could be match with collection in database: %v", artist.Name)
}
sub := spec.NewResponse()
sub.SimilarSongsTwo = &spec.SimilarSongsTwo{
Tracks: make([]*spec.TrackChild, len(tracks)),
return nil, spec.NewError(70, "no similar song could be match with collection in database: %v", artist.Name)
}
trackChildren := make([]*spec.TrackChild, len(tracks))
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for i, track := range tracks {
sub.SimilarSongsTwo.Tracks[i] = spec.NewTrackByTags(track, track.Album)
sub.SimilarSongsTwo.Tracks[i].TranscodeMeta = transcodeMeta
trackChildren[i] = spec.NewTrackByTags(track, track.Album)
trackChildren[i].TranscodeMeta = transcodeMeta
}
return sub
return trackChildren, nil
}
func getSimilarSongsFromAlbum(c *Controller, id specid.ID, params params.Params, user *db.User, count int) ([]*spec.TrackChild, *spec.Response) {
var album db.Album
err := c.dbc.
Preload("Tracks").
Where("id=?", id.Value).
First(&album).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, spec.NewError(70, "couldn't find an album with that id")
}
var similarTracks lastfm.SimilarTracks
for _, albumTrack := range album.Tracks {
similarTracks, err = c.lastFMClient.TrackGetSimilarTracks(albumTrack.TagTrackArtist, albumTrack.TagTitle)
if err != nil {
log.Printf("error fetching similar songs from lastfm: %v", err)
continue
}
if len(similarTracks.Tracks) == 0 {
log.Printf("no similar songs found for track: %v", albumTrack.TagTitle)
continue
}
break
}
if len(similarTracks.Tracks) == 0 {
return nil, spec.NewError(0, "no similar songs found for album: %v", album.TagTitle)
}
similarTrackNames := make([]string, len(similarTracks.Tracks))
for i, t := range similarTracks.Tracks {
similarTrackNames[i] = t.Name
}
var tracks []*db.Track
err = c.dbc.
Select("tracks.*").
Preload("Album").
Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames).
Order(gorm.Expr("random()")).
Limit(count).
Find(&tracks).
Error
if err != nil {
return nil, spec.NewError(0, "error finding tracks: %v", err)
}
if len(tracks) == 0 {
return nil, spec.NewError(70, "no similar songs could be matched with collection in database: %v", album.TagTitle)
}
trackChildren := make([]*spec.TrackChild, len(tracks))
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for i, track := range tracks {
trackChildren[i] = spec.NewTrackByTags(track, track.Album)
trackChildren[i].TranscodeMeta = transcodeMeta
}
return trackChildren, nil
}
func starIDsOfType(p params.Params, typ specid.IDT) []int {
+20 -8
View File
@@ -391,17 +391,29 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
return nil, fmt.Errorf("get playlist: %w", err)
}
for _, path := range playlist {
file, err := specidpaths.Lookup(c.dbc, MusicPaths(c.musicPaths), c.podcastsPath, path)
id, err := specidpaths.Lookup(c.dbc, MusicPaths(c.musicPaths), c.podcastsPath, path)
if err != nil {
return nil, fmt.Errorf("fetch track: %w", err)
}
switch f := file.(type) {
case *db.Track:
ret = append(ret, spec.NewTrackByTags(f, f.Album))
case *db.InternetRadioStation:
ret = append(ret, spec.NewTCInternetRadioStation(f))
case *db.PodcastEpisode:
ret = append(ret, spec.NewTCPodcastEpisode(f))
switch id.Type {
case specid.Track:
var track db.Track
if err := c.dbc.Where("id=?", id.Value).Preload("Album").Preload("Album.Artists").Preload("Artists").Find(&track).Error; err != nil {
return nil, fmt.Errorf("load track: %w", err)
}
ret = append(ret, spec.NewTrackByTags(&track, track.Album))
case specid.InternetRadioStation:
var irs db.InternetRadioStation
if err := c.dbc.Where("id=?", id.Value).Find(&irs).Error; err != nil {
return nil, fmt.Errorf("load internet radio station: %w", err)
}
ret = append(ret, spec.NewTCInternetRadioStation(&irs))
case specid.PodcastEpisode:
var pe db.PodcastEpisode
if err := c.dbc.Preload("Podcast").Where("id=?", id.Value).Find(&pe).Error; err != nil {
return nil, fmt.Errorf("load podcast episode: %w", err)
}
ret = append(ret, spec.NewTCPodcastEpisode(&pe))
default:
return nil, fmt.Errorf("%q: %w", path, errUnknownPlaylistEntry)
}
+23 -14
View File
@@ -39,7 +39,7 @@ func (c *Controller) ServeGetPlaylists(r *http.Request) *spec.Response {
continue
}
playlistID := playlistIDEncode(path)
rendered, err := playlistRender(c, params, playlistID, playlist, false)
rendered, err := playlistRender(c, params, playlist, playlistID, false)
if err != nil {
return spec.NewError(0, "error rendering playlist %q: %v", path, err)
}
@@ -50,7 +50,7 @@ func (c *Controller) ServeGetPlaylists(r *http.Request) *spec.Response {
func (c *Controller) ServeGetPlaylist(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
playlistID, err := params.GetFirst("id", "playlistId")
playlistID, err := params.GetFirstID("id", "playlistId")
if err != nil {
return spec.NewError(10, "please provide an `id` parameter")
}
@@ -59,7 +59,7 @@ func (c *Controller) ServeGetPlaylist(r *http.Request) *spec.Response {
return spec.NewError(70, "playlist with id %s not found", playlistID)
}
sub := spec.NewResponse()
rendered, err := playlistRender(c, params, playlistID, playlist, true)
rendered, err := playlistRender(c, params, playlist, playlistID, true)
if err != nil {
return spec.NewError(0, "error rendering playlist: %v", err)
}
@@ -71,7 +71,7 @@ func (c *Controller) ServeCreateOrUpdatePlaylist(r *http.Request) *spec.Response
user := r.Context().Value(CtxUser).(*db.User)
params := r.Context().Value(CtxParams).(params.Params)
playlistID := params.GetFirstOr( /* default */ "", "id", "playlistId")
playlistID, _ := params.GetFirstID("id", "playlistId")
playlistPath := playlistIDDecode(playlistID)
var playlist playlistp.Playlist
@@ -112,7 +112,7 @@ func (c *Controller) ServeCreateOrUpdatePlaylist(r *http.Request) *spec.Response
}
sub := spec.NewResponse()
rendered, err := playlistRender(c, params, playlistID, &playlist, true)
rendered, err := playlistRender(c, params, &playlist, playlistID, true)
if err != nil {
return spec.NewError(0, "error rendering playlist: %v", err)
}
@@ -124,7 +124,10 @@ func (c *Controller) ServeUpdatePlaylist(r *http.Request) *spec.Response {
user := r.Context().Value(CtxUser).(*db.User)
params := r.Context().Value(CtxParams).(params.Params)
playlistID := params.GetFirstOr( /* default */ "", "id", "playlistId")
playlistID, err := params.GetFirstID("id", "playlistId")
if err != nil {
return spec.NewError(10, "please provide an `id` or `playlistId` parameter")
}
playlistPath := playlistIDDecode(playlistID)
playlist, err := c.playlistStore.Read(playlistPath)
if err != nil {
@@ -173,23 +176,29 @@ func (c *Controller) ServeUpdatePlaylist(r *http.Request) *spec.Response {
func (c *Controller) ServeDeletePlaylist(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
playlistID := params.GetFirstOr( /* default */ "", "id", "playlistId")
playlistID, err := params.GetFirstID("id", "playlistId")
if err != nil {
return spec.NewError(10, "please provide an `id` or `playlistId` parameter")
}
if err := c.playlistStore.Delete(playlistIDDecode(playlistID)); err != nil {
return spec.NewError(0, "delete playlist: %v", err)
}
return spec.NewResponse()
}
func playlistIDEncode(path string) string {
return base64.URLEncoding.EncodeToString([]byte(path))
func playlistIDEncode(path string) specid.ID {
return specid.ID{
Type: specid.Playlist,
StringValue: base64.URLEncoding.EncodeToString([]byte(path)),
}
}
func playlistIDDecode(id string) string {
path, _ := base64.URLEncoding.DecodeString(id)
func playlistIDDecode(id specid.ID) string {
path, _ := base64.URLEncoding.DecodeString(id.StringValue)
return string(path)
}
func playlistRender(c *Controller, params params.Params, playlistID string, playlist *playlistp.Playlist, withItems bool) (*spec.Playlist, error) {
func playlistRender(c *Controller, params params.Params, playlist *playlistp.Playlist, playlistID specid.ID, withItems bool) (*spec.Playlist, error) {
user := &db.User{}
if err := c.dbc.Where("id=?", playlist.UserID).Find(user).Error; err != nil {
return nil, fmt.Errorf("find user by id: %w", err)
@@ -212,14 +221,14 @@ func playlistRender(c *Controller, params params.Params, playlistID string, play
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for _, path := range playlist.Items {
file, err := specidpaths.Lookup(c.dbc, MusicPaths(c.musicPaths), c.podcastsPath, path)
id, err := specidpaths.Lookup(c.dbc, MusicPaths(c.musicPaths), c.podcastsPath, path)
if err != nil {
log.Printf("error looking up path %q: %s", path, err)
continue
}
var trch *spec.TrackChild
switch id := file.SID(); id.Type {
switch id.Type {
case specid.Track:
var track db.Track
if err := c.dbc.Where("id=?", id.Value).Preload("Album").Preload("Album.Artists").Preload("Artists").Preload("TrackStar", "user_id=?", user.ID).Preload("TrackRating", "user_id=?", user.ID).Find(&track).Error; errors.Is(err, gorm.ErrRecordNotFound) {
+36 -2
View File
@@ -11,13 +11,16 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"time"
"github.com/disintegration/imaging"
"github.com/jinzhu/gorm"
"go.senan.xyz/wrtag/coverparse"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
@@ -77,7 +80,7 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
return nil
}
reader, err := coverFor(c.dbc, c.artistInfoCache, c.tagReader, id)
reader, err := coverFor(c.dbc, c.artistInfoCache, c.playlistStore, c.tagReader, id)
if err != nil {
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
}
@@ -131,7 +134,7 @@ var (
)
// TODO: can we use specidpaths.Locate here?
func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, tagReader tags.Reader, id specid.ID) (io.ReadCloser, error) {
func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, playlistStore *playlist.Store, tagReader tags.Reader, id specid.ID) (io.ReadCloser, error) {
switch id.Type {
case specid.Album:
return coverForAlbum(dbc, id.Value)
@@ -143,6 +146,8 @@ func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, tagR
return coverForPodcastEpisode(dbc, id.Value)
case specid.Track:
return coverForTrack(dbc, tagReader, id.Value)
case specid.Playlist:
return coverForPlaylist(playlistStore, id)
default:
return nil, errCoverNotFound
}
@@ -230,6 +235,35 @@ func coverForTrack(dbc *db.DB, tagReader tags.Reader, id int) (io.ReadCloser, er
return io.NopCloser(bytes.NewReader(cover)), nil
}
func coverForPlaylist(playlistStore *playlist.Store, id specid.ID) (*os.File, error) {
playlistPath := playlistIDDecode(id)
playlistDir := filepath.Join(playlistStore.BasePath(), filepath.Dir(playlistPath))
playlistBase := strings.TrimSuffix(filepath.Base(playlistPath), filepath.Ext(playlistPath))
entries, err := os.ReadDir(playlistDir)
if err != nil {
return nil, fmt.Errorf("read playlist dir: %w", err)
}
var cover string
for _, entry := range entries {
if entry.IsDir() {
continue
}
name := entry.Name()
nameBase := strings.TrimSuffix(name, filepath.Ext(name))
if nameBase == playlistBase && coverparse.IsCover(name) {
cover = coverparse.BestBetween(cover, name)
}
}
if cover == "" {
return nil, errCoverEmpty
}
return os.Open(filepath.Join(playlistDir, cover))
}
func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
user := r.Context().Value(CtxUser).(*db.User)
+128
View File
@@ -0,0 +1,128 @@
package ctrlsubsonic
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"go.senan.xyz/gonic/playlist"
)
func TestCoverForPlaylist(t *testing.T) {
t.Parallel()
t.Run("cover found jpg", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistDir := filepath.Join(tmp, "1")
require.NoError(t, os.MkdirAll(playlistDir, 0o755))
require.NoError(t, touch(filepath.Join(playlistDir, "test-playlist.jpg")))
playlistID := playlistIDEncode("1/test-playlist.m3u")
file, err := coverForPlaylist(store, playlistID)
require.NoError(t, err)
require.NotNil(t, file)
require.NoError(t, file.Close())
})
t.Run("cover found png", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistDir := filepath.Join(tmp, "1")
require.NoError(t, os.MkdirAll(playlistDir, 0o755))
require.NoError(t, touch(filepath.Join(playlistDir, "test-playlist.png")))
playlistID := playlistIDEncode("1/test-playlist.m3u")
file, err := coverForPlaylist(store, playlistID)
require.NoError(t, err)
require.NotNil(t, file)
require.NoError(t, file.Close())
})
t.Run("cover not found", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistDir := filepath.Join(tmp, "1")
require.NoError(t, os.MkdirAll(playlistDir, 0o755))
playlistID := playlistIDEncode("1/test-playlist.m3u")
file, err := coverForPlaylist(store, playlistID)
require.ErrorIs(t, err, errCoverEmpty)
require.Nil(t, file)
})
t.Run("nested playlist path", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistDir := filepath.Join(tmp, "1", "subfolder")
require.NoError(t, os.MkdirAll(playlistDir, 0o755))
require.NoError(t, touch(filepath.Join(playlistDir, "my-nested-playlist.jpg")))
playlistID := playlistIDEncode("1/subfolder/my-nested-playlist.m3u")
file, err := coverForPlaylist(store, playlistID)
require.NoError(t, err)
require.NotNil(t, file)
require.NoError(t, file.Close())
})
t.Run("playlist directory missing", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistID := playlistIDEncode("1/test-playlist.m3u")
file, err := coverForPlaylist(store, playlistID)
require.Error(t, err)
require.Nil(t, file)
})
t.Run("different playlists different covers", func(t *testing.T) {
t.Parallel()
tmp := t.TempDir()
store, err := playlist.NewStore(tmp)
require.NoError(t, err)
playlistDir := filepath.Join(tmp, "1")
require.NoError(t, os.MkdirAll(playlistDir, 0o755))
require.NoError(t, touch(filepath.Join(playlistDir, "playlist-a.jpg")))
require.NoError(t, touch(filepath.Join(playlistDir, "playlist-b.png")))
fileA, err := coverForPlaylist(store, playlistIDEncode("1/playlist-a.m3u"))
require.NoError(t, err)
require.Equal(t, "playlist-a.jpg", filepath.Base(fileA.Name()))
require.NoError(t, fileA.Close())
fileB, err := coverForPlaylist(store, playlistIDEncode("1/playlist-b.m3u"))
require.NoError(t, err)
require.Equal(t, "playlist-b.png", filepath.Base(fileB.Name()))
require.NoError(t, fileB.Close())
})
}
func touch(path string) error {
f, err := os.Create(path)
if err != nil {
return err
}
return f.Close()
}
+16 -11
View File
@@ -3,6 +3,7 @@ package spec
import (
"cmp"
"path/filepath"
"sort"
"go.senan.xyz/gonic/db"
)
@@ -63,14 +64,14 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
trCh := &TrackChild{
ID: t.SID(),
ContentType: t.MIME(),
Suffix: formatExt(t.Ext()),
Size: t.Size,
Artist: t.TagTrackArtist,
Title: cmp.Or(t.TagTitle, t.Filename),
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
ID: t.SID(),
ContentType: t.MIME(),
Suffix: formatExt(t.Ext()),
Size: t.Size,
DisplayArtist: t.TagTrackArtist,
Title: cmp.Or(t.TagTitle, t.Filename),
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
Path: filepath.Join(
parent.LeftPath,
parent.RightPath,
@@ -115,10 +116,14 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
for _, g := range t.Genres {
trCh.Genres = append(trCh.Genres, &GenreRef{Name: g.Name})
}
sort.Slice(t.Artists, func(i, j int) bool {
return t.Artists[i].ID < t.Artists[j].ID
})
if len(t.Artists) > 0 {
trCh.Artist = t.Artists[0].Name
trCh.ArtistID = t.Artists[0].SID()
}
for _, a := range t.Artists {
if a.Name == t.TagTrackArtist {
trCh.ArtistID = a.SID()
}
trCh.Artists = append(trCh.Artists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 {
+29 -8
View File
@@ -25,6 +25,7 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
AverageRating: formatRating(a.AverageRating),
IsCompilation: a.TagCompilation,
ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
DiscTitles: []*DiscTitle{},
}
if a.Cover != "" {
ret.CoverID = a.SID()
@@ -59,6 +60,17 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
if a.Play != nil {
ret.PlayCount = a.Play.Count
}
if len(a.DiscTitles) > 0 {
sort.Slice(a.DiscTitles, func(i, j int) bool {
return a.DiscTitles[i].DiscNumber < a.DiscTitles[j].DiscNumber
})
for _, dt := range a.DiscTitles {
ret.DiscTitles = append(ret.DiscTitles, &DiscTitle{
Disc: dt.DiscNumber,
Title: dt.Title,
})
}
}
return ret
}
@@ -67,7 +79,6 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
ID: t.SID(),
Album: album.TagTitle,
AlbumID: album.SID(),
Artist: t.TagTrackArtist,
Artists: []*ArtistRef{},
DisplayArtist: t.TagTrackArtist,
AlbumArtists: []*ArtistRef{},
@@ -106,21 +117,31 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
if t.TrackRating != nil {
ret.UserRating = t.TrackRating.Rating
}
if len(album.Artists) > 0 {
sort.Slice(album.Artists, func(i, j int) bool {
return album.Artists[i].ID < album.Artists[j].ID
})
sort.Slice(t.Artists, func(i, j int) bool {
return t.Artists[i].ID < t.Artists[j].ID
})
sort.Slice(album.Artists, func(i, j int) bool {
return album.Artists[i].ID < album.Artists[j].ID
})
switch {
case len(t.Artists) > 0:
ret.Artist = t.Artists[0].Name
ret.ArtistID = t.Artists[0].SID()
case len(album.Artists) > 0:
ret.Artist = album.Artists[0].Name
ret.ArtistID = album.Artists[0].SID()
}
for _, a := range t.Artists {
ret.Artists = append(ret.Artists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
if len(t.Genres) > 0 {
ret.Genre = t.Genres[0].Name
}
for _, g := range t.Genres {
ret.Genres = append(ret.Genres, &GenreRef{Name: g.Name})
}
for _, a := range t.Artists {
ret.Artists = append(ret.Artists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
for _, a := range album.Artists {
ret.AlbumArtists = append(ret.AlbumArtists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
+12 -6
View File
@@ -125,6 +125,11 @@ type GenreRef struct {
Name string `xml:"name,attr" json:"name"`
}
type DiscTitle struct {
Disc int `xml:"disc,attr" json:"disc"`
Title string `xml:"title,attr" json:"title"`
}
// https://opensubsonic.netlify.app/docs/responses/albumid3/
type Album struct {
ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
@@ -135,7 +140,7 @@ type Album struct {
Artist string `xml:"artist,attr" json:"artist"`
Artists []*ArtistRef `xml:"artists" json:"artists"`
DisplayArtist string `xml:"diplayArtist,attr" json:"displayArtist"`
DisplayArtist string `xml:"displayArtist,attr" json:"displayArtist"`
// folder stuff
Title string `xml:"title,attr,omitempty" json:"title"`
@@ -153,8 +158,9 @@ type Album struct {
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
DiscTitles []*DiscTitle `xml:"discTitles" json:"discTitles"`
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
@@ -193,10 +199,10 @@ type TrackChild struct {
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Artists []*ArtistRef `xml:"artists" json:"artists"`
DisplayArtist string `xml:"diplayArtist,attr" json:"displayArtist"`
DisplayArtist string `xml:"displayArtist,attr" json:"displayArtist"`
AlbumArtists []*ArtistRef `xml:"albumArtists" json:"albumArtists"`
AlbumDisplayArtist string `xml:"diplayAlbumArtist,attr" json:"displayAlbumArtist"`
AlbumDisplayArtist string `xml:"displayAlbumArtist,attr" json:"displayAlbumArtist"`
Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
@@ -320,7 +326,7 @@ type Playlists struct {
}
type Playlist struct {
ID string `xml:"id,attr" json:"id"`
ID specid.ID `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"`
Comment string `xml:"comment,attr" json:"comment"`
Owner string `xml:"owner,attr" json:"owner"`
+17 -5
View File
@@ -27,13 +27,15 @@ const (
Podcast IDT = "pd"
PodcastEpisode IDT = "pe"
InternetRadioStation IDT = "ir"
Playlist IDT = "pl"
separator = "-"
)
//nolint:musttag
type ID struct {
Type IDT
Value int
Type IDT
Value int
StringValue string
}
func New(in string) (ID, error) {
@@ -41,10 +43,17 @@ func New(in string) (ID, error) {
if !ok {
return ID{}, ErrBadSeparator
}
switch IDT(partType) {
case Playlist:
return ID{Type: Playlist, StringValue: partValue}, nil
}
val, err := strconv.Atoi(partValue)
if err != nil {
return ID{}, fmt.Errorf("%q: %w", partValue, ErrNotAnInt)
}
switch IDT(partType) {
case Artist:
return ID{Type: Artist, Value: val}, nil
@@ -64,10 +73,13 @@ func New(in string) (ID, error) {
}
func (i ID) String() string {
if i.Value == 0 {
return "-1"
switch {
case i.Value != 0:
return fmt.Sprintf("%s%s%d", i.Type, separator, i.Value)
case i.StringValue != "":
return fmt.Sprintf("%s%s%s", i.Type, separator, i.StringValue)
}
return fmt.Sprintf("%s%s%d", i.Type, separator, i.Value)
return "-1"
}
func (i ID) MarshalJSON() ([]byte, error) {
+25 -16
View File
@@ -37,32 +37,40 @@ func Locate(dbc *db.DB, id specid.ID) (Result, error) {
}
}
// Locate maps a location on the filesystem to a specid
func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (Result, error) {
// Lookup maps a location on the filesystem to a specid
func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (*specid.ID, error) {
if !strings.HasPrefix(path, "http") && !filepath.IsAbs(path) {
return nil, ErrNotAbs
}
if strings.HasPrefix(path, podcastsPath) {
podcastPath, episodeFilename := filepath.Split(path)
q := dbc.
Select("podcast_episodes.id").
Model(db.PodcastEpisode{}).
Joins(`JOIN podcasts ON podcasts.id=podcast_episodes.podcast_id`).
Where(`podcasts.root_dir=? AND podcast_episodes.filename=?`, filepath.Clean(podcastPath), filepath.Clean(episodeFilename))
var pe db.PodcastEpisode
if err := q.First(&pe).Error; err == nil {
return &pe, nil
var id int
if err := q.Row().Scan(&id); err != nil {
return nil, ErrNotFound
}
return nil, ErrNotFound
return &specid.ID{Type: specid.PodcastEpisode, Value: id}, nil
}
// probably internet radio
if strings.HasPrefix(path, "http") {
var irs db.InternetRadioStation
if err := dbc.First(&irs, "stream_url=?", path).Error; err == nil {
return &irs, nil
q := dbc.
Select("internet_radio_stations.id").
Model(db.InternetRadioStation{}).
Where("stream_url=?", path)
var id int
if err := q.Row().Scan(&id); err != nil {
return nil, ErrNotFound
}
return nil, ErrNotFound
return &specid.ID{Type: specid.InternetRadioStation, Value: id}, nil
}
var musicPath string
@@ -81,13 +89,14 @@ func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (
leftPath, rightPath := filepath.Split(filepath.Clean(relDir))
q := dbc.
Select("tracks.id").
Model(db.Track{}).
Where(`albums.root_dir=? AND albums.left_path=? AND albums.right_path=? AND tracks.filename=?`, musicPath, leftPath, rightPath, filename).
Joins(`JOIN albums ON tracks.album_id=albums.id`).
Preload("Album")
Joins(`JOIN albums ON tracks.album_id=albums.id`)
var track db.Track
if err := q.First(&track).Error; err == nil {
return &track, nil
var id int
if err := q.Row().Scan(&id); err != nil {
return nil, ErrNotFound
}
return nil, ErrNotFound
return &specid.ID{Type: specid.Track, Value: id}, nil
}
@@ -23,7 +23,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
@@ -41,7 +42,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-5",
@@ -59,7 +61,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-7",
@@ -77,7 +80,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-9",
@@ -113,7 +118,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-11",
@@ -131,7 +137,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-12",
@@ -149,7 +156,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
}
]
}
+18 -9
View File
@@ -23,7 +23,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-7",
@@ -41,7 +42,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-11",
@@ -59,7 +61,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
@@ -77,7 +80,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-12",
@@ -113,7 +118,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-5",
@@ -131,7 +137,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-9",
@@ -149,7 +156,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
}
]
}
+18 -9
View File
@@ -23,7 +23,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
@@ -41,7 +42,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-5",
@@ -59,7 +61,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-7",
@@ -77,7 +80,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-9",
@@ -113,7 +118,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-11",
@@ -131,7 +137,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-12",
@@ -149,7 +156,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
}
]
}
+120 -111
View File
@@ -23,115 +23,8 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-2",
"isDir": true,
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-6",
"isDir": true,
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"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": []
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"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": []
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-13",
@@ -149,7 +42,65 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-6",
"isDir": true,
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-2",
"isDir": true,
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-8",
@@ -167,7 +118,65 @@
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
"releaseTypes": [],
"discTitles": null
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"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
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
}
]
}
@@ -25,7 +25,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
@@ -45,7 +46,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
@@ -65,7 +67,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-7",
@@ -85,7 +88,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
@@ -105,7 +109,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -125,7 +130,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-11",
@@ -145,7 +151,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-12",
@@ -165,7 +172,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-13",
@@ -185,7 +193,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
@@ -25,7 +25,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-7",
@@ -45,7 +46,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-11",
@@ -65,7 +67,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
@@ -85,7 +88,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
@@ -105,7 +109,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-12",
@@ -125,7 +130,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
@@ -145,7 +151,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -165,7 +172,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-13",
@@ -185,7 +193,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+18 -9
View File
@@ -25,7 +25,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
@@ -45,7 +46,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
@@ -65,7 +67,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-7",
@@ -85,7 +88,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
@@ -105,7 +109,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -125,7 +130,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-11",
@@ -145,7 +151,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-12",
@@ -165,7 +172,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-13",
@@ -185,7 +193,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+137 -128
View File
@@ -7,106 +7,6 @@
"openSubsonic": true,
"albumList2": {
"album": [
{
"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"]
},
{
"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,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-1",
"album": "album-1",
"coverArt": "al-8",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-2",
"album": "album-2",
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
@@ -125,19 +25,20 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
"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-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
@@ -145,27 +46,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-0",
"album": "album-0",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -185,7 +67,134 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"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,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-0",
"album": "album-0",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-1",
"album": "album-1",
"coverArt": "al-8",
"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-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": []
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-2",
"album": "album-2",
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+2 -1
View File
@@ -109,7 +109,8 @@
}
],
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
}
}
+2 -1
View File
@@ -18,7 +18,8 @@
"duration": 0,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [""]
"releaseTypes": [""],
"discTitles": []
}
}
}
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-12",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-13",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
@@ -17,7 +17,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -45,7 +45,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -73,7 +73,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
+18 -9
View File
@@ -25,7 +25,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-4",
@@ -45,7 +46,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-5",
@@ -65,7 +67,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-7",
@@ -85,7 +88,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-8",
@@ -105,7 +109,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-9",
@@ -125,7 +130,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-11",
@@ -145,7 +151,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-12",
@@ -165,7 +172,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-13",
@@ -185,7 +193,8 @@
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
"releaseTypes": ["Album"],
"discTitles": []
}
]
}
+20 -20
View File
@@ -14,7 +14,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -42,7 +42,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -70,7 +70,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -98,7 +98,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -126,7 +126,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -154,7 +154,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -182,7 +182,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -210,7 +210,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -238,7 +238,7 @@
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"displayArtist": "artist-0",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -266,7 +266,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -294,7 +294,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -322,7 +322,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -350,7 +350,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -378,7 +378,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -406,7 +406,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -434,7 +434,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -462,7 +462,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -490,7 +490,7 @@
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"displayArtist": "artist-1",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -518,7 +518,7 @@
"artist": "artist-2",
"artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "",
"displayArtist": "artist-2",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
@@ -546,7 +546,7 @@
"artist": "artist-2",
"artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "",
"displayArtist": "artist-2",
"albumArtists": null,
"displayAlbumArtist": "",
"bitRate": 100,
+12 -3
View File
@@ -51,7 +51,10 @@ func MustArtists(p Tags) []string {
if r := normtag.Values(p, normtag.Artists); len(r) > 0 {
return r
}
return []string{MustArtist(p)}
if r := normtag.Values(p, normtag.Artist); len(r) > 0 {
return r
}
return []string{FallbackArtist}
}
func MustAlbumArtist(p Tags) string {
@@ -65,7 +68,10 @@ func MustAlbumArtists(p Tags) []string {
if r := normtag.Values(p, normtag.AlbumArtists); len(r) > 0 {
return r
}
return []string{MustAlbumArtist(p)}
if r := normtag.Values(p, normtag.AlbumArtist); len(r) > 0 {
return r
}
return []string{MustArtist(p)}
}
func MustGenre(p Tags) string {
@@ -79,7 +85,10 @@ func MustGenres(p Tags) []string {
if r := normtag.Values(p, normtag.Genres); len(r) > 0 {
return r
}
return []string{MustGenre(p)}
if r := normtag.Values(p, normtag.Genre); len(r) > 0 {
return r
}
return []string{FallbackGenre}
}
func MustYear(p Tags) int {
+1 -1
View File
@@ -1 +1 @@
0.19.0
0.20.1