Author SHA1 Message Date
yaemiku c2e2e037a2 Merge branch 'master' into default_music_folder 2026-04-26 03:57:41 +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 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 a7929ecb38 Merge branch 'master' into default_music_folder 2026-02-19 03:26:10 +01:00
yaemiku a63df166b0 Add default music path flag 2026-02-19 02:51:10 +01:00
sentriz 25a061f44e fix(listenbrainz): disable keep-alive to avoid connection reset errors 2026-02-17 15:36:20 +00:00
sentriz 4fff4185b5 refactor(specid): have Lookup return *specid.ID 2026-02-07 18:26:46 +00:00
sentriz 9407450660 fix(subsonic): return artist as track artist in TrackChild
fixes #654
2026-02-07 17:18:52 +00:00
sentriz fcf69743f0 scanner: log file paths when can't scan tags 2026-02-07 14:51:10 +00:00
sentriz e2dabd2519 feat(scanner): skip macOS resource fork files
related #657
2026-02-07 14:46:52 +00:00
sentriz 896b0dde2b feat(scanner): also read multi vorbis singular tags
closes #659
2026-02-05 21:14:12 +00:00
github-actions[bot] c36580fc30 chore: release 0.20.1 (#656)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-01-30 09:59:25 +00:00
sentriz 103a048e84 fix(playlist): fix regression in playlist ID handling
closes #655
2026-01-30 09:53:00 +00:00
sentriz 6a64822259 chore(deps): downgrade wrtag 2026-01-30 09:52:39 +00:00
github-actions[bot] 13255e67a5 chore: release 0.20.0 (#617)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-01-25 00:11:52 +00:00
sentriz 6cf2517d8d chore(deps): bump 2026-01-22 20:52:42 +00:00
sentriz 04ff7f3c33 fix(subsonic): correct spec typos
closes #653
2026-01-22 19:23:03 +00:00
sentriz e407421032 always return disc titles 2026-01-21 17:45:33 +00:00
sentriz 0fe8d4c1cc chore(deps): bump 2026-01-20 19:36:17 +00:00
sentriz 0377bfa696 feat(subsonic): return disc titles 2026-01-20 19:32:24 +00:00
sentrizandMatteo aad729e3ea feat: add support for playlist cover art on filesystem
closes #650

Co-authored-by: Matteo <girardi.matteo.dev@gmail.com>
2026-01-19 17:56:10 +00:00
snoutieandsnoutie db9aa2b2e3 feat(subsonic): implement getSimilarSongs for artists and albums (#649)
* getSimilarSongs for artists and albums

* Use preloaded album tracks

* Return after no similar tracks have been found for album

* Move controller to params

* Move getSimilarSongsFrom functions

* Fix getSimilarSongs returning similarSongs2 & refactor

---------

Co-authored-by: snoutie <snoutie@achtarmig.org>
2026-01-18 14:44:04 +00:00
sentriz 2900ce5102 fix(podcast): validate response status code when fetching podcast audio
fixes #639
2026-01-06 19:46:08 +00:00
Daniele Ricci 99e2ccfb0f fix(gonic): correct typo in command line help (#640) 2025-12-22 21:50:57 +00:00
sentriz ca59601484 fix(scanner): clear metadata of albums who no longer have tracks
fixes #638
2025-12-21 18:51:27 +00:00
sentriz c752a22808 feat(scanner): read multi valued release types 2025-12-13 16:19:40 +00:00
sentriz 469649935e fix(db): use separate DSN for both drivers 2025-12-05 17:52:29 +01:00
sentriz b67c1c14d2 fix(db): enable WAL also for Wasm driver
related #620
2025-12-05 11:49:04 +01:00
sentriz c8cc0ddb4c chore(deps): bump 2025-12-04 14:24:55 +01:00
sentriz 816e437d44 feat(db): add an index on albums.created_at
related #620
2025-12-02 11:48:27 +01:00
sentriz 1df6d02e6e db: remove shared cache and bump to 4 max open conns
related #620
2025-11-30 20:43:55 +01:00
sentriz 86752787ec chore(deps): bump
fixes #631
2025-11-30 20:01:17 +01:00
eddyizm 8c7b64a9f7 docs: add tempus android client to readme (#629) 2025-11-19 15:51:03 +00:00
sentriz e848bee945 chore(deps): bump 2025-11-11 17:45:39 +00:00
sentriz 971d22d619 update wazero sum 2025-11-11 02:00:17 -05:00
sentriz 79e3898c3b feat(ci): bump golangci-lint
a
2025-11-11 02:00:16 -05:00
sentriz dd7139c16d chore(deps): bump
fixes #610
2025-11-09 12:29:50 -03:00
sentriz e12ab544c2 fix(podcast): truncate filenames longer than 200 chars
fixes #624
2025-11-05 12:10:32 -03:00
sentriz c2ebe96313 feat(subsonic): allow non admins to download podcast episodes
closes #623
2025-11-05 11:41:55 -03:00
sentriz 75a0918a7e feat(gonic): add log-db option to log queries
related #620
2025-10-24 17:05:46 +01:00
sentriz ea5e6252a1 fix(scanner): reset embedded cover for album when toggling scan-embedded-cover
closes #619
2025-10-23 16:52:25 +01:00
sentriz 82642eb1ca feat(taglib): add .ape as a supported filetype
closes #615
2025-10-21 17:23:40 +01:00
sentriz e61e27815f update default.pgo 2025-10-11 17:24:14 +01:00
sentriz bdfa9faede update changelog 2025-10-11 17:00:38 +01:00
github-actions[bot]andsentriz b957f50e86 chore: release 0.19.0 (#603)
* chore: release 0.19.0

* add notes

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: sentriz <senan@senan.xyz>
2025-10-11 15:16:53 +00:00
sentriz f6cc20f7aa chore(deps): bump 2025-10-11 13:18:51 +01:00
Senan Kelly 1af4ce3587 feat(subsonic): keep original cover file format when caching (#609)
related #11
2025-10-10 22:19:29 +00:00
sentriz 7b29c611e8 refactor(scanner): don't pass double pointers 2025-10-06 17:40:39 +01:00
sentriz 2f13b89dac chore(deps): bump 2025-10-01 17:51:12 +01:00
sentriz 9819578bda refactor(mockfs): format 2025-09-30 22:41:22 +01:00
sentriz d66814bfd1 feat(subsonic): support embedded track level cover art
related #11
2025-09-30 15:08:46 +01:00
sentriz bc0b6c0da4 feat(tags): add Properties.HasCover 2025-09-30 14:20:29 +01:00
sentriz c69cb8cf35 feat(gonic): add scan-embedded-cover-enabled flag 2025-09-30 13:49:40 +01:00
sentriz 1fc608aa52 chore(deps): bump 2025-09-30 13:18:58 +01:00
sentriz e3ea9ecc91 refactor(tags): remove ChainReader 2025-09-30 11:38:26 +01:00
sentriz 8e7820a72e feat(ffprobe): add more supported file types 2025-09-29 19:10:12 +01:00
sentriz ca85eed4c1 feat(ci): merge nightly and debug workflows 2025-09-29 19:10:12 +01:00
sentriz ec7cffdd57 feat(subsonic): support embedded cover art
closes #11
closes #556
2025-09-29 18:24:37 +01:00
sentriz 2fcba12650 wire tag.Reader to subsonic Controller 2025-09-29 18:24:10 +01:00
sentriz e413bc35de feat(tags): add ReadCover interface method 2025-09-29 17:08:00 +01:00
Alex McGrath 3a9c03ac88 feat(tags): add ffprobe reader 2025-09-29 16:02:57 +01:00
sentriz aba758f2ba feat(gonic): use wrtag/normtag for nag normalisation 2025-09-29 16:02:57 +01:00
sentriz e3db819d8f feat(ci): remove Cgo dependencies, cross compile without QEMU, upload static binaries 2025-09-29 14:41:40 +01:00
sentriz 58c2933355 chore(deps): bump 2025-09-29 14:41:39 +01:00
sentriz 505f7d8ae6 feat(build): add Cgo free database 2025-09-29 14:41:39 +01:00
sentriz 7802e20e72 feat(build): add Cgo free tagging backend 2025-09-29 14:41:39 +01:00
sentriz 3909e9b5bd feat(subsonic): return genres for getAlbumListTwo2
fixes #605
2025-09-28 18:38:53 +01:00
sentriz 85ea8d896a refactor(scanner): batch dir lookups / reduce tx overhead 2025-09-24 14:59:06 +01:00
sentriz eb0d8fd1c7 feat(subsonic): also read unsynced lyrics from .txt files and tag metadata
closes #593
2025-09-23 21:29:20 +01:00
github-actions[bot] e8d03f4450 chore: release 0.18.0 (#595)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-22 09:42:54 +01:00
sentriz c9f41810af feat(docker): use alpine native taglib
bumps from 2.0.1 to 2.1.1
2025-09-18 16:47:42 +01:00
sentriz 3db183bda4 feat(subsonic): better support for internet radio and podcast episodes in jukebox
fixes #572
2025-09-18 15:45:34 +01:00
sentriz 8ac8779b92 fix(subsonic): restore disc/track ordering in getMusicDirectory
fixes #597
2025-09-18 12:42:14 +01:00
sentriz eaa82b00e5 feat(readme): document comma escaping in readme
closes #596
2025-09-09 18:42:52 +01:00
sentriz 223b7feab4 readme: mention tagging with wrtag 2025-09-08 13:07:07 +01:00
sentriz 1bf4a5b0c1 chore(deps)!: bump to go1.25
fixes #594

Release-As: 0.18.0
2025-09-06 23:38:04 +01:00
./daniele db97bc753e feat(subsonic): add support for lyrics (#519)
* Add songLyrics extension since the getLyricsBySongId method is implemented

* Add support for lyrics

* Add check for getLyrics function

* fix typo

* chore: fix tests

* fix(lyrics): if lrc is formatted with empty spaces remove them

* fix(lint): use NewError correctly

bump ts
2025-08-26 11:09:00 +01:00
sentriz 5916a7fe7b feat(subsonic): replace html2text with bluemonday
fixes #591

Release-As: 0.17.1
2025-08-26 00:53:33 +01:00
79 changed files with 3013 additions and 1490 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: ["*"]
-40
View File
@@ -1,40 +0,0 @@
name: Debug Release
on:
workflow_dispatch:
inputs:
tag:
description: "Tag of image to build"
required: true
jobs:
build-release:
name: Build and release Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login into DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}
${{ github.repository }}:${{ github.event.inputs.tag }}
+24 -24
View File
@@ -2,7 +2,12 @@ name: Nightly Release
on: on:
schedule: schedule:
- cron: "0 0 * * *" - cron: "0 0 * * *"
workflow_dispatch: {} workflow_dispatch:
inputs:
custom_tag:
description: 'Custom tag (optional, will use "nightly" if not provided)'
required: false
type: string
jobs: jobs:
check-date: check-date:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -22,38 +27,28 @@ jobs:
if: ${{ needs.check-date.outputs.should_run == 'true' }} if: ${{ needs.check-date.outputs.should_run == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v6
with: with:
go-version-file: go.mod go-version-file: go.mod
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v8 uses: golangci/golangci-lint-action@v9
with: with:
install-mode: goinstall install-mode: goinstall
version: v2.3.0 version: v2.6.1
- name: Test - name: Test
run: go test ./... run: go test ./...
build-release: build-docker:
name: Build and release Docker image name: Build and release Docker image
needs: [check-date, test] needs: [check-date, test]
if: ${{ needs.check-date.outputs.should_run == 'true' }} if: ${{ needs.check-date.outputs.should_run == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up QEMU - name: Setup Docker Buildx
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with: with:
install: true install: true
@@ -63,19 +58,24 @@ jobs:
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry - name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Generate short hash - name: Generate short hash and set tag
run: | run: |
_short_hash=${{ github.sha }} _short_hash=${{ github.sha }}
echo "SHORT_HASH=${_short_hash:0:7}" >> $GITHUB_ENV echo "SHORT_HASH=${_short_hash:0:7}" >> $GITHUB_ENV
if [ -n "${{ github.event.inputs.custom_tag }}" ]; then
echo "TAG_NAME=${{ github.event.inputs.custom_tag }}" >> $GITHUB_ENV
else
echo "TAG_NAME=nightly" >> $GITHUB_ENV
fi
- name: Build and Push - name: Build and Push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
push: true push: true
tags: | tags: |
ghcr.io/${{ github.repository }}:${{ env.SHORT_HASH }} ghcr.io/${{ github.repository }}:${{ env.SHORT_HASH }}
ghcr.io/${{ github.repository }}:nightly ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }}
${{ github.repository }}:${{ env.SHORT_HASH }} ${{ github.repository }}:${{ env.SHORT_HASH }}
${{ github.repository }}:nightly ${{ github.repository }}:${{ env.TAG_NAME }}
+51 -24
View File
@@ -8,21 +8,17 @@ jobs:
name: Lint and test name: Lint and test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v6
with: with:
go-version-file: go.mod go-version-file: go.mod
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v8 uses: golangci/golangci-lint-action@v9
with: with:
install-mode: goinstall install-mode: goinstall
version: v2.3.0 version: v2.6.1
- name: Test - name: Test
run: go test ./... run: go test ./...
release-please: release-please:
@@ -43,32 +39,61 @@ jobs:
release-type: simple release-type: simple
changelog-path: CHANGELOG.md changelog-path: CHANGELOG.md
package-name: gonic package-name: gonic
build-release: build-binaries:
name: Build binaries
runs-on: ubuntu-latest
needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }}
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64, 386]
exclude:
- os: darwin
arch: 386
# https://github.com/natefinch/npipe/issues/33 (required by mpvipc)
- os: windows
arch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build
run: |
set -e
CGO_ENABLED=0 GOOS="${{ matrix.os }}" GOARCH="${{ matrix.arch }}" go build -o out/ ./cmd/...
[[ "${{ matrix.os }}" = "windows" ]] && suff=".exe"
cd out/
for p in *; do
mv "$p" "${p%.*}-${{ matrix.os }}-${{ matrix.arch }}-${{ needs.release-please.outputs.tag_name }}$suff"
done
cd -
- name: Upload
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.CR_PAT }}
file: out/*
file_glob: true
tag: ${{ needs.release-please.outputs.tag_name }}
build-docker:
name: Build, tag, and publish Docker image name: Build, tag, and publish Docker image
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [release-please] needs: [release-please]
if: ${{ needs.release-please.outputs.release_created }} if: ${{ needs.release-please.outputs.release_created }}
steps: steps:
- name: Checkout repository - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Set up QEMU - name: Setup Docker Buildx
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:master
- name: Login into DockerHub - name: Login into DockerHub
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login into GitHub Container Registry - name: Login into GitHub Container Registry
run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push - name: Build and Push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
@@ -79,6 +104,8 @@ jobs:
ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:latest
${{ github.repository }}:${{ needs.release-please.outputs.tag_name }} ${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
${{ github.repository }}:latest ${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
notify-irc: notify-irc:
needs: [release-please] needs: [release-please]
name: Notify IRC name: Notify IRC
+5 -9
View File
@@ -9,20 +9,16 @@ jobs:
name: Lint and test name: Lint and test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v6
with: with:
go-version-file: go.mod go-version-file: go.mod
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint - name: Lint
uses: golangci/golangci-lint-action@v8 uses: golangci/golangci-lint-action@v9
with: with:
install-mode: goinstall install-mode: goinstall
version: v2.3.0 version: v2.6.1
- name: Test - name: Test
run: go test ./... run: go test ./...
+3
View File
@@ -12,3 +12,6 @@ dist
*.swp *.swp
.tags* .tags*
*.test *.test
.env
config
genre-tree
+118
View File
@@ -1,5 +1,123 @@
# Changelog # 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.
### Features
* **build:** add Cgo free database ([505f7d8](https://www.github.com/sentriz/gonic/commit/505f7d8ae6116c5dc1cfa50a5caba6333672be20))
* **build:** add Cgo free tagging backend ([7802e20](https://www.github.com/sentriz/gonic/commit/7802e20e7214e1912fc84bb29c877984b99913c9))
* **ci:** merge nightly and debug workflows ([ca85eed](https://www.github.com/sentriz/gonic/commit/ca85eed4c156c5370c1e3e4c7fbc31d4c1811f57))
* **ci:** remove Cgo dependencies, cross compile without QEMU, upload static binaries ([e3db819](https://www.github.com/sentriz/gonic/commit/e3db819d8fd5ae14332c56ab7cebc01d46a6c76b))
* **ffprobe:** add more supported file types ([8e7820a](https://www.github.com/sentriz/gonic/commit/8e7820a72e2360e3b5808299123fd5a686c084e8))
* **gonic:** add `scan-embedded-cover-enabled` flag ([c69cb8c](https://www.github.com/sentriz/gonic/commit/c69cb8cf35203c6db15d3c1bd68a86cb91108b40))
* **gonic:** use wrtag/normtag for nag normalisation ([aba758f](https://www.github.com/sentriz/gonic/commit/aba758f2ba6e6d20887a36a0cba80127c2b110a9))
* **subsonic:** also read unsynced lyrics from .txt files and tag metadata ([eb0d8fd](https://www.github.com/sentriz/gonic/commit/eb0d8fd1c710bf0367348873858662c39515b676)), closes [#593](https://www.github.com/sentriz/gonic/issues/593)
* **subsonic:** keep original cover file format when caching ([#609](https://www.github.com/sentriz/gonic/issues/609)) ([1af4ce3](https://www.github.com/sentriz/gonic/commit/1af4ce35873ff17dc6331e0d7c0e0385213b53b3)), closes [#11](https://www.github.com/sentriz/gonic/issues/11)
* **subsonic:** return genres for getAlbumListTwo2 ([3909e9b](https://www.github.com/sentriz/gonic/commit/3909e9b5bdbc3deb1b5f48ff6f04b3d865a1b1bc)), closes [#605](https://www.github.com/sentriz/gonic/issues/605)
* **subsonic:** support embedded cover art ([ec7cffd](https://www.github.com/sentriz/gonic/commit/ec7cffdd57f235adce93b7faf1998fdc9a164c52)), closes [#11](https://www.github.com/sentriz/gonic/issues/11) [#556](https://www.github.com/sentriz/gonic/issues/556)
* **subsonic:** support embedded track level cover art ([d66814b](https://www.github.com/sentriz/gonic/commit/d66814bfd1d39ba92c6c368c0006052451675454)), closes [#11](https://www.github.com/sentriz/gonic/issues/11)
* **tags:** add ffprobe reader ([3a9c03a](https://www.github.com/sentriz/gonic/commit/3a9c03ac88b6e6476206a87e3703e247c965e7c9))
* **tags:** add Properties.HasCover ([bc0b6c0](https://www.github.com/sentriz/gonic/commit/bc0b6c0da4738c3ee8f40525e2ed1d85c51f927a))
* **tags:** add ReadCover interface method ([e413bc3](https://www.github.com/sentriz/gonic/commit/e413bc35ded9463b245ff913fb2d90ee80ea3184))
### ⚠ Note to package maintainers
- The `sqlite-dev` and `libtag-dev` (or your distro's equivalents) packages are **no longer required**; please remove them from package dependencies.
- Build with `CGO_ENABLED=0` to produce static binaries.
gonic now vendors reproducible WebAssembly backends for TagLib and SQLite, eliminating Cgo and external system libraries. Builds are fully static, cross-compiling is straightforward, and supply-chain verification is easier.
Verify the vendored WASM artifacts using Artifact Attestations:
- <https://github.com/sentriz/go-taglib/raw/refs/tags/v0.10.4/taglib.wasm> ([Attestations](https://github.com/sentriz/go-taglib/attestations/11402786))
- <https://github.com/ncruces/go-sqlite3/raw/refs/tags/v0.29.1/embed/sqlite3.wasm> ([Attestations](https://github.com/ncruces/go-sqlite3/attestations/11344814))
Example build pipeline:
```console
$ git clone https://github.com/sentriz/gonic
$ cd gonic
$ sha256sum "$(go list -m -f '{{.Dir}}' go.senan.xyz/taglib)/taglib.wasm"
# expected ca5ce04b35f1e6cad8b8d9f00906a4c108ccd004b56e713db5ce69aa69b3805d (https://github.com/sentriz/go-taglib/attestations/11402786)
$ sha256sum "$(go list -m -f '{{.Dir}}' github.com/ncruces/go-sqlite3)/embed/sqlite3.wasm"
# expected 117262b6241d8de78ba564a44383fa1562e52f1a978de269e20a02b3c06c02e3 (https://github.com/ncruces/go-sqlite3/attestations/11344814)
$ CGO_ENABLED=0 go build ./cmd/gonic/.
```
Opting out of WebAssembly:
- If you prefer not to use the WebAssembly binaries, you can build with `nowasm`:
```console
$ go build -tags nowasm ./cmd/gonic/.
```
- This mode is not supported, and tagging/scan performance will degrade.
- Cgo will be used for sqlite, so sqlite-dev is still required.
- `ffprobe` will be used for tagging, so that must be available in `$PATH`. `libtag-dev` is still not used in this mode.
## [0.18.0](https://www.github.com/sentriz/gonic/compare/v0.17.0...v0.18.0) (2025-09-18)
### ⚠ BREAKING CHANGES
* **deps:** bump to go1.25
### Features
* **docker:** use alpine native taglib ([c9f4181](https://www.github.com/sentriz/gonic/commit/c9f41810af76d6a49c40af274b001f2b5b1d155d))
* **readme:** document comma escaping in readme ([eaa82b0](https://www.github.com/sentriz/gonic/commit/eaa82b00e55dc56dd5f1b7683769c2f30dadcc63)), closes [#596](https://www.github.com/sentriz/gonic/issues/596)
* **subsonic:** add support for lyrics ([#519](https://www.github.com/sentriz/gonic/issues/519)) ([db97bc7](https://www.github.com/sentriz/gonic/commit/db97bc753e1070de12b3907b2b996511140a3259))
* **subsonic:** better support for internet radio and podcast episodes in jukebox ([3db183b](https://www.github.com/sentriz/gonic/commit/3db183bda4b9feda1adf7f4f67218d36eff61a49)), closes [#572](https://www.github.com/sentriz/gonic/issues/572)
* **subsonic:** replace html2text with bluemonday ([5916a7f](https://www.github.com/sentriz/gonic/commit/5916a7fe7bc7ac39ca1975665433da627d214769)), closes [#591](https://www.github.com/sentriz/gonic/issues/591)
### Bug Fixes
* **subsonic:** restore disc/track ordering in getMusicDirectory ([8ac8779](https://www.github.com/sentriz/gonic/commit/8ac8779b92ec9c969bf6a26b26454a1c9e49748a)), closes [#597](https://www.github.com/sentriz/gonic/issues/597)
### Miscellaneous Chores
* **deps:** bump to go1.25 ([1bf4a5b](https://www.github.com/sentriz/gonic/commit/1bf4a5b0c1e209770b060c8b4a08910afb72078f)), closes [#594](https://www.github.com/sentriz/gonic/issues/594)
## [0.17.0](https://www.github.com/sentriz/gonic/compare/v0.16.4...v0.17.0) (2025-08-21) ## [0.17.0](https://www.github.com/sentriz/gonic/compare/v0.16.4...v0.17.0) (2025-08-21)
+10 -33
View File
@@ -1,33 +1,18 @@
FROM alpine:3.22 AS builder-taglib # syntax=docker/dockerfile:1
WORKDIR /tmp FROM --platform=$BUILDPLATFORM golang:1.26-alpine3.23 AS builder
COPY alpine/taglib/APKBUILD . ARG TARGETOS
RUN apk update && \ ARG TARGETARCH
apk add --no-cache abuild doas && \
echo "permit nopass root" > /etc/doas.conf && \
abuild-keygen -a -n -i && \
REPODEST=/pkgs abuild -F -r
FROM golang:1.24-alpine3.22 AS builder
RUN apk add -U --no-cache \
build-base \
ca-certificates \
git \
sqlite \
zlib-dev \
go
# TODO: delete this block when taglib v2 is on alpine packages
COPY --from=builder-taglib /pkgs/*/*.apk /pkgs/
RUN apk add --no-cache --allow-untrusted /pkgs/*
WORKDIR /src WORKDIR /src
COPY go.mod . COPY go.mod .
COPY go.sum . COPY go.sum .
RUN go mod download RUN go mod download
COPY . . COPY . .
RUN GOOS=linux go build -o gonic cmd/gonic/gonic.go RUN \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/ ./cmd/...
FROM alpine:3.22 FROM alpine:3.23
LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic
RUN apk add -U --no-cache \ RUN apk add -U --no-cache \
ffmpeg \ ffmpeg \
@@ -36,15 +21,7 @@ RUN apk add -U --no-cache \
tzdata \ tzdata \
tini \ tini \
shared-mime-info shared-mime-info
COPY --from=builder /out/* /usr/local/bin/
COPY --from=builder \
/usr/lib/libgcc_s.so.1 \
/usr/lib/libstdc++.so.6 \
/usr/lib/libtag.so.2 \
/usr/lib/
COPY --from=builder \
/src/gonic \
/bin/
VOLUME ["/cache", "/data", "/music", "/podcasts"] VOLUME ["/cache", "/data", "/music", "/podcasts"]
EXPOSE 80 EXPOSE 80
ENV TZ= ENV TZ=
-10
View File
@@ -1,10 +0,0 @@
FROM golang:1.24-alpine3.22 AS builder
RUN apk add -U --no-cache \
build-base \
ca-certificates \
git \
sqlite \
taglib-dev \
zlib-dev \
shared-mime-info
WORKDIR /src
-39
View File
@@ -1,39 +0,0 @@
# syntax=docker/dockerfile:experimental
FROM golang:1.24-alpine3.22 AS builder
RUN apk add -U --no-cache \
build-base \
ca-certificates \
git \
sqlite \
taglib-dev \
zlib-dev
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=linux go build -o gonic cmd/gonic/gonic.go
FROM alpine:3.22
RUN apk add -U --no-cache \
ffmpeg \
mpv \
ca-certificates \
shared-mime-info
COPY --from=builder \
/usr/lib/libgcc_s.so.1 \
/usr/lib/libstdc++.so.6 \
/usr/lib/libtag.so.1 \
/usr/lib/
COPY --from=builder \
/src/gonic \
/bin/
VOLUME ["/cache", "/data", "/music", "/podcasts"]
EXPOSE 80
ENV GONIC_DB_PATH=/data/gonic.db
ENV GONIC_LISTEN_ADDR=:80
ENV GONIC_MUSIC_PATH=/music
ENV GONIC_PODCAST_PATH=/podcasts
ENV GONIC_PLAYLISTS_PATH=/playlists
ENV GONIC_CACHE_PATH=/cache
CMD ["gonic"]
+7 -3
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/), [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
@@ -50,8 +50,9 @@ password can then be changed from the web interface
## configuration options ## configuration options
| env var | command line arg | description | | env var | command line arg | description |
| -------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) | | `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) |
| `GONIC_DEFAULT_MUSIC_PATH` | `-default-music-path` | default music path for when no folder is selected in client (useful for when client does not support choosing a folder) |
| `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory | | `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory |
| `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. | | `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. |
| `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc | | `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc |
@@ -64,6 +65,7 @@ password can then be changed from the web interface
| `GONIC_SCAN_INTERVAL` | `-scan-interval` | **optional** interval (in minutes) to check for new music (automatic scanning disabled if omitted) | | `GONIC_SCAN_INTERVAL` | `-scan-interval` | **optional** interval (in minutes) to check for new music (automatic scanning disabled if omitted) |
| `GONIC_SCAN_AT_START_ENABLED` | `-scan-at-start-enabled` | **optional** whether to perform an initial scan at startup | | `GONIC_SCAN_AT_START_ENABLED` | `-scan-at-start-enabled` | **optional** whether to perform an initial scan at startup |
| `GONIC_SCAN_WATCHER_ENABLED` | `-scan-watcher-enabled` | **optional** whether to watch file system for new music and rescan | | `GONIC_SCAN_WATCHER_ENABLED` | `-scan-watcher-enabled` | **optional** whether to watch file system for new music and rescan |
| `GONIC_SCAN_EMBEDDED_COVER_ENABLED` | `-scan-embedded-cover-enabled` | **optional** whether to scan for embedded covers in audio files (_default_ `true`) |
| `GONIC_JUKEBOX_ENABLED` | `-jukebox-enabled` | **optional** whether the subsonic [jukebox api](https://airsonic.github.io/docs/jukebox/) should be enabled | | `GONIC_JUKEBOX_ENABLED` | `-jukebox-enabled` | **optional** whether the subsonic [jukebox api](https://airsonic.github.io/docs/jukebox/) should be enabled |
| `GONIC_JUKEBOX_MPV_EXTRA_ARGS` | `-jukebox-mpv-extra-args` | **optional** extra command line arguments to pass to the jukebox mpv daemon | | `GONIC_JUKEBOX_MPV_EXTRA_ARGS` | `-jukebox-mpv-extra-args` | **optional** extra command line arguments to pass to the jukebox mpv daemon |
| `GONIC_PODCAST_PURGE_AGE` | `-podcast-purge-age` | **optional** age (in days) to purge podcast episodes if not accessed | | `GONIC_PODCAST_PURGE_AGE` | `-podcast-purge-age` | **optional** age (in days) to purge podcast episodes if not accessed |
@@ -85,10 +87,12 @@ the available modes are:
| value | desc | | value | desc |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), or [betanin](https://github.com/sentriz/betanin/) can set set these | | `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), [wrtag](https://github.com/sentriz/wrtag/), or [betanin](https://github.com/sentriz/betanin/) can set set these |
| `delim <delim>` | gonic will look at your normal audio metadata fields like "genre" or "album_artist", but split them on a delimiter. for example you could set `-multi-value-genre "delim ;"` to split the single genre field on ";". note this mode is not recommended unless you use an uncommon delimiter such as ";" or "\|". using a delimiter like "&" will likely lead to many [false positives](https://musicbrainz.org/artist/ccd4879c-5e88-4385-b131-bf65296bf245) | | `delim <delim>` | gonic will look at your normal audio metadata fields like "genre" or "album_artist", but split them on a delimiter. for example you could set `-multi-value-genre "delim ;"` to split the single genre field on ";". note this mode is not recommended unless you use an uncommon delimiter such as ";" or "\|". using a delimiter like "&" will likely lead to many [false positives](https://musicbrainz.org/artist/ccd4879c-5e88-4385-b131-bf65296bf245) |
| `none` (default) | gonic will not attempt to do any multi value processing | | `none` (default) | gonic will not attempt to do any multi value processing |
note: `,` is a special character in the environment variable parser. if you wish to use `,` for example for splitting genres, the `,` must be escaped with `\`. for example `"delim \,"`.
## screenshots ## screenshots
| | | | | | | | | | | |
-56
View File
@@ -1,56 +0,0 @@
# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=taglib2
pkgver=2.0.1
pkgrel=0
pkgdesc="Library for reading and editing metadata of several popular audio formats"
url="https://taglib.github.io/"
arch="all"
license="LGPL-2.1-only OR MPL-1.1"
makedepends="zlib-dev utfcpp cmake samurai"
checkdepends="cppunit-dev"
subpackages="
$pkgname-dev
libtag:_lib
libtag_c:_lib
"
source="https://taglib.github.io/releases/taglib-$pkgver.tar.gz"
builddir="$srcdir/taglib-$pkgver"
# secfixes:
# 1.11.1-r2:
# - CVE-2017-12678
# - CVE-2018-11439
build() {
CFLAGS="$CFLAGS -flto=auto" \
CXXFLAGS="$CXXFLAGS -flto=auto" \
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DWITH_ZLIB=ON \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
-DVISIBILITY_HIDDEN=ON
CPLUS_INCLUDE_PATH="/usr/include/utf8cpp" \
cmake --build build
}
check() {
ctest --test-dir build --output-on-failure
}
package() {
DESTDIR="$pkgdir" cmake --install build
}
_lib() {
pkgdesc="$pkgdesc ($subpkgname lib)"
amove usr/lib/$subpkgname.so.*
}
sha512sums="
25ee89293a96d7f8dca6276f822bdaef01fd98503b78c20ffeac8e1d9821de7273a5127146aa798d304c6a995cb2b7229a205aff1cc261b5d4fa9e499dda0439 taglib-2.0.1.tar.gz
"
Binary file not shown.
+13 -14
View File
@@ -26,13 +26,14 @@ import (
"github.com/google/shlex" "github.com/google/shlex"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/sentriz/gormstore" "github.com/sentriz/gormstore"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"go.senan.xyz/flagconf" "go.senan.xyz/flagconf"
"go.senan.xyz/gonic" "go.senan.xyz/gonic"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/deps"
"go.senan.xyz/gonic/handlerutil" "go.senan.xyz/gonic/handlerutil"
"go.senan.xyz/gonic/infocache/albuminfocache" "go.senan.xyz/gonic/infocache/albuminfocache"
"go.senan.xyz/gonic/infocache/artistinfocache" "go.senan.xyz/gonic/infocache/artistinfocache"
@@ -45,8 +46,6 @@ import (
"go.senan.xyz/gonic/scrobble" "go.senan.xyz/gonic/scrobble"
"go.senan.xyz/gonic/server/ctrladmin" "go.senan.xyz/gonic/server/ctrladmin"
"go.senan.xyz/gonic/server/ctrlsubsonic" "go.senan.xyz/gonic/server/ctrlsubsonic"
"go.senan.xyz/gonic/tags/tagcommon"
"go.senan.xyz/gonic/tags/taglib"
"go.senan.xyz/gonic/transcode" "go.senan.xyz/gonic/transcode"
) )
@@ -63,6 +62,7 @@ func main() {
var confMusicPaths pathAliases var confMusicPaths pathAliases
flag.Var(&confMusicPaths, "music-path", "path to music") flag.Var(&confMusicPaths, "music-path", "path to music")
defaultMusicPath := flag.String("default-music-path", "", "interval (in minutes) to automatically scan music (optional)")
confPlaylistsPath := flag.String("playlists-path", "", "path to your list of new or existing m3u playlists that gonic can manage") confPlaylistsPath := flag.String("playlists-path", "", "path to your list of new or existing m3u playlists that gonic can manage")
@@ -71,6 +71,7 @@ func main() {
confScanIntervalMins := flag.Uint("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)") confScanIntervalMins := flag.Uint("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)")
confScanAtStart := flag.Bool("scan-at-start-enabled", false, "whether to perform an initial scan at startup (optional)") confScanAtStart := flag.Bool("scan-at-start-enabled", false, "whether to perform an initial scan at startup (optional)")
confScanWatcher := flag.Bool("scan-watcher-enabled", false, "whether to watch file system for new music and rescan (optional)") confScanWatcher := flag.Bool("scan-watcher-enabled", false, "whether to watch file system for new music and rescan (optional)")
confScanEmbeddedCover := flag.Bool("scan-embedded-cover-enabled", true, "whether to scan for embedded covers in audio files (optional)")
confJukeboxEnabled := flag.Bool("jukebox-enabled", false, "whether the subsonic jukebox api should be enabled (optional)") confJukeboxEnabled := flag.Bool("jukebox-enabled", false, "whether the subsonic jukebox api should be enabled (optional)")
confJukeboxMPVExtraArgs := flag.String("jukebox-mpv-extra-args", "", "extra command line arguments to pass to the jukebox mpv daemon (optional)") confJukeboxMPVExtraArgs := flag.String("jukebox-mpv-extra-args", "", "extra command line arguments to pass to the jukebox mpv daemon (optional)")
@@ -84,12 +85,13 @@ 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 confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-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 mutli-valued track artist scanning (optional)") flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for multi-valued track artist scanning (optional)")
flag.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)") flag.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for multi-valued album artist scanning (optional)")
confPprof := flag.Bool("pprof", false, "enable the /debug/pprof endpoint (optional)") confPprof := flag.Bool("pprof", false, "enable the /debug/pprof endpoint (optional)")
confExpvar := flag.Bool("expvar", false, "enable the /debug/vars endpoint (optional)") confExpvar := flag.Bool("expvar", false, "enable the /debug/vars endpoint (optional)")
confLogDB := flag.Bool("log-db", false, "enable database query logging (optional)")
deprecatedConfGenreSplit := flag.String("genre-split", "", "(deprecated, see multi-value settings)") deprecatedConfGenreSplit := flag.String("genre-split", "", "(deprecated, see multi-value settings)")
@@ -139,7 +141,7 @@ func main() {
log.Fatalf("couldn't create covers cache path: %v\n", err) log.Fatalf("couldn't create covers cache path: %v\n", err)
} }
dbc, err := db.New(*confDBPath, db.DefaultOptions()) dbc, err := db.New(*confDBPath, deps.DBDriverOptions(), *confLogDB)
if err != nil { if err != nil {
log.Fatalf("error opening database: %v\n", err) log.Fatalf("error opening database: %v\n", err)
} }
@@ -180,14 +182,10 @@ func main() {
log.Printf("provided config\n") log.Printf("provided config\n")
flag.VisitAll(func(f *flag.Flag) { flag.VisitAll(func(f *flag.Flag) {
value := strings.ReplaceAll(f.Value.String(), "\n", "") value := strings.ReplaceAll(f.Value.String(), "\n", "")
log.Printf(" %-25s %s\n", f.Name, value) log.Printf(" %-30s %s\n", f.Name, value)
}) })
tagReader := tagcommon.ChainReader{ tagReader := deps.TagReader
taglib.TagLib{},
// ffprobe reader?
// nfo reader?
}
scannr := scanner.New( scannr := scanner.New(
ctrlsubsonic.MusicPaths(musicPaths), ctrlsubsonic.MusicPaths(musicPaths),
@@ -199,6 +197,7 @@ func main() {
}, },
tagReader, tagReader,
*confExcludePattern, *confExcludePattern,
*confScanEmbeddedCover,
) )
podcast := podcast.New(dbc, *confPodcastPath, tagReader) podcast := podcast.New(dbc, *confPodcastPath, tagReader)
transcoder := transcode.NewCachingTranscoder( transcoder := transcode.NewCachingTranscoder(
@@ -258,7 +257,7 @@ func main() {
if err != nil { if err != nil {
log.Panicf("error creating admin controller: %v\n", err) log.Panicf("error creating admin controller: %v\n", err)
} }
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, resolveProxyPath) ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *defaultMusicPath, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath)
if err != nil { if err != nil {
log.Panicf("error creating subsonic controller: %v\n", err) log.Panicf("error creating subsonic controller: %v\n", err)
} }
+81 -85
View File
@@ -1,7 +1,6 @@
package db package db
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"log" "log"
@@ -13,69 +12,76 @@ import (
"time" "time"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/mattn/go-sqlite3"
// TODO: remove this dep // TODO: remove this dep
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
) )
func DefaultOptions() url.Values {
return url.Values{
// with this, multiple connections share a single data and schema cache.
// see https://www.sqlite.org/sharedcache.html
"cache": {"shared"},
// with this, the db sleeps for a little while when locked. can prevent
// a SQLITE_BUSY. see https://www.sqlite.org/c3ref/busy_timeout.html
"_busy_timeout": {"30000"},
"_journal_mode": {"WAL"},
"_foreign_keys": {"true"},
}
}
func mockOptions() url.Values {
return url.Values{
"_foreign_keys": {"true"},
}
}
type DB struct { type DB struct {
*gorm.DB *gorm.DB
} }
func New(path string, options url.Values) (*DB, error) { func New(path string, opts url.Values, logQueries bool) (*DB, error) {
// https://github.com/mattn/go-sqlite3#connection-string u := url.URL{
url := url.URL{
Scheme: "file", Scheme: "file",
Opaque: path, Opaque: path,
RawQuery: opts.Encode(),
} }
url.RawQuery = options.Encode()
db, err := gorm.Open("sqlite3", url.String()) db, err := gorm.Open("sqlite3", u.String())
if err != nil { if err != nil {
return nil, fmt.Errorf("with gorm: %w", err) return nil, fmt.Errorf("with gorm: %w", err)
} }
db.SetLogger(log.New(os.Stdout, "gorm ", 0)) db.SetLogger(log.New(os.Stdout, "gorm ", 0))
db.DB().SetMaxOpenConns(1) if logQueries {
db.LogMode(true)
}
db.DB().SetMaxOpenConns(4)
return &DB{DB: db}, nil return &DB{DB: db}, nil
} }
func NewMock() (*DB, error) { func NewMock(opts url.Values) (*DB, error) {
return New(":memory:", mockOptions()) d, err := New(":memory:", opts, false)
if err != nil {
return nil, err
}
// in-memory databases can't be shared across multiple connections
d.DB.DB().SetMaxOpenConns(1)
return d, nil
} }
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 []interface{} 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
} }
@@ -136,18 +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 := i + size end := min(i+size, len(data))
if end > len(data) { if err := db.Transaction(func(tx *DB) error {
end = len(data) return cb(tx, data[i:end])
} }); err != nil {
if err := cb(tx, data[i:end]); err != nil {
return err return err
} }
} }
return nil return nil
})
} }
type SettingKey string type SettingKey string
@@ -225,6 +228,7 @@ type Track struct {
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"`
Contributors []*TrackContributor `gorm:"foreignkey:track_id"`
Genres []*Genre `gorm:"many2many:track_genres"` Genres []*Genre `gorm:"many2many:track_genres"`
Size int `sql:"default: null"` Size int `sql:"default: null"`
Length int `sql:"default: null"` Length int `sql:"default: null"`
@@ -235,12 +239,16 @@ type Track struct {
TagTrackNumber int `sql:"default: null"` TagTrackNumber int `sql:"default: null"`
TagDiscNumber int `sql:"default: null"` TagDiscNumber int `sql:"default: null"`
TagBrainzID string `sql:"default: null"` TagBrainzID string `sql:"default: null"`
TagLyrics string `sql:"default: null"`
TagYear int `sql:"default: null"`
ReplayGainTrackGain float32 ReplayGainTrackGain float32
ReplayGainTrackPeak float32 ReplayGainTrackPeak float32
ReplayGainAlbumGain float32 ReplayGainAlbumGain float32
ReplayGainAlbumPeak float32 ReplayGainAlbumPeak float32
HasEmbeddedCover bool
TrackStar *TrackStar TrackStar *TrackStar
TrackRating *TrackRating TrackRating *TrackRating
AverageRating float64 `sql:"default: null"` AverageRating float64 `sql:"default: null"`
@@ -333,6 +341,7 @@ type Album struct {
RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"` RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"`
Genres []*Genre `gorm:"many2many:album_genres"` Genres []*Genre `gorm:"many2many:album_genres"`
Cover string `sql:"default: null"` Cover string `sql:"default: null"`
EmbeddedCoverTrackID *int `sql:"default: null; type:int REFERENCES tracks(id) ON DELETE SET NULL"`
Artists []*Artist `gorm:"many2many:album_artists"` Artists []*Artist `gorm:"many2many:album_artists"`
TagTitle string `sql:"default: null"` TagTitle string `sql:"default: null"`
TagAlbumArtist string // display purposes only TagAlbumArtist string // display purposes only
@@ -348,6 +357,7 @@ type Album struct {
AlbumRating *AlbumRating AlbumRating *AlbumRating
AverageRating float64 `sql:"default: null"` AverageRating float64 `sql:"default: null"`
Play *Play Play *Play
DiscTitles []*AlbumDiscTitle
} }
func (a *Album) SID() *specid.ID { func (a *Album) SID() *specid.ID {
@@ -358,6 +368,10 @@ func (a *Album) ParentSID() *specid.ID {
return &specid.ID{Type: specid.Album, Value: a.ParentID} return &specid.ID{Type: specid.Album, Value: a.ParentID}
} }
func (a *Album) EmbeddedCoverTrackSID() *specid.ID {
return &specid.ID{Type: specid.Track, Value: *a.EmbeddedCoverTrackID}
}
func (a *Album) IndexRightPath() string { func (a *Album) IndexRightPath() string {
if len(a.RightPathUDec) > 0 { if len(a.RightPathUDec) > 0 {
return a.RightPathUDec return a.RightPathUDec
@@ -406,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"`
@@ -421,6 +453,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"` 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 { type AlbumStar struct {
UserID int `gorm:"primary_key; not null" sql:"default: null; type:int REFERENCES users(id) ON DELETE CASCADE"` 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"` AlbumID int `gorm:"primary_key; not null" sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
@@ -622,45 +660,3 @@ func join[T fmt.Stringer](in []T, sep string) string {
} }
return strings.Join(strs, sep) return strings.Join(strs, sep)
} }
func Dump(ctx context.Context, db *gorm.DB, to string) error {
dest, err := New(to, url.Values{})
if err != nil {
return fmt.Errorf("create dest db: %w", err)
}
defer dest.Close()
connSrc, err := db.DB().Conn(ctx)
if err != nil {
return fmt.Errorf("getting src raw conn: %w", err)
}
defer connSrc.Close()
connDest, err := dest.DB.DB().Conn(ctx)
if err != nil {
return fmt.Errorf("getting dest raw conn: %w", err)
}
defer connDest.Close()
err = connDest.Raw(func(connDest interface{}) error {
return connSrc.Raw(func(connSrc interface{}) error {
connDestq := connDest.(*sqlite3.SQLiteConn)
connSrcq := connSrc.(*sqlite3.SQLiteConn)
bk, err := connDestq.Backup("main", connSrcq, "main")
if err != nil {
return fmt.Errorf("create backup db: %w", err)
}
for done, _ := bk.Step(-1); !done; { //nolint: revive
}
if err := bk.Finish(); err != nil {
return fmt.Errorf("finishing dump: %w", err)
}
return nil
})
})
if err != nil {
return fmt.Errorf("backing up: %w", err)
}
return nil
}
+3 -2
View File
@@ -7,8 +7,9 @@ import (
"os" "os"
"testing" "testing"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.senan.xyz/gonic/deps"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
@@ -22,7 +23,7 @@ func TestGetSetting(t *testing.T) {
key := SettingKey(randKey()) key := SettingKey(randKey())
value := "howdy" value := "howdy"
testDB, err := NewMock() testDB, err := NewMock(deps.DBDriverOptions())
if err != nil { if err != nil {
t.Fatalf("error creating db: %v", err) t.Fatalf("error creating db: %v", err)
} }
+52 -9
View File
@@ -2,7 +2,6 @@
package db package db
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"log" "log"
@@ -59,7 +58,6 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202206101425", migrateUser), construct(ctx, "202206101425", migrateUser),
construct(ctx, "202207251148", migrateStarRating), construct(ctx, "202207251148", migrateStarRating),
construct(ctx, "202211111057", migratePlaylistsQueuesToFullID), construct(ctx, "202211111057", migratePlaylistsQueuesToFullID),
constructNoTx(ctx, "202212272312", backupDBPre016),
construct(ctx, "202304221528", migratePlaylistsToM3U), construct(ctx, "202304221528", migratePlaylistsToM3U),
construct(ctx, "202305301718", migratePlayCountToLength), construct(ctx, "202305301718", migratePlayCountToLength),
construct(ctx, "202307281628", migrateAlbumArtistsMany2Many), construct(ctx, "202307281628", migrateAlbumArtistsMany2Many),
@@ -80,6 +78,13 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID), construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID), construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType), construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
construct(ctx, "202508261102", migrateAddLyrics),
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
construct(ctx, "202601201000", migrateAddAlbumDiscTitles),
construct(ctx, "202602061800", migrateAddTrackYear),
construct(ctx, "202604231200", migrateAddTrackContributors),
} }
return gormigrate. return gormigrate.
@@ -737,13 +742,6 @@ func migratePlaylistsPaths(tx *gorm.DB, ctx MigrationContext) error {
return nil return nil
} }
func backupDBPre016(tx *gorm.DB, ctx MigrationContext) error {
if !ctx.Production {
return nil
}
return Dump(context.Background(), tx, fmt.Sprintf("%s.%d.bak", ctx.DBPath, time.Now().Unix()))
}
func migrateAlbumTagArtistString(tx *gorm.DB, _ MigrationContext) error { func migrateAlbumTagArtistString(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Album{}).Error return tx.AutoMigrate(Album{}).Error
} }
@@ -861,3 +859,48 @@ func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error {
Album{}, Album{},
).Error ).Error
} }
func migrateAddLyrics(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
func migrateAddAlbumEmbeddedCoverTrackID(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Album{}).Error
}
func migrateAddTrackEmbeddedCover(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_albums_created_at ON "albums" (created_at);
`).Error
}
func migrateAddAlbumDiscTitles(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(AlbumDiscTitle{}).Error
}
func migrateAddTrackContributors(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(TrackContributor{}).Error
}
func migrateAddTrackYear(tx *gorm.DB, _ MigrationContext) error {
step := tx.AutoMigrate(Track{})
if err := step.Error; err != nil {
return fmt.Errorf("step auto migrate: %w", err)
}
step = tx.Exec(`
UPDATE tracks
SET tag_year=(SELECT tag_year
FROM albums
WHERE tracks.album_id = albums.id)
`)
if err := step.Error; err != nil {
return fmt.Errorf("step set default track year based on album's : %w", err)
}
return nil
}
+27
View File
@@ -0,0 +1,27 @@
//go:build !nowasm
package deps
import (
"net/url"
// Cgo-free Wasm database
_ "github.com/ncruces/go-sqlite3/driver"
// Cgo-free Wasm tagger
"go.senan.xyz/gonic/tags/taglib"
)
//nolint:gochecknoglobals
var TagReader = taglib.Reader{}
// DBDriverOptions returns SQLite DSN options for the ncruces driver
func DBDriverOptions() url.Values {
return url.Values{
"_pragma": {
"busy_timeout(30000)",
"journal_mode(WAL)",
"foreign_keys(ON)",
},
}
}
+25
View File
@@ -0,0 +1,25 @@
//go:build nowasm
package deps
import (
"net/url"
// Cgo database
_ "github.com/mattn/go-sqlite3"
// Cgo tagger
"go.senan.xyz/gonic/tags/ffprobe"
)
//nolint:gochecknoglobals
var TagReader = ffprobe.Reader{}
// DSNOptions returns SQLite DSN options for the mattn driver
func DBDriverOptions() url.Values {
return url.Values{
"_busy_timeout": {"30000"},
"_journal_mode": {"WAL"},
"_foreign_keys": {"true"},
}
}
+5 -1
View File
@@ -14,9 +14,13 @@ import (
var nonAlphaNumExpr = regexp.MustCompile("[^a-zA-Z0-9_.]+") var nonAlphaNumExpr = regexp.MustCompile("[^a-zA-Z0-9_.]+")
const maxFilenameLength = 200
func Safe(filename string) string { func Safe(filename string) string {
filename = nonAlphaNumExpr.ReplaceAllString(filename, "") filename = nonAlphaNumExpr.ReplaceAllString(filename, "")
return filename ext := filepath.Ext(filename)
filename = filename[:min(maxFilenameLength, len(filename))-len(ext)]
return filename + ext
} }
// try to find a unqiue file (or dir) name. incrementing like "example (1)" // try to find a unqiue file (or dir) name. incrementing like "example (1)"
+17
View File
@@ -57,3 +57,20 @@ func TestFirst(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, p("test"), r) require.Equal(t, p("test"), r)
} }
func TestSafe(t *testing.T) {
t.Parallel()
longName := "hi_00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
result := Safe(longName)
require.Equal(t, 200, len(result))
require.Equal(t, longName[:200], result)
longNameWithExt := "hi_00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.mp3"
result = Safe(longNameWithExt)
require.Equal(t, 200, len(result))
require.Equal(t, ".mp3", result[len(result)-4:])
require.Equal(t, "test.mp3", Safe("test.mp3"))
require.Equal(t, "testing.mp3", Safe("test ing.mp3"))
}
+26 -25
View File
@@ -1,14 +1,16 @@
module go.senan.xyz/gonic module go.senan.xyz/gonic
go 1.24 go 1.26.0
require ( require (
github.com/Masterminds/sprig v2.22.0+incompatible github.com/Masterminds/sprig v2.22.0+incompatible
github.com/andybalholm/cascadia v1.3.3 github.com/andybalholm/cascadia v1.3.3
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/dexterlb/mpvipc v0.0.0-20241005113212-7cdefca0e933 github.com/dexterlb/mpvipc v0.0.0-20241005113212-7cdefca0e933
github.com/disintegration/imaging v1.6.2 github.com/disintegration/imaging v1.6.2
github.com/djherbis/times v1.6.0 github.com/djherbis/times v1.6.0
github.com/dustin/go-humanize v1.0.1 github.com/dustin/go-humanize v1.0.1
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/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
@@ -17,57 +19,56 @@ require (
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.32 github.com/mattn/go-sqlite3 v1.14.42
github.com/microcosm-cc/bluemonday v1.0.27
github.com/mitchellh/mapstructure v1.5.0 github.com/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.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
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.11.1
go.senan.xyz/flagconf v0.1.9 go.senan.xyz/flagconf v0.1.11
go.senan.xyz/wrtag v0.16.0 go.senan.xyz/taglib v0.11.1
golang.org/x/net v0.43.0 go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb
golang.org/x/sync v0.16.0 golang.org/x/net v0.53.0
golang.org/x/sync v0.20.0
gopkg.in/gormigrate.v1 v1.6.0 gopkg.in/gormigrate.v1 v1.6.0
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056
) )
require ( require (
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.10.3 // indirect github.com/PuerkitoBio/goquery v1.12.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/jsonpointer v0.21.2 // indirect github.com/go-openapi/jsonpointer v0.23.1 // indirect
github.com/go-openapi/swag 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/huandu/xstrings v1.5.0 // indirect github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect github.com/imdario/mergo v0.3.16 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect github.com/jinzhu/now v1.1.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // 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/lib/pq v1.3.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect
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/olekukonko/tablewriter v1.0.9 // indirect github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0 // indirect
github.com/ncruces/julianday v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect github.com/tetratelabs/wazero v1.11.0 // indirect
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect golang.org/x/crypto v0.50.0 // indirect
golang.org/x/crypto v0.41.0 // indirect golang.org/x/image v0.39.0 // indirect
golang.org/x/image v0.30.0 // indirect golang.org/x/sys v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect golang.org/x/text v0.36.0 // indirect
golang.org/x/text v0.28.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/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
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )
// https://github.com/jaytaylor/html2text/issues/67
replace github.com/olekukonko/tablewriter => github.com/olekukonko/tablewriter v0.0.5
+61 -50
View File
@@ -6,11 +6,15 @@ 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.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo= github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo=
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y= github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.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=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -25,16 +29,20 @@ github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0= github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/env25/mpdlrc v0.7.4 h1:A9If5JKVjgJldaIjJztqkXpUKXlsoRIwXqGK3qS38pY=
github.com/env25/mpdlrc v0.7.4/go.mod h1:Zyhq2WfcYeSJUCtx7mhbXwlh4Xt6mR7HDw0qQh7LvyY=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= 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.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA= github.com/go-openapi/jsonpointer v0.23.1 h1:1HBACs7XIwR2RcmItfdSFlALhGbe6S92p0ry4d1GWg4=
github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk= github.com/go-openapi/jsonpointer v0.23.1/go.mod h1:iWRmZTrGn7XwYhtPt/fvdSFj1OfNBngqRT2UG3BxSqY=
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU= github.com/go-openapi/swag/jsonname v0.26.0 h1:gV1NFX9M8avo0YSpmWogqfQISigCmpaiNci8cGECU5w=
github.com/go-openapi/swag v0.23.1/go.mod h1:STZs8TbRvEQQKUA+JZNAm3EWlgaOBGpyFDqQnDHMef0= 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=
@@ -54,6 +62,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o= github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM= github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
@@ -78,27 +88,25 @@ github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y= github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y=
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM= github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 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/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 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.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.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
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.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo=
github.com/mattn/go-sqlite3 v1.14.32/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/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=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -114,36 +122,40 @@ 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.33.3 h1:6jCR3KuGvJSEwhaQrkHDGeIe2qCQ6nOUDNsPz7ZIotw=
github.com/ncruces/go-sqlite3 v0.33.3/go.mod h1:t2Osfw0wcKzJTgv2EvrkTtVLqlbKTA5Yvwb2ypAlBcY=
github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0 h1:ymE9H30x1AyW5VfMNkJC9teuI2W1jjMsQS7kc6zl6Tg=
github.com/ncruces/go-sqlite3-wasm v1.1.1-0.20260409221933-87e4b35a38d0/go.mod h1:/H3+JykPsfSlvKbOxNSx9kKwm3ecqQGzyCs1e9KkNsU=
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA= github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA=
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4/go.mod h1:Mpa6Hci7lO3vybfdYlWXmH5gEq2vyOmYYjhrlwCTW3w= github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4/go.mod h1:Mpa6Hci7lO3vybfdYlWXmH5gEq2vyOmYYjhrlwCTW3w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ= github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q= github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6 h1:WCZxu77OR9yzKGZugQC1dHhslXROOJT+UL5JCtJbBq8= github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6/go.mod h1:+pmkMFDEXJuu/u4h2OYJVfYF2qIhXJD7kqvWq6q5Zo0=
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/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
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/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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
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= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.senan.xyz/flagconf v0.1.9 h1:LBDmqiVFgijfqFXDzH97gPn0qDbg1Dq6/vxsxS/TzC4= go.senan.xyz/flagconf v0.1.11 h1:ApA9DpoSrfVQlLt8spKJC3fOT7oTEZ2/MmBGMnb9mt4=
go.senan.xyz/flagconf v0.1.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ= go.senan.xyz/flagconf v0.1.11/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
go.senan.xyz/wrtag v0.16.0 h1:Txcl4OXwfLe5PO7agfRGaRD00GLji5wn9qwLFD/aR1E= go.senan.xyz/taglib v0.11.1 h1:S3mO5e3HRRG0Ehw1jLUodYbAJK8TtqdOoNgqkC0D3uU=
go.senan.xyz/wrtag v0.16.0/go.mod h1:XAbiIGbf0DP22RcQBW1n1KeeUTGQU9B6k5A6CGw2j4A= go.senan.xyz/taglib v0.11.1/go.mod h1:qyTl978MnGeZ/ny4d/t0ErLXxysA+39X4+SNSCk56Zs=
go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb h1:hFxxWH6MlgcHZQv2BpkQ1KSp8MSbXMHtN338/HfSzdY=
go.senan.xyz/wrtag v0.30.1-0.20260423121427-fec4b6e433cb/go.mod h1:sWPfwc3FM2O9Ka/l46vDp+/XwLCgywukxgfZipaWrKw=
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-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=
@@ -153,11 +165,11 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.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.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= 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.30.0 h1:jD5RhkmVAnjqaCUXfbGBrn3lpxbknfN9w2UhHHU+5B4= golang.org/x/image v0.39.0 h1:skVYidAEVKgn8lZ602XO75asgXBgLj9G/FE3RbuPFww=
golang.org/x/image v0.30.0/go.mod h1:SAEUTxCCMWSrJcCy/4HwavEsfZZJlYxeHLc6tTiAe/c= 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=
@@ -177,8 +189,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.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.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE= golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg= 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=
@@ -186,8 +198,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.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.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 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=
@@ -202,8 +214,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.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.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= 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=
@@ -222,28 +234,27 @@ 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.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= 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.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= 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=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 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 h1:XpYM6RHQPmzwY7Uyu+t+xxMXc86JYFJn4nEc9HzQjsI=
gopkg.in/gormigrate.v1 v1.6.0/go.mod h1:Lf00lQrHqfSYWiTtPcyQabsDdM6ejZaMgV0OU6JMSlw= gopkg.in/gormigrate.v1 v1.6.0/go.mod h1:Lf00lQrHqfSYWiTtPcyQabsDdM6ejZaMgV0OU6JMSlw=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g=
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:OxvTsCwKosqQ1q7B+8FwXqg4rKZ/UG9dUW+g/VL2xH4=
+2 -1
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[:])
} }
+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 {
+68 -83
View File
@@ -2,7 +2,6 @@
package mockfs package mockfs
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"os" "os"
@@ -12,8 +11,10 @@ import (
"time" "time"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/deps"
"go.senan.xyz/gonic/scanner" "go.senan.xyz/gonic/scanner"
"go.senan.xyz/gonic/tags/tagcommon" "go.senan.xyz/gonic/tags"
"go.senan.xyz/wrtag/tags/normtag"
) )
var ErrPathNotFound = errors.New("path not found") var ErrPathNotFound = errors.New("path not found")
@@ -35,7 +36,7 @@ func NewWithExcludePattern(tb testing.TB, excludePattern string) *MockFS {
func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS { func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
tb.Helper() tb.Helper()
dbc, err := db.NewMock() dbc, err := db.NewMock(deps.DBDriverOptions())
if err != nil { if err != nil {
tb.Fatalf("create db: %v", err) tb.Fatalf("create db: %v", err)
} }
@@ -68,7 +69,7 @@ func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
} }
tagReader := &tagReader{paths: map[string]*TagInfo{}} tagReader := &tagReader{paths: map[string]*TagInfo{}}
scanner := scanner.New(absDirs, dbc, multiValueSettings, tagReader, excludePattern) scanner := scanner.New(absDirs, dbc, multiValueSettings, tagReader, excludePattern, true)
return &MockFS{ return &MockFS{
t: tb, t: tb,
@@ -81,7 +82,7 @@ func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
func (m *MockFS) DB() *db.DB { return m.db } func (m *MockFS) DB() *db.DB { return m.db }
func (m *MockFS) TmpDir() string { return m.dir } func (m *MockFS) TmpDir() string { return m.dir }
func (m *MockFS) TagReader() tagcommon.Reader { return m.tagReader } func (m *MockFS) TagReader() tags.Reader { return m.tagReader }
func (m *MockFS) ScanAndClean() *scanner.State { func (m *MockFS) ScanAndClean() *scanner.State {
m.t.Helper() m.t.Helper()
@@ -116,25 +117,27 @@ func (m *MockFS) AddItemsWithCovers() { m.addItems("", "", tr
func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) } func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) }
func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) { func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
p := func(format string, a ...interface{}) string { p := func(format string, a ...any) string {
return filepath.Join(prefix, fmt.Sprintf(format, a...)) return filepath.Join(prefix, fmt.Sprintf(format, a...))
} }
for ar := 0; ar < 3; ar++ {
for al := 0; al < 3; al++ { for ar := range 3 {
for tr := 0; tr < 3; tr++ { for al := range 3 {
for tr := range 3 {
path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr) path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr)
if !match(onlyGlob, path) { if !match(onlyGlob, path) {
continue continue
} }
m.AddTrack(path) m.AddTrack(path)
m.SetTags(path, func(tags *TagInfo) { m.SetTags(path, func(info *TagInfo) {
tags.RawArtist = fmt.Sprintf("artist-%d", ar) normtag.Set(info.Tags, normtag.Artist, fmt.Sprintf("artist-%d", ar))
tags.RawAlbumArtist = fmt.Sprintf("artist-%d", ar) normtag.Set(info.Tags, normtag.AlbumArtist, fmt.Sprintf("artist-%d", ar))
tags.RawAlbum = fmt.Sprintf("album-%d", al) normtag.Set(info.Tags, normtag.Album, fmt.Sprintf("album-%d", al))
tags.RawTitle = fmt.Sprintf("title-%d", tr) normtag.Set(info.Tags, normtag.Title, fmt.Sprintf("title-%d", tr))
}) })
} }
if covers { if covers {
path := p("artist-%d/album-%d/cover.png", ar, al) path := p("artist-%d/album-%d/cover.png", ar, al)
if !match(onlyGlob, path) { if !match(onlyGlob, path) {
@@ -158,6 +161,21 @@ func (m *MockFS) RemoveAll(path string) {
} }
} }
func (m *MockFS) Move(src, dest string) {
srcAbs := filepath.Join(m.dir, src)
destAbs := filepath.Join(m.dir, dest)
if err := os.MkdirAll(filepath.Dir(destAbs), os.ModePerm); err != nil {
m.t.Fatalf("mkdir: %v", err)
}
if err := os.Rename(srcAbs, destAbs); err != nil {
m.t.Fatalf("rename: %v", err)
}
if info, ok := m.tagReader.paths[srcAbs]; ok {
m.tagReader.paths[destAbs] = info
delete(m.tagReader.paths, srcAbs)
}
}
func (m *MockFS) Symlink(src, dest string) { func (m *MockFS) Symlink(src, dest string) {
if err := os.MkdirAll(filepath.Dir(dest), os.ModePerm); err != nil { if err := os.MkdirAll(filepath.Dir(dest), os.ModePerm); err != nil {
m.t.Fatalf("mkdir: %v", err) m.t.Fatalf("mkdir: %v", err)
@@ -172,7 +190,7 @@ func (m *MockFS) Symlink(src, dest string) {
} }
} }
func (m *MockFS) SetRealAudio(path string, length int, audioPath string) { func (m *MockFS) SetAudio(path string, length time.Duration, bitrate uint, audioPath string) {
abspath := filepath.Join(m.dir, path) abspath := filepath.Join(m.dir, path)
if err := os.Remove(abspath); err != nil { if err := os.Remove(abspath); err != nil {
m.t.Fatalf("remove all: %v", err) m.t.Fatalf("remove all: %v", err)
@@ -182,8 +200,8 @@ func (m *MockFS) SetRealAudio(path string, length int, audioPath string) {
m.t.Fatalf("symlink: %v", err) m.t.Fatalf("symlink: %v", err)
} }
m.SetTags(path, func(tags *TagInfo) { m.SetTags(path, func(tags *TagInfo) {
tags.RawLength = length tags.Length = length
tags.RawBitrate = 0 tags.Bitrate = bitrate
}) })
} }
@@ -288,33 +306,33 @@ func (m *MockFS) AddCover(path string) {
defer f.Close() defer f.Close()
} }
func newTagInfo() *TagInfo {
var info TagInfo
info.Tags = map[string][]string{}
normtag.Set(info.Tags, normtag.TrackNumber, "1")
normtag.Set(info.Tags, normtag.DiscNumber, "1")
normtag.Set(info.Tags, normtag.Date, "2021-01-01")
normtag.Set(info.Tags, normtag.ReleaseType, "Album")
info.Length = 100 * time.Second
info.Bitrate = 100
return &info
}
func (m *MockFS) SetTags(path string, cb func(*TagInfo)) { func (m *MockFS) SetTags(path string, cb func(*TagInfo)) {
absPath := filepath.Join(m.dir, path) absPath := filepath.Join(m.dir, path)
if err := os.Chtimes(absPath, time.Time{}, time.Now()); err != nil { if err := os.Chtimes(absPath, time.Time{}, time.Now()); err != nil {
m.t.Fatalf("touch track: %v", err) m.t.Fatalf("touch track: %v", err)
} }
if _, ok := m.tagReader.paths[absPath]; !ok { if _, ok := m.tagReader.paths[absPath]; !ok {
m.tagReader.paths[absPath] = &TagInfo{} m.tagReader.paths[absPath] = newTagInfo()
} }
cb(m.tagReader.paths[absPath]) cb(m.tagReader.paths[absPath])
} }
func (m *MockFS) DumpDB(suffix ...string) { var _ tags.Reader = (*tagReader)(nil)
var p []string
p = append(p,
"gonic", "dump",
strings.ReplaceAll(m.t.Name(), string(filepath.Separator), "-"),
fmt.Sprint(time.Now().UnixNano()),
)
p = append(p, suffix...)
destPath := filepath.Join(os.TempDir(), strings.Join(p, "-"))
if err := db.Dump(context.Background(), m.db.DB, destPath); err != nil {
m.t.Fatalf("dumping db: %v", err)
}
m.t.Error(destPath)
}
type tagReader struct { type tagReader struct {
paths map[string]*TagInfo paths map[string]*TagInfo
@@ -325,66 +343,33 @@ func (m *tagReader) CanRead(absPath string) bool {
return stat.Mode().IsRegular() return stat.Mode().IsRegular()
} }
func (m *tagReader) Read(absPath string) (tagcommon.Info, error) { func (m *tagReader) Read(absPath string) (tags.Properties, map[string][]string, error) {
p, ok := m.paths[absPath] p, ok := m.paths[absPath]
if !ok { if !ok {
return nil, ErrPathNotFound return tags.Properties{}, nil, ErrPathNotFound
} }
if p.Error != nil { if p.Error != nil {
return nil, p.Error return tags.Properties{}, nil, p.Error
} }
return p, nil
props := tags.Properties{
Length: p.Length,
Bitrate: p.Bitrate,
}
return props, p.Tags, nil
}
func (m *tagReader) ReadCover(absPath string) ([]byte, error) {
return nil, nil
} }
type TagInfo struct { type TagInfo struct {
RawTitle string Tags map[string][]string
RawArtist string Length time.Duration
RawArtists []string Bitrate uint
RawAlbum string
RawAlbumArtist string
RawAlbumArtists []string
RawGenre string
RawBitrate int
RawLength int
Error error Error error
} }
func (i *TagInfo) Title() string { return i.RawTitle }
func (i *TagInfo) BrainzID() string { return "" }
func (i *TagInfo) Artist() string { return i.RawArtist }
func (i *TagInfo) Artists() []string { return i.RawArtists }
func (i *TagInfo) Album() string { return i.RawAlbum }
func (i *TagInfo) AlbumArtist() string { return i.RawAlbumArtist }
func (i *TagInfo) AlbumArtists() []string { return i.RawAlbumArtists }
func (i *TagInfo) AlbumBrainzID() string { return "" }
func (i *TagInfo) Genre() string { return i.RawGenre }
func (i *TagInfo) Genres() []string { return []string{i.RawGenre} }
func (i *TagInfo) TrackNumber() int { return 1 }
func (i *TagInfo) DiscNumber() int { return 1 }
func (i *TagInfo) Year() int { return 2021 }
func (i *TagInfo) Compilation() bool { return false }
func (i *TagInfo) ReleaseType() string { return "album" }
func (i *TagInfo) ReplayGainTrackGain() float32 { return 0 }
func (i *TagInfo) ReplayGainTrackPeak() float32 { return 0 }
func (i *TagInfo) ReplayGainAlbumGain() float32 { return 0 }
func (i *TagInfo) ReplayGainAlbumPeak() float32 { return 0 }
func (i *TagInfo) Length() int { return firstInt(100, i.RawLength) }
func (i *TagInfo) Bitrate() int { return firstInt(100, i.RawBitrate) }
var _ tagcommon.Reader = (*tagReader)(nil)
func firstInt(or int, ints ...int) int {
for _, int := range ints {
if int > 0 {
return int
}
}
return or
}
func match(pattern, name string) bool { func match(pattern, name string) bool {
if pattern == "" { if pattern == "" {
return true return true
+10
View File
@@ -53,6 +53,10 @@ func NewStore(basePath string) (*Store, error) {
}, nil }, nil
} }
func (s *Store) BasePath() string {
return s.basePath
}
// List finds playlist items in s.basePath. // List finds playlist items in s.basePath.
// the expected format is <base path>/<user id>/**/<playlist name>.m3u // the expected format is <base path>/<user id>/**/<playlist name>.m3u
func (s *Store) List() ([]string, error) { func (s *Store) List() ([]string, error) {
@@ -130,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)
} }
@@ -182,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,
} }
+28 -16
View File
@@ -21,7 +21,7 @@ import (
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/fileutil" "go.senan.xyz/gonic/fileutil"
"go.senan.xyz/gonic/tags/tagcommon" "go.senan.xyz/gonic/tags"
) )
var ErrNoAudioInFeedItem = errors.New("no audio in feed item") var ErrNoAudioInFeedItem = errors.New("no audio in feed item")
@@ -34,10 +34,10 @@ type Podcasts struct {
httpClient *http.Client httpClient *http.Client
db *db.DB db *db.DB
baseDir string baseDir string
tagReader tagcommon.Reader tagReader tags.Reader
} }
func New(db *db.DB, base string, tagReader tagcommon.Reader) *Podcasts { func New(db *db.DB, base string, tagReader tags.Reader) *Podcasts {
return &Podcasts{ return &Podcasts{
db: db, db: db,
baseDir: base, baseDir: base,
@@ -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,12 +516,23 @@ 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 {
return fmt.Errorf("fetch podcast audio: unexpected status %s", resp.Status)
}
filename, err := getPodcastEpisodeFilename(podcast, podcastEpisode, resp.Header) filename, err := getPodcastEpisodeFilename(podcast, podcastEpisode, resp.Header)
if err != nil { if err != nil {
return fmt.Errorf("get podcast episode filename: %w", err) return fmt.Errorf("get podcast episode filename: %w", err)
} }
podcastEpisode.Filename = filename podcastEpisode.Filename = filename
if err := p.db.Save(&podcastEpisode).Error; err != nil { if err := p.db.Save(podcastEpisode).Error; err != nil {
return fmt.Errorf("save podcast episode: %w", err) return fmt.Errorf("save podcast episode: %w", err)
} }
if err := os.MkdirAll(filepath.Dir(filepath.Join(podcast.RootDir, podcastEpisode.Filename)), os.ModePerm); err != nil { if err := os.MkdirAll(filepath.Dir(filepath.Join(podcast.RootDir, podcastEpisode.Filename)), os.ModePerm); err != nil {
@@ -525,25 +544,18 @@ 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)
} }
podcastTags, err := p.tagReader.Read(podcastEpisode.AbsPath()) podcastProps, _, err := p.tagReader.Read(podcastEpisode.AbsPath())
if err != nil { if err != nil {
return fmt.Errorf("read podcast tags: %w", err) return fmt.Errorf("read podcast tags: %w", err)
} }
podcastEpisode.Status = db.PodcastEpisodeStatusCompleted podcastEpisode.Status = db.PodcastEpisodeStatusCompleted
podcastEpisode.Bitrate = podcastTags.Bitrate() podcastEpisode.Bitrate = int(podcastProps.Bitrate)
podcastEpisode.Length = podcastTags.Length() podcastEpisode.Length = int(podcastProps.Length.Seconds())
stat, _ := file.Stat() stat, _ := file.Stat()
podcastEpisode.Size = int(stat.Size()) podcastEpisode.Size = int(stat.Size())
+296 -60
View File
@@ -2,6 +2,7 @@
package scanner package scanner
import ( import (
"cmp"
"context" "context"
"errors" "errors"
"fmt" "fmt"
@@ -25,8 +26,9 @@ import (
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/fileutil" "go.senan.xyz/gonic/fileutil"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"go.senan.xyz/gonic/tags/tagcommon" "go.senan.xyz/gonic/tags"
"go.senan.xyz/wrtag/coverparse" "go.senan.xyz/wrtag/coverparse"
"go.senan.xyz/wrtag/tags/normtag"
) )
var ( var (
@@ -38,12 +40,13 @@ type Scanner struct {
db *db.DB db *db.DB
musicDirs []string musicDirs []string
multiValueSettings map[Tag]MultiValueSetting multiValueSettings map[Tag]MultiValueSetting
tagReader tagcommon.Reader tagReader tags.Reader
excludePattern *regexp.Regexp excludePattern *regexp.Regexp
scanEmbeddedCover bool
scanning *int32 scanning *int32
} }
func New(musicDirs []string, db *db.DB, multiValueSettings map[Tag]MultiValueSetting, tagReader tagcommon.Reader, excludePattern string) *Scanner { func New(musicDirs []string, db *db.DB, multiValueSettings map[Tag]MultiValueSetting, tagReader tags.Reader, excludePattern string, scanEmbeddedCover bool) *Scanner {
var excludePatternRegExp *regexp.Regexp var excludePatternRegExp *regexp.Regexp
if excludePattern != "" { if excludePattern != "" {
excludePatternRegExp = regexp.MustCompile(excludePattern) excludePatternRegExp = regexp.MustCompile(excludePattern)
@@ -55,13 +58,14 @@ func New(musicDirs []string, db *db.DB, multiValueSettings map[Tag]MultiValueSet
multiValueSettings: multiValueSettings, multiValueSettings: multiValueSettings,
tagReader: tagReader, tagReader: tagReader,
excludePattern: excludePatternRegExp, excludePattern: excludePatternRegExp,
scanEmbeddedCover: scanEmbeddedCover,
scanning: new(int32), scanning: new(int32),
} }
} }
func (s *Scanner) IsScanning() bool { return atomic.LoadInt32(s.scanning) == 1 } func (s *Scanner) IsScanning() bool { return atomic.LoadInt32(s.scanning) == 1 }
func (s *Scanner) StartScanning() bool { return atomic.CompareAndSwapInt32(s.scanning, 0, 1) } func (s *Scanner) StartScanning() bool { return atomic.CompareAndSwapInt32(s.scanning, 0, 1) }
func (s *Scanner) StopScanning() { defer atomic.StoreInt32(s.scanning, 0) } func (s *Scanner) StopScanning() { atomic.StoreInt32(s.scanning, 0) }
type ScanOptions struct { type ScanOptions struct {
IsFull bool IsFull bool
@@ -101,6 +105,9 @@ func (s *Scanner) ScanAndClean(opts ScanOptions) (*State, error) {
if err := s.cleanAlbums(st); err != nil { if err := s.cleanAlbums(st); err != nil {
return nil, fmt.Errorf("clean albums: %w", err) return nil, fmt.Errorf("clean albums: %w", err)
} }
if err := s.cleanAlbumMetadata(); err != nil {
return nil, fmt.Errorf("clean album metadata: %w", err)
}
if err := s.cleanArtists(st); err != nil { if err := s.cleanArtists(st); err != nil {
return nil, fmt.Errorf("clean artists: %w", err) return nil, fmt.Errorf("clean artists: %w", err)
} }
@@ -181,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 {
@@ -250,16 +258,15 @@ func (s *Scanner) scanCallback(st *State, absPath string, d fs.DirEntry, err err
log.Printf("processing folder %q", absPath) log.Printf("processing folder %q", absPath)
return s.db.Transaction(func(tx *db.DB) error { if err := s.scanDir(st, absPath); err != nil {
if err := s.scanDir(tx, st, absPath); err != nil {
st.errs = append(st.errs, fmt.Errorf("%q: %w", absPath, err)) st.errs = append(st.errs, fmt.Errorf("%q: %w", absPath, err))
return nil return nil
} }
return nil return nil
})
} }
func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error { func (s *Scanner) scanDir(st *State, absPath string) error {
musicDir, relPath := musicDirRelative(s.musicDirs, absPath) musicDir, relPath := musicDirRelative(s.musicDirs, absPath)
if musicDir == absPath { if musicDir == absPath {
return nil return nil
@@ -270,7 +277,7 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
return err return err
} }
var tracks []string var trackPaths []string
var cover string var cover string
for _, item := range items { for _, item := range items {
absPath := filepath.Join(absPath, item.Name()) absPath := filepath.Join(absPath, item.Name())
@@ -282,19 +289,24 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
continue continue
} }
// skip macOS ._ resource fork files
if strings.HasPrefix(item.Name(), "._") {
continue
}
if coverparse.IsCover(item.Name()) { if coverparse.IsCover(item.Name()) {
cover = coverparse.BestBetween(cover, item.Name()) cover = coverparse.BestBetween(cover, item.Name())
continue continue
} }
if s.tagReader.CanRead(absPath) { if s.tagReader.CanRead(absPath) {
tracks = append(tracks, item.Name()) trackPaths = append(trackPaths, item.Name())
continue continue
} }
} }
pdir, pbasename := filepath.Split(filepath.Dir(relPath)) pdir, pbasename := filepath.Split(filepath.Dir(relPath))
var parent db.Album var parent db.Album
if err := tx.Where("root_dir=? AND left_path=? AND right_path=?", musicDir, pdir, pbasename).Assign(db.Album{RootDir: musicDir, LeftPath: pdir, RightPath: pbasename}).FirstOrCreate(&parent).Error; err != nil { if err := s.db.Where("root_dir=? AND left_path=? AND right_path=?", musicDir, pdir, pbasename).Assign(db.Album{RootDir: musicDir, LeftPath: pdir, RightPath: pbasename}).FirstOrCreate(&parent).Error; err != nil {
return fmt.Errorf("first or create parent: %w", err) return fmt.Errorf("first or create parent: %w", err)
} }
@@ -302,46 +314,103 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
dir, basename := filepath.Split(relPath) dir, basename := filepath.Split(relPath)
var album db.Album var album db.Album
if err := populateAlbumBasics(tx, musicDir, &parent, &album, dir, basename, cover); err != nil { if err := populateAlbumBasics(s.db, musicDir, &parent, &album, dir, basename, cover); err != nil {
return fmt.Errorf("populate album basics: %w", err) return fmt.Errorf("populate album basics: %w", err)
} }
st.seenAlbums[album.ID] = struct{}{} st.seenAlbums[album.ID] = struct{}{}
sort.Strings(tracks) if len(trackPaths) == 0 {
for i, basename := range tracks {
absPath := filepath.Join(musicDir, relPath, basename)
if err := s.populateTrackAndArtists(tx, st, i, &album, basename, absPath); err != nil {
return fmt.Errorf("populate track %q: %w", basename, err)
}
}
return nil return nil
} }
var tracks []*db.Track
if err := s.db.Where("album_id=? AND filename IN (?)", album.ID, trackPaths).Find(&tracks).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return fmt.Errorf("query track: %w", err)
}
trackMap := make(map[string]*db.Track, len(tracks))
for _, t := range tracks {
trackMap[t.Filename] = t
st.seenTracks[t.ID] = struct{}{}
}
type trackUpdate struct {
i int
basename string
absPath string
track *db.Track
timeSpec times.Timespec
}
trackUpdates := make([]trackUpdate, 0, len(trackPaths))
sort.Strings(trackPaths)
for i, basename := range trackPaths {
absPath := filepath.Join(musicDir, relPath, basename)
func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db.Album, basename string, absPath string) error {
// useful to get the real create/birth time for filesystems and kernels which support it
timeSpec, err := times.Stat(absPath) timeSpec, err := times.Stat(absPath)
if err != nil { if err != nil {
return fmt.Errorf("get times %q: %w", basename, err) return fmt.Errorf("get times %q: %w", basename, err)
} }
var track db.Track // might be nil if new track
if err := tx.Where("album_id=? AND filename=?", album.ID, filepath.Base(basename)).First(&track).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { track := trackMap[basename]
return fmt.Errorf("query track: %w", err)
if st.isFull || track == nil || timeSpec.ModTime().After(track.UpdatedAt) {
trackUpdates = append(trackUpdates, trackUpdate{
i: i,
basename: basename,
absPath: absPath,
track: track,
timeSpec: timeSpec,
})
}
} }
if !st.isFull && track.ID != 0 && timeSpec.ModTime().Before(track.UpdatedAt) { if len(trackUpdates) == 0 {
st.seenTracks[track.ID] = struct{}{}
return nil return nil
} }
trags, err := s.tagReader.Read(absPath) // 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 { if err != nil {
return fmt.Errorf("%w: %w", err, ErrReadingTags) return fmt.Errorf("read %q: %w: %w", t.basename, err, ErrReadingTags)
}
tagData = append(tagData, trackTagData{trackUpdate: t, trprops: trprops, trags: trags})
} }
genreNames := ParseMulti(s.multiValueSettings[Genre], tagcommon.MustGenres(trags), tagcommon.MustGenre(trags)) return s.db.Transaction(func(tx *db.DB) error {
var discTitles = map[int]string{}
for _, t := range tagData {
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, t.trprops, t.trags, t.basename, t.absPath); err != nil {
return fmt.Errorf("populate track %q: %w", t.basename, err)
}
discNum := cmp.Or(tags.ParseInt(normtag.Get(t.trags, normtag.DiscNumber)), 1)
discSubtitle := normtag.Get(t.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, 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) genreIDs, err := populateGenres(tx, genreNames)
if err != nil { if err != nil {
return fmt.Errorf("populate genres: %w", err) return fmt.Errorf("populate genres: %w", err)
@@ -353,7 +422,7 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
return fmt.Errorf("delete artist appearances: %w", err) return fmt.Errorf("delete artist appearances: %w", err)
} }
albumArtistNames := ParseMulti(s.multiValueSettings[AlbumArtist], tagcommon.MustAlbumArtists(trags), tagcommon.MustAlbumArtist(trags)) albumArtistNames := ParseMulti(s.multiValueSettings[AlbumArtist], tags.MustAlbumArtists(trags), tags.MustAlbumArtist(trags))
var albumArtistIDs []int var albumArtistIDs []int
for _, albumArtistName := range albumArtistNames { for _, albumArtistName := range albumArtistNames {
albumArtist, err := populateArtist(tx, albumArtistName) albumArtist, err := populateArtist(tx, albumArtistName)
@@ -387,14 +456,19 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
if err != nil { if err != nil {
return fmt.Errorf("stating %q: %w", basename, err) return fmt.Errorf("stating %q: %w", basename, err)
} }
if err := populateTrack(tx, album, &track, trags, basename, int(stat.Size())); err != nil {
if track == nil {
track = &db.Track{}
}
if err := populateTrack(tx, s.scanEmbeddedCover, album, track, trprops, trags, basename, int(stat.Size())); err != nil {
return fmt.Errorf("process %q: %w", basename, err) return fmt.Errorf("process %q: %w", basename, err)
} }
if err := populateTrackGenres(tx, &track, genreIDs); err != nil { if err := populateTrackGenres(tx, track, genreIDs); err != nil {
return fmt.Errorf("populate track genres: %w", err) return fmt.Errorf("populate track genres: %w", err)
} }
trackArtistNames := ParseMulti(s.multiValueSettings[Artist], tagcommon.MustArtists(trags), tagcommon.MustArtist(trags)) trackArtistNames := ParseMulti(s.multiValueSettings[Artist], tags.MustArtists(trags), tags.MustArtist(trags))
var trackArtistIDs []int var trackArtistIDs []int
for _, trackArtistName := range trackArtistNames { for _, trackArtistName := range trackArtistNames {
trackArtist, err := populateArtist(tx, trackArtistName) trackArtist, err := populateArtist(tx, trackArtistName)
@@ -403,7 +477,7 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
} }
trackArtistIDs = append(trackArtistIDs, trackArtist.ID) trackArtistIDs = append(trackArtistIDs, trackArtist.ID)
} }
if err := populateTrackArtists(tx, &track, trackArtistIDs); err != nil { if err := populateTrackArtists(tx, track, trackArtistIDs); err != nil {
return fmt.Errorf("populate track artists: %w", err) return fmt.Errorf("populate track artists: %w", err)
} }
@@ -411,28 +485,66 @@ 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
if i == 0 {
if err := populateAlbumEmbeddedCover(tx, s.scanEmbeddedCover, album, track, trprops); err != nil {
return fmt.Errorf("populate embedded cover: %w", err)
}
}
st.seenTracks[track.ID] = struct{}{} st.seenTracks[track.ID] = struct{}{}
st.seenTracksNew++ st.seenTracksNew++
return nil return nil
} }
func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime, createTime time.Time) error { func populateAlbumEmbeddedCover(tx *db.DB, scanEmbeddedCover bool, album *db.Album, track *db.Track, trprops tags.Properties) error {
albumName := tagcommon.MustAlbum(trags) var trackID int
if scanEmbeddedCover && trprops.HasCover {
trackID = track.ID
}
var prevTrackID int
if album.EmbeddedCoverTrackID != nil {
prevTrackID = *album.EmbeddedCoverTrackID
}
if prevTrackID == trackID {
return nil
}
album.EmbeddedCoverTrackID = nil
if trackID > 0 {
album.EmbeddedCoverTrackID = &trackID
}
if err := tx.Save(album).Error; err != nil {
return fmt.Errorf("saving album for embedded cover track id: %w", err)
}
return nil
}
func populateAlbum(tx *db.DB, album *db.Album, trags map[string][]string, modTime, createTime time.Time) error {
albumName := tags.MustAlbum(trags)
album.TagTitle = albumName album.TagTitle = albumName
album.TagTitleUDec = decoded(albumName) album.TagTitleUDec = decoded(albumName)
album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags) album.TagAlbumArtist = tags.MustAlbumArtist(trags)
album.TagBrainzID = trags.AlbumBrainzID() album.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzReleaseID)
album.TagYear = trags.Year() album.TagYear = tags.MustYear(trags)
album.TagCompilation = trags.Compilation() album.TagCompilation = tags.ParseBool(normtag.Get(trags, normtag.Compilation))
album.TagReleaseType = trags.ReleaseType() album.TagReleaseType = strings.Join(normtag.Values(trags, normtag.ReleaseType), ", ")
album.ModifiedAt = modTime album.ModifiedAt = modTime
if album.CreatedAt.After(createTime) { if album.CreatedAt.After(createTime) {
album.CreatedAt = createTime // reset created at to match filesytem for new albums album.CreatedAt = createTime // reset created at to match filesytem for new albums
} }
if err := tx.Save(&album).Error; err != nil { if err := tx.Save(album).Error; err != nil {
return fmt.Errorf("saving album: %w", err) return fmt.Errorf("saving album: %w", err)
} }
return nil return nil
@@ -455,37 +567,44 @@ func populateAlbumBasics(tx *db.DB, musicDir string, parent, album *db.Album, di
album.RightPathUDec = decoded(basename) album.RightPathUDec = decoded(basename)
album.ParentID = parent.ID album.ParentID = parent.ID
if err := tx.Save(&album).Error; err != nil { if err := tx.Save(album).Error; err != nil {
return fmt.Errorf("saving album: %w", err) return fmt.Errorf("saving album: %w", err)
} }
return nil return nil
} }
func populateTrack(tx *db.DB, album *db.Album, track *db.Track, trags tagcommon.Info, absPath string, size int) error { func populateTrack(tx *db.DB, scanEmbeddedCover bool, album *db.Album, track *db.Track, trprops tags.Properties, trags map[string][]string, basename string, size int) error {
basename := filepath.Base(absPath)
track.Filename = basename track.Filename = basename
track.FilenameUDec = decoded(basename) track.FilenameUDec = decoded(basename)
track.Size = size track.Size = size
track.AlbumID = album.ID track.AlbumID = album.ID
track.TagLyrics = normtag.Get(trags, normtag.Lyrics)
track.TagTitle = trags.Title() trackTitle := normtag.Get(trags, normtag.Title)
track.TagTitleUDec = decoded(trags.Title()) track.TagTitle = trackTitle
track.TagTrackArtist = tagcommon.MustArtist(trags) track.TagTitleUDec = decoded(trackTitle)
track.TagTrackNumber = trags.TrackNumber() track.TagTrackArtist = tags.MustArtist(trags)
track.TagDiscNumber = trags.DiscNumber() track.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
track.TagBrainzID = trags.BrainzID() track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
track.TagYear = tags.MustYear(trags)
track.ReplayGainTrackGain = trags.ReplayGainTrackGain() track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
track.ReplayGainTrackPeak = trags.ReplayGainTrackPeak() track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
track.ReplayGainAlbumGain = trags.ReplayGainAlbumGain() track.ReplayGainAlbumGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainAlbumGain))
track.ReplayGainAlbumPeak = trags.ReplayGainAlbumPeak() track.ReplayGainAlbumPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainAlbumPeak))
track.HasEmbeddedCover = false
if scanEmbeddedCover {
track.HasEmbeddedCover = trprops.HasCover
}
// these two are calculated from the file instead of tags // these two are calculated from the file instead of tags
track.Length = trags.Length() track.Length = int(trprops.Length.Seconds())
track.Bitrate = trags.Bitrate() track.Bitrate = int(trprops.Bitrate)
if err := tx.Save(&track).Error; err != nil { if err := tx.Save(track).Error; err != nil {
return fmt.Errorf("saving track: %w", err) return fmt.Errorf("saving track: %w", err)
} }
@@ -546,6 +665,24 @@ func populateAlbumGenres(tx *db.DB, album *db.Album, genreIDs []int) error {
return nil 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 { 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 { if err := tx.Where("album_id=?", album.ID).Delete(db.AlbumArtist{}).Error; err != nil {
return fmt.Errorf("delete old album artists: %w", err) return fmt.Errorf("delete old album artists: %w", err)
@@ -557,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)
@@ -619,6 +796,65 @@ func (s *Scanner) cleanAlbums(st *State) error {
}) })
} }
func (s *Scanner) cleanAlbumMetadata() error {
var numModified int
start := time.Now()
defer func() { log.Printf("finished clean album metadata in %s, %d modified", durSince(start), numModified) }()
subTracks := s.db.Model(db.Track{}).Select("DISTINCT album_id").SubQuery()
var emptyAlbumIDs []int
err := s.db.
Model(db.Album{}).
Where("id NOT IN ?", subTracks).
Where("tag_title != '' OR tag_album_artist != ''").
Pluck("id", &emptyAlbumIDs).
Error
if err != nil {
return fmt.Errorf("finding empty albums: %w", err)
}
if len(emptyAlbumIDs) == 0 {
return nil
}
numModified = len(emptyAlbumIDs)
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.AlbumArtist{}).Error; err != nil {
return err
}
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.AlbumGenre{}).Error; err != nil {
return err
}
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{}).
Where("id IN (?)", emptyAlbumIDs).
Updates(map[string]any{
"tag_title": "",
"tag_title_u_dec": "",
"tag_album_artist": "",
"tag_year": 0,
"tag_brainz_id": "",
"tag_compilation": 0,
"tag_release_type": "",
"embedded_cover_track_id": nil,
})
if err := q.Error; err != nil {
return err
}
numModified = int(q.RowsAffected)
return nil
}
func (s *Scanner) cleanArtists(st *State) error { func (s *Scanner) cleanArtists(st *State) error {
start := time.Now() start := time.Now()
defer func() { log.Printf("finished clean artists in %s, %d removed", durSince(start), st.ArtistsMissing()) }() defer func() { log.Printf("finished clean artists in %s, %d removed", durSince(start), st.ArtistsMissing()) }()
+4 -5
View File
@@ -9,21 +9,20 @@ import (
func BenchmarkScanIncremental(b *testing.B) { func BenchmarkScanIncremental(b *testing.B) {
m := mockfs.New(b) m := mockfs.New(b)
for i := 0; i < 5; i++ { for i := range 5 {
m.AddItemsPrefix(fmt.Sprintf("t-%d", i)) m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
} }
m.ScanAndClean() m.ScanAndClean()
b.ResetTimer()
for i := 0; i < b.N; i++ { for b.Loop() {
m.ScanAndClean() m.ScanAndClean()
} }
} }
func BenchmarkScanFull(b *testing.B) { func BenchmarkScanFull(b *testing.B) {
for i := 0; i < b.N; i++ { for b.Loop() {
m := mockfs.New(b) m := mockfs.New(b)
for i := 0; i < 5; i++ { for i := range 5 {
m.AddItemsPrefix(fmt.Sprintf("t-%d", i)) m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
} }
b.StartTimer() b.StartTimer()
+2 -6
View File
@@ -1,6 +1,3 @@
//go:build go1.18
// +build go1.18
package scanner_test package scanner_test
import ( import (
@@ -9,7 +6,6 @@ import (
"reflect" "reflect"
"testing" "testing"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"go.senan.xyz/gonic/mockfs" "go.senan.xyz/gonic/mockfs"
) )
@@ -30,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) {
@@ -43,7 +39,7 @@ func FuzzScanner(f *testing.F) {
}) })
} }
func fuzzStruct(taken int, data []byte, seed int64, dest interface{}) { func fuzzStruct(taken int, data []byte, seed int64, dest any) {
if len(data) == 0 { if len(data) == 0 {
return return
} }
+158 -57
View File
@@ -10,13 +10,15 @@ import (
"testing" "testing"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
_ "go.senan.xyz/gonic/deps"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/mockfs" "go.senan.xyz/gonic/mockfs"
"go.senan.xyz/gonic/scanner" "go.senan.xyz/gonic/scanner"
"go.senan.xyz/wrtag/tags/normtag"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
@@ -122,16 +124,47 @@ func TestCoverBeforeTracks(t *testing.T) {
assert.Equal(t, 3, len(tracks)) // album has tracks assert.Equal(t, 3, len(tracks)) // album has tracks
} }
// https://github.com/sentriz/gonic/issues/638
func TestAlbumArtistsClearedWhenFolderLosesTracks(t *testing.T) {
t.Parallel()
m := mockfs.New(t)
loosePath := "artist-0/fusion.flac"
nestedPath := "artist-0/album-0/track-0.flac"
m.AddTrack(loosePath)
m.SetTags(loosePath, func(tags *mockfs.TagInfo) {
normtag.Set(tags.Tags, normtag.Artist, "artist-0")
normtag.Set(tags.Tags, normtag.AlbumArtist, "artist-0")
normtag.Set(tags.Tags, normtag.Album, "Fusion Firespace")
normtag.Set(tags.Tags, normtag.Title, "Fusion Firespace")
})
m.ScanAndClean()
var albumArtistCount int
require.NoError(t, m.DB().Model(db.AlbumArtist{}).Count(&albumArtistCount).Error)
require.Equal(t, 1, albumArtistCount)
m.Move(loosePath, nestedPath)
m.ScanAndClean()
var postAlbumArtistCount int
require.NoError(t, m.DB().Model(db.AlbumArtist{}).Count(&postAlbumArtistCount).Error)
require.Equal(t, 1, postAlbumArtistCount)
}
func TestUpdatedTags(t *testing.T) { func TestUpdatedTags(t *testing.T) {
t.Parallel() t.Parallel()
m := mockfs.New(t) m := mockfs.New(t)
m.AddTrack("artist-10/album-10/track-10.flac") m.AddTrack("artist-10/album-10/track-10.flac")
m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) {
tags.RawArtist = "artist" normtag.Set(tags.Tags, normtag.Artist, "artist")
tags.RawAlbumArtist = "album-artist" normtag.Set(tags.Tags, normtag.AlbumArtist, "album-artist")
tags.RawAlbum = "album" normtag.Set(tags.Tags, normtag.Album, "album")
tags.RawTitle = "title" normtag.Set(tags.Tags, normtag.Title, "title")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -147,10 +180,10 @@ func TestUpdatedTags(t *testing.T) {
assert.Equal(t, "album-artist", trackArtistA.Name) // track has tags assert.Equal(t, "album-artist", trackArtistA.Name) // track has tags
m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) {
tags.RawArtist = "artist-upd" normtag.Set(tags.Tags, normtag.Artist, "artist-upd")
tags.RawAlbumArtist = "album-artist-upd" normtag.Set(tags.Tags, normtag.AlbumArtist, "album-artist-upd")
tags.RawAlbum = "album-upd" normtag.Set(tags.Tags, normtag.Album, "album-upd")
tags.RawTitle = "title-upd" normtag.Set(tags.Tags, normtag.Title, "title-upd")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -174,7 +207,7 @@ func TestUpdatedAlbumGenre(t *testing.T) {
m.AddItems() m.AddItems()
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawGenre = "gen-a;gen-b" normtag.Set(tags.Tags, normtag.Genre, "gen-a;gen-b")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -184,7 +217,7 @@ func TestUpdatedAlbumGenre(t *testing.T) {
assert.Equal(t, []string{"gen-a", "gen-b"}, genreStrings(album)) assert.Equal(t, []string{"gen-a", "gen-b"}, genreStrings(album))
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawGenre = "gen-a-upd;gen-b-upd" normtag.Set(tags.Tags, normtag.Genre, "gen-a-upd;gen-b-upd")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -279,10 +312,10 @@ func TestGenres(t *testing.T) {
} }
m.AddItems() m.AddItems()
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-a;genre-b" }) m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-a;genre-b") })
m.SetTags("artist-0/album-0/track-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-c;genre-d" }) m.SetTags("artist-0/album-0/track-1.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-c;genre-d") })
m.SetTags("artist-1/album-2/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-e;genre-f" }) m.SetTags("artist-1/album-2/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-e;genre-f") })
m.SetTags("artist-1/album-2/track-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-g;genre-h" }) m.SetTags("artist-1/album-2/track-1.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-g;genre-h") })
m.ScanAndClean() m.ScanAndClean()
isGenre("genre-a") // genre exists isGenre("genre-a") // genre exists
@@ -302,7 +335,7 @@ func TestGenres(t *testing.T) {
isAlbumGenre("artist-0/", "album-0", "genre-a") // album genre exists isAlbumGenre("artist-0/", "album-0", "genre-a") // album genre exists
isAlbumGenre("artist-0/", "album-0", "genre-b") // album genre exists isAlbumGenre("artist-0/", "album-0", "genre-b") // album genre exists
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-aa;genre-bb" }) m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-aa;genre-bb") })
m.ScanAndClean() m.ScanAndClean()
isTrackGenre("artist-0/", "album-0", "track-0.flac", "genre-aa") // updated track genre exists isTrackGenre("artist-0/", "album-0", "track-0.flac", "genre-aa") // updated track genre exists
@@ -363,13 +396,13 @@ func TestNewAlbumForExistingArtist(t *testing.T) {
assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist
assert.Greater(t, artist.ID, 0) assert.Greater(t, artist.ID, 0)
for tr := 0; tr < 3; tr++ { for tr := range 3 {
m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr)) m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr))
m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) { m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) {
tags.RawArtist = "artist-2" normtag.Set(tags.Tags, normtag.Artist, "artist-2")
tags.RawAlbumArtist = "artist-2" normtag.Set(tags.Tags, normtag.AlbumArtist, "artist-2")
tags.RawAlbum = "new-album" normtag.Set(tags.Tags, normtag.Album, "new-album")
tags.RawTitle = fmt.Sprintf("title-%d", tr) normtag.Set(tags.Tags, normtag.Title, fmt.Sprintf("title-%d", tr))
}) })
} }
@@ -390,19 +423,19 @@ func TestMultiFolderWithSharedArtist(t *testing.T) {
m.AddTrack(fmt.Sprintf("m-0/%s/album-a/track-1.flac", artistName)) m.AddTrack(fmt.Sprintf("m-0/%s/album-a/track-1.flac", artistName))
m.SetTags(fmt.Sprintf("m-0/%s/album-a/track-1.flac", artistName), func(tags *mockfs.TagInfo) { m.SetTags(fmt.Sprintf("m-0/%s/album-a/track-1.flac", artistName), func(tags *mockfs.TagInfo) {
tags.RawArtist = artistName normtag.Set(tags.Tags, normtag.Artist, artistName)
tags.RawAlbumArtist = artistName normtag.Set(tags.Tags, normtag.AlbumArtist, artistName)
tags.RawAlbum = "album-a" normtag.Set(tags.Tags, normtag.Album, "album-a")
tags.RawTitle = "track-1" normtag.Set(tags.Tags, normtag.Title, "track-1")
}) })
m.ScanAndClean() m.ScanAndClean()
m.AddTrack(fmt.Sprintf("m-1/%s/album-a/track-1.flac", artistName)) m.AddTrack(fmt.Sprintf("m-1/%s/album-a/track-1.flac", artistName))
m.SetTags(fmt.Sprintf("m-1/%s/album-a/track-1.flac", artistName), func(tags *mockfs.TagInfo) { m.SetTags(fmt.Sprintf("m-1/%s/album-a/track-1.flac", artistName), func(tags *mockfs.TagInfo) {
tags.RawArtist = artistName normtag.Set(tags.Tags, normtag.Artist, artistName)
tags.RawAlbumArtist = artistName normtag.Set(tags.Tags, normtag.AlbumArtist, artistName)
tags.RawAlbum = "album-a" normtag.Set(tags.Tags, normtag.Album, "album-a")
tags.RawTitle = "track-1" normtag.Set(tags.Tags, normtag.Title, "track-1")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -428,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"})
@@ -462,10 +563,10 @@ func TestSymlinkedSubdiscs(t *testing.T) {
p := fmt.Sprintf("%s/%s/%s/%s/%s", prefix, artist, album, disc, track) p := fmt.Sprintf("%s/%s/%s/%s/%s", prefix, artist, album, disc, track)
m.AddTrack(p) m.AddTrack(p)
m.SetTags(p, func(tags *mockfs.TagInfo) { m.SetTags(p, func(tags *mockfs.TagInfo) {
tags.RawArtist = artist normtag.Set(tags.Tags, normtag.Artist, artist)
tags.RawAlbumArtist = artist normtag.Set(tags.Tags, normtag.AlbumArtist, artist)
tags.RawAlbum = album normtag.Set(tags.Tags, normtag.Album, album)
tags.RawTitle = track normtag.Set(tags.Tags, normtag.Title, track)
}) })
} }
@@ -552,14 +653,14 @@ func TestCompilationAlbumWithoutAlbumArtist(t *testing.T) {
const toAdd = 5 const toAdd = 5
// add tracks to one folder with random artists and no album artist tag // add tracks to one folder with random artists and no album artist tag
for i := 0; i < toAdd; i++ { for i := range toAdd {
p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i) p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i)
m.AddTrack(p) m.AddTrack(p)
m.SetTags(p, func(tags *mockfs.TagInfo) { m.SetTags(p, func(tags *mockfs.TagInfo) {
// don't set an album artist // don't set an album artist
tags.RawTitle = fmt.Sprintf("track %d", i) normtag.Set(tags.Tags, normtag.Title, fmt.Sprintf("track %d", i))
tags.RawArtist = fmt.Sprintf("artist %d", i) normtag.Set(tags.Tags, normtag.Artist, fmt.Sprintf("artist %d", i))
tags.RawAlbum = pathArtist normtag.Set(tags.Tags, normtag.Album, pathArtist)
}) })
} }
@@ -605,7 +706,7 @@ func TestAlbumAndArtistSameNameWeirdness(t *testing.T) {
const name = "same" const name = "same"
add := func(path string, a ...interface{}) { add := func(path string, a ...any) {
m.AddTrack(fmt.Sprintf(path, a...)) m.AddTrack(fmt.Sprintf(path, a...))
m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {}) m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {})
} }
@@ -627,10 +728,10 @@ func TestNoOrphanedGenres(t *testing.T) {
m := mockfs.New(t) m := mockfs.New(t)
m.AddItems() m.AddItems()
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-a;genre-b" }) m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-a;genre-b") })
m.SetTags("artist-0/album-0/track-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-c;genre-d" }) m.SetTags("artist-0/album-0/track-1.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-c;genre-d") })
m.SetTags("artist-1/album-2/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-e;genre-f" }) m.SetTags("artist-1/album-2/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-e;genre-f") })
m.SetTags("artist-1/album-2/track-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-g;genre-h" }) m.SetTags("artist-1/album-2/track-1.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-g;genre-h") })
m.ScanAndClean() m.ScanAndClean()
m.RemoveAll("artist-0") m.RemoveAll("artist-0")
@@ -649,7 +750,7 @@ func TestNoOrphanedGenresButOnlyDeleteTracks(t *testing.T) {
m := mockfs.New(t) m := mockfs.New(t)
m.AddItems() m.AddItems()
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-a" }) m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { normtag.Set(tags.Tags, normtag.Genre, "genre-a") })
m.ScanAndClean() m.ScanAndClean()
trackPaths, err := filepath.Glob(filepath.Join(m.TmpDir(), "*", "*", "*.flac")) trackPaths, err := filepath.Glob(filepath.Join(m.TmpDir(), "*", "*", "*.flac"))
@@ -684,16 +785,16 @@ func TestMultiArtistSupport(t *testing.T) {
m.AddItemsGlob("artist-0/album-[012]/track-0.*") m.AddItemsGlob("artist-0/album-[012]/track-0.*")
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Mutator" normtag.Set(tags.Tags, normtag.Album, "Mutator")
tags.RawAlbumArtists = []string{"Alan Vega", "Liz Lamere"} normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Liz Lamere")
}) })
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Dead Man" normtag.Set(tags.Tags, normtag.Album, "Dead Man")
tags.RawAlbumArtists = []string{"Alan Vega", "Mercury Rev"} normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Mercury Rev")
}) })
m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Yerself Is Steam" normtag.Set(tags.Tags, normtag.Album, "Yerself Is Steam")
tags.RawAlbumArtist = "Mercury Rev" normtag.Set(tags.Tags, normtag.AlbumArtist, "Mercury Rev")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -732,8 +833,8 @@ func TestMultiArtistSupport(t *testing.T) {
m.RemoveAll("artist-0/album-2") m.RemoveAll("artist-0/album-2")
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Dead Man" normtag.Set(tags.Tags, normtag.Album, "Dead Man")
tags.RawAlbumArtists = []string{"Alan Vega"} normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega")
}) })
m.ScanAndClean() m.ScanAndClean()
@@ -758,16 +859,16 @@ func TestMultiArtistPreload(t *testing.T) {
m.AddItemsGlob("artist-0/album-[012]/track-0.*") m.AddItemsGlob("artist-0/album-[012]/track-0.*")
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Mutator" normtag.Set(tags.Tags, normtag.Album, "Mutator")
tags.RawAlbumArtists = []string{"Alan Vega", "Liz Lamere"} normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Liz Lamere")
}) })
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Dead Man" normtag.Set(tags.Tags, normtag.Album, "Dead Man")
tags.RawAlbumArtists = []string{"Alan Vega", "Mercury Rev"} normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Mercury Rev")
}) })
m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) { m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) {
tags.RawAlbum = "Yerself Is Steam" normtag.Set(tags.Tags, normtag.Album, "Yerself Is Steam")
tags.RawAlbumArtist = "Mercury Rev" normtag.Set(tags.Tags, normtag.AlbumArtist, "Mercury Rev")
}) })
m.ScanAndClean() m.ScanAndClean()
+1 -1
View File
@@ -271,7 +271,7 @@ func respRaw(h http.HandlerFunc) http.Handler {
type templateData struct { type templateData struct {
// common // common
Flashes []interface{} Flashes []any
User *db.User User *db.User
Version string Version string
+9 -1
View File
@@ -24,6 +24,7 @@ import (
"go.senan.xyz/gonic/scrobble" "go.senan.xyz/gonic/scrobble"
"go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/tags"
"go.senan.xyz/gonic/transcode" "go.senan.xyz/gonic/transcode"
) )
@@ -55,6 +56,7 @@ type Controller struct {
dbc *db.DB dbc *db.DB
scanner *scanner.Scanner scanner *scanner.Scanner
musicPaths []MusicPath musicPaths []MusicPath
defaultMusicPath string
podcastsPath string podcastsPath string
cacheAudioPath string cacheAudioPath string
cacheCoverPath string cacheCoverPath string
@@ -66,16 +68,19 @@ type Controller struct {
lastFMClient *lastfm.Client lastFMClient *lastfm.Client
artistInfoCache *artistinfocache.ArtistInfoCache artistInfoCache *artistinfocache.ArtistInfoCache
albumInfoCache *albuminfocache.AlbumInfoCache albumInfoCache *albuminfocache.AlbumInfoCache
tagReader tags.Reader
resolveProxyPath ProxyPathResolver resolveProxyPath ProxyPathResolver
} }
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, resolveProxyPath ProxyPathResolver) (*Controller, error) { func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, defaultMusicPath string, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, tagReader tags.Reader, resolveProxyPath ProxyPathResolver) (*Controller, error) {
c := Controller{ c := Controller{
ServeMux: http.NewServeMux(), ServeMux: http.NewServeMux(),
dbc: dbc, dbc: dbc,
scanner: scannr, scanner: scannr,
musicPaths: musicPaths, musicPaths: musicPaths,
defaultMusicPath: defaultMusicPath,
podcastsPath: podcastsPath, podcastsPath: podcastsPath,
cacheAudioPath: cacheAudioPath, cacheAudioPath: cacheAudioPath,
cacheCoverPath: cacheCoverPath, cacheCoverPath: cacheCoverPath,
@@ -87,6 +92,8 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
lastFMClient: lastFMClient, lastFMClient: lastFMClient,
artistInfoCache: artistInfoCache, artistInfoCache: artistInfoCache,
albumInfoCache: albumInfoCache, albumInfoCache: albumInfoCache,
tagReader: tagReader,
resolveProxyPath: resolveProxyPath, resolveProxyPath: resolveProxyPath,
} }
@@ -127,6 +134,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
c.Handle("/getSimilarSongs", chain(resp(c.ServeGetSimilarSongs))) c.Handle("/getSimilarSongs", chain(resp(c.ServeGetSimilarSongs)))
c.Handle("/getSimilarSongs2", chain(resp(c.ServeGetSimilarSongsTwo))) c.Handle("/getSimilarSongs2", chain(resp(c.ServeGetSimilarSongsTwo)))
c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics))) c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics)))
c.Handle("/getLyricsBySongId", chain(resp(c.ServeGetLyricsBySongID)))
// raw // raw
c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt))) c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt)))
+6 -4
View File
@@ -13,10 +13,13 @@ import (
"regexp" "regexp"
"strings" "strings"
"testing" "testing"
"time"
jd "github.com/josephburnett/jd/lib" jd "github.com/josephburnett/jd/lib"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
_ "go.senan.xyz/gonic/deps"
"go.senan.xyz/gonic" "go.senan.xyz/gonic"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/mockfs" "go.senan.xyz/gonic/mockfs"
@@ -87,7 +90,6 @@ func makeHTTPMockWithAdmin(query url.Values) (*httptest.ResponseRecorder, *http.
func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) { func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) {
t.Helper() t.Helper()
for _, qc := range cases { for _, qc := range cases {
qc := qc
t.Run(qc.expectPath, func(t *testing.T) { t.Run(qc.expectPath, func(t *testing.T) {
t.Helper() t.Helper()
t.Parallel() t.Parallel()
@@ -143,9 +145,9 @@ func makec(tb testing.TB, roots []string, audio bool) *Controller {
if !audio { if !audio {
continue continue
} }
m.SetRealAudio(filepath.Join(root, "artist-0/album-0/track-0.flac"), 10, audioPath10s) m.SetAudio(filepath.Join(root, "artist-0/album-0/track-0.flac"), 10*time.Second, 0, audioPath10s)
m.SetRealAudio(filepath.Join(root, "artist-0/album-0/track-1.flac"), 10, audioPath10s) m.SetAudio(filepath.Join(root, "artist-0/album-0/track-1.flac"), 10*time.Second, 0, audioPath10s)
m.SetRealAudio(filepath.Join(root, "artist-0/album-0/track-2.flac"), 10, audioPath10s) m.SetAudio(filepath.Join(root, "artist-0/album-0/track-2.flac"), 10*time.Second, 0, audioPath10s)
} }
m.ScanAndClean() m.ScanAndClean()
+3
View File
@@ -42,6 +42,9 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
var track db.Track var track db.Track
err := c.dbc. err := c.dbc.
Preload("Album"). Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Preload("Contributors.Artist").
Find(&track, "id=?", bookmark.EntryID). Find(&track, "id=?", bookmark.EntryID).
Error Error
if err != nil { if err != nil {
+9 -9
View File
@@ -25,7 +25,7 @@ func (c *Controller) ServeGetIndexes(r *http.Request) *spec.Response {
Select("id"). Select("id").
Model(&db.Album{}). Model(&db.Album{}).
Where("parent_id IS NULL") Where("parent_id IS NULL")
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
rootQ = rootQ. rootQ = rootQ.
Where("root_dir=?", m) Where("root_dir=?", m)
} }
@@ -96,7 +96,7 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
Preload("Artists"). Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Order("tag_track_number"). Order("tracks.tag_disc_number, tracks.tag_track_number").
Order("filename"). Order("filename").
Find(&childTracks) Find(&childTracks)
@@ -170,7 +170,7 @@ func (c *Controller) ServeGetAlbumList(r *http.Request) *spec.Response {
return spec.NewError(10, "unknown value %q for parameter 'type'", v) return spec.NewError(10, "unknown value %q for parameter 'type'", v)
} }
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
var folders []*db.Album var folders []*db.Album
@@ -220,7 +220,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
Select("id"). Select("id").
Model(&db.Album{}). Model(&db.Album{}).
Where("parent_id IS NULL") Where("parent_id IS NULL")
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
rootQ = rootQ.Where("root_dir=?", m) rootQ = rootQ.Where("root_dir=?", m)
} }
@@ -261,7 +261,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
Preload("AlbumRating", "user_id=?", user.ID). Preload("AlbumRating", "user_id=?", user.ID).
Offset(params.GetOrInt("albumOffset", 0)). Offset(params.GetOrInt("albumOffset", 0)).
Limit(params.GetOrInt("albumCount", 20)) Limit(params.GetOrInt("albumCount", 20))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
if err := q.Find(&albums).Error; err != nil { if err := q.Find(&albums).Error; err != nil {
@@ -287,7 +287,7 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
Preload("TrackRating", "user_id=?", user.ID). Preload("TrackRating", "user_id=?", user.ID).
Offset(params.GetOrInt("songOffset", 0)). Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20)) Limit(params.GetOrInt("songCount", 20))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q. q = q.
Joins("JOIN albums ON albums.id=tracks.album_id"). Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m) Where("albums.root_dir=?", m)
@@ -324,7 +324,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Select("id"). Select("id").
Model(&db.Album{}). Model(&db.Album{}).
Where("parent_id IS NULL") Where("parent_id IS NULL")
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
rootQ = rootQ.Where("root_dir=?", m) rootQ = rootQ.Where("root_dir=?", m)
} }
@@ -350,7 +350,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Where("album_stars.user_id=?", user.ID). Where("album_stars.user_id=?", user.ID).
Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID) Preload("AlbumRating", "user_id=?", user.ID)
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
if err := q.Find(&albums).Error; err != nil { if err := q.Find(&albums).Error; err != nil {
@@ -369,7 +369,7 @@ func (c *Controller) ServeGetStarred(r *http.Request) *spec.Response {
Preload("Artists"). Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID). Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID) Preload("TrackRating", "user_id=?", user.ID)
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q. q = q.
Joins("JOIN albums ON albums.id=tracks.album_id"). Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m) Where("albums.root_dir=?", m)
@@ -3,8 +3,6 @@ package ctrlsubsonic
import ( import (
"net/url" "net/url"
"testing" "testing"
_ "github.com/jinzhu/gorm/dialects/sqlite"
) )
func TestGetIndexes(t *testing.T) { func TestGetIndexes(t *testing.T) {
+193 -79
View File
@@ -15,6 +15,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/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
@@ -32,7 +33,7 @@ func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
Preload("Info"). Preload("Info").
Group("artists.id"). Group("artists.id").
Order("artists.name COLLATE NOCASE") Order("artists.name COLLATE NOCASE")
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q. q = q.
Joins("JOIN albums ON albums.id=album_artists.album_id"). Joins("JOIN albums ON albums.id=album_artists.album_id").
Where("albums.root_dir=?", m) Where("albums.root_dir=?", m)
@@ -107,10 +108,12 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
Joins("LEFT JOIN tracks ON tracks.album_id=albums.id"). Joins("LEFT JOIN tracks ON tracks.album_id=albums.id").
Preload("Artists"). Preload("Artists").
Preload("Genres"). Preload("Genres").
Preload("DiscTitles").
Preload("Tracks", func(db *gorm.DB) *gorm.DB { Preload("Tracks", func(db *gorm.DB) *gorm.DB {
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)
}). }).
@@ -152,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":
@@ -177,14 +180,14 @@ 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")
default: default:
return spec.NewError(10, "unknown value %q for parameter 'type'", listType) return spec.NewError(10, "unknown value %q for parameter 'type'", listType)
} }
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
var albums []*db.Album var albums []*db.Album
@@ -198,6 +201,8 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
Offset(params.GetOrInt("offset", 0)). Offset(params.GetOrInt("offset", 0)).
Limit(params.GetOrInt("size", 10)). Limit(params.GetOrInt("size", 10)).
Preload("Artists"). Preload("Artists").
Preload("Genres").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID). Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID). Preload("Play", "user_id=?", user.ID).
@@ -250,7 +255,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("Info"). Preload("Info").
Offset(params.GetOrInt("artistOffset", 0)). Offset(params.GetOrInt("artistOffset", 0)).
Limit(params.GetOrInt("artistCount", 20)) Limit(params.GetOrInt("artistCount", 20))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) q = q.Where("albums.root_dir=?", m)
} }
if err := q.Find(&artists).Error; err != nil { if err := q.Find(&artists).Error; err != nil {
@@ -265,6 +270,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
q = c.dbc. q = c.dbc.
Preload("Artists"). Preload("Artists").
Preload("Genres"). Preload("Genres").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID). Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID) Preload("Play", "user_id=?", user.ID)
@@ -278,7 +284,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
q = q. q = q.
Offset(params.GetOrInt("albumOffset", 0)). Offset(params.GetOrInt("albumOffset", 0)).
Limit(params.GetOrInt("albumCount", 20)) Limit(params.GetOrInt("albumCount", 20))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("root_dir=?", m) q = q.Where("root_dir=?", m)
} }
if err := q.Find(&albums).Error; err != nil { if err := q.Find(&albums).Error; err != nil {
@@ -295,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 {
@@ -306,7 +313,7 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
} }
q = q.Offset(params.GetOrInt("songOffset", 0)). q = q.Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20)) Limit(params.GetOrInt("songCount", 20))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q. q = q.
Joins("JOIN albums ON albums.id=tracks.album_id"). Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m) Where("albums.root_dir=?", m)
@@ -447,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{
@@ -473,11 +481,12 @@ 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)).
Limit(params.GetOrInt("count", 10)) Limit(params.GetOrInt("count", 10))
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) q = q.Where("albums.root_dir=?", m)
} }
q = q.Group("tracks.id") q = q.Group("tracks.id")
@@ -518,7 +527,7 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Preload("ArtistRating", "user_id=?", user.ID). Preload("ArtistRating", "user_id=?", user.ID).
Preload("Info"). Preload("Info").
Group("artists.id") Group("artists.id")
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) q = q.Where("albums.root_dir=?", m)
} }
if err := q.Find(&artists).Error; err != nil { if err := q.Find(&artists).Error; err != nil {
@@ -535,10 +544,11 @@ func (c *Controller) ServeGetStarredTwo(r *http.Request) *spec.Response {
Where("album_stars.user_id=?", user.ID). Where("album_stars.user_id=?", user.ID).
Order("album_stars.star_date DESC"). Order("album_stars.star_date DESC").
Preload("Artists"). Preload("Artists").
Preload("DiscTitles").
Preload("AlbumStar", "user_id=?", user.ID). Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID). Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID) Preload("Play", "user_id=?", user.ID)
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) q = q.Where("albums.root_dir=?", m)
} }
if err := q.Find(&albums).Error; err != nil { if err := q.Find(&albums).Error; err != nil {
@@ -557,9 +567,10 @@ 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.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q. q = q.
Joins("JOIN albums ON albums.id=tracks.album_id"). Joins("JOIN albums ON albums.id=tracks.album_id").
Where("albums.root_dir=?", m) Where("albums.root_dir=?", m)
@@ -630,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").
@@ -658,64 +670,31 @@ func (c *Controller) ServeGetSimilarSongs(r *http.Request) *spec.Response {
user := r.Context().Value(CtxUser).(*db.User) user := r.Context().Value(CtxUser).(*db.User)
count := params.GetOrInt("count", 10) count := params.GetOrInt("count", 10)
id, err := params.GetID("id") id, err := params.GetID("id")
if err != nil || id.Type != specid.Track {
return spec.NewError(10, "please provide an track `id` parameter")
}
var track db.Track
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")
}
similarTracks, err := c.lastFMClient.TrackGetSimilarTracks(track.TagTrackArtist, track.TagTitle)
if err != nil { if err != nil {
log.Printf("error fetching similar songs from lastfm: %v", err) return spec.NewError(10, "please provide an `id` parameter")
return spec.NewResponse()
} }
if len(similarTracks.Tracks) == 0 { var tracks []*spec.TrackChild
return spec.NewError(70, "no similar songs found for track: %v", track.TagTitle) 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")
} }
similarTrackNames := make([]string, len(similarTracks.Tracks)) if sub != nil {
for i, t := range similarTracks.Tracks { return sub
similarTrackNames[i] = t.Name
} }
var tracks []*db.Track sub = spec.NewResponse()
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 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{ sub.SimilarSongs = &spec.SimilarSongs{
Tracks: make([]*spec.TrackChild, len(tracks)), Tracks: 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
} }
return sub return sub
} }
@@ -729,22 +708,92 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
return spec.NewError(10, "please provide an artist `id` parameter") return spec.NewError(10, "please provide an artist `id` parameter")
} }
var artist db.Artist 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.
Preload("Album").
Where("id=?", id.Value).
First(&track).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
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 nil, spec.NewResponse()
}
if len(similarTracks.Tracks) == 0 {
return nil, spec.NewError(70, "no similar songs found for track: %v", track.TagTitle)
}
similarTrackNames := make([]string, len(similarTracks.Tracks))
for i, t := range similarTracks.Tracks {
similarTrackNames[i] = t.Name
}
var tracks []*db.Track
err = c.dbc. err = c.dbc.
Select("tracks.*").
Preload("Album").
Preload("Artists").
Preload("Contributors.Artist").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Where("tracks.tag_title IN (?)", similarTrackNames).
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 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 {
trackChildren[i] = spec.NewTrackByTags(track, track.Album)
trackChildren[i].TranscodeMeta = transcodeMeta
}
return trackChildren, nil
}
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.
Where("id=?", id.Value). Where("id=?", id.Value).
First(&artist). First(&artist).
Error Error
if errors.Is(err, gorm.ErrRecordNotFound) { 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) similarArtists, err := c.lastFMClient.ArtistGetSimilar(artist.Name)
if err != nil { if err != nil {
log.Printf("error fetching artist info from lastfm: %v", err) log.Printf("error fetching artist info from lastfm: %v", err)
return spec.NewResponse() return nil, spec.NewResponse()
} }
if len(similarArtists.Artists) == 0 { 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)) artistNames := make([]string, len(similarArtists.Artists))
@@ -756,6 +805,7 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
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").
@@ -767,23 +817,87 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
Find(&tracks). Find(&tracks).
Error Error
if err != nil { 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 { if len(tracks) == 0 {
return spec.NewError(70, "no similar song could be match with collection in database: %v", artist.Name) return nil, 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)),
} }
trackChildren := make([]*spec.TrackChild, len(tracks))
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", "")) transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for i, track := range tracks { for i, track := range tracks {
sub.SimilarSongsTwo.Tracks[i] = spec.NewTrackByTags(track, track.Album) trackChildren[i] = spec.NewTrackByTags(track, track.Album)
sub.SimilarSongsTwo.Tracks[i].TranscodeMeta = transcodeMeta 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("Contributors.Artist").
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 { func starIDsOfType(p params.Params, typ specid.IDT) []int {
+270 -12
View File
@@ -8,10 +8,13 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"slices"
"strings"
"sync" "sync"
"time" "time"
"unicode" "unicode"
"github.com/env25/mpdlrc/lrc"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
@@ -41,6 +44,7 @@ func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Respo
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{ sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{
{Name: "transcodeOffset", Versions: []int{1}}, {Name: "transcodeOffset", Versions: []int{1}},
{Name: "formPost", Versions: []int{1}}, {Name: "formPost", Versions: []int{1}},
{Name: "songLyrics", Versions: []int{1}},
} }
return sub return sub
} }
@@ -96,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 == "" {
@@ -289,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).
@@ -316,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").
@@ -330,7 +336,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
q = q.Joins("JOIN track_genres ON track_genres.track_id=tracks.id") q = q.Joins("JOIN track_genres ON track_genres.track_id=tracks.id")
q = q.Joins("JOIN genres ON genres.id=track_genres.genre_id AND genres.name=?", genre) q = q.Joins("JOIN genres ON genres.id=track_genres.genre_id AND genres.name=?", genre)
} }
if m := getMusicFolder(c.musicPaths, params); m != "" { if m := getMusicFolder(c, params); m != "" {
q = q.Where("albums.root_dir=?", m) q = q.Where("albums.root_dir=?", m)
} }
if err := q.Find(&tracks).Error; err != nil { if err := q.Find(&tracks).Error; err != nil {
@@ -349,7 +355,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
return sub return sub
} }
var errNotATrack = errors.New("not a track") var errUnknownPlaylistEntry = errors.New("unknown playlist entry")
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
if c.jukebox == nil { if c.jukebox == nil {
@@ -387,15 +393,32 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
return nil, fmt.Errorf("get playlist: %w", err) return nil, fmt.Errorf("get playlist: %w", err)
} }
for _, path := range playlist { 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 { if err != nil {
return nil, fmt.Errorf("fetch track: %w", err) return nil, fmt.Errorf("fetch track: %w", err)
} }
track, ok := file.(*db.Track) switch id.Type {
if !ok { case specid.Track:
return nil, fmt.Errorf("%q: %w", path, errNotATrack) var track db.Track
if err := c.dbc.Where("id=?", id.Value).Preload("Album").Preload("Album.Artists").Preload("Artists").Preload("Contributors.Artist").Find(&track).Error; err != nil {
return nil, fmt.Errorf("load track: %w", err)
}
ret = append(ret, spec.NewTrackByTags(&track, track.Album))
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)
} }
ret = append(ret, spec.NewTrackByTags(track, track.Album))
} }
return ret, nil return ret, nil
} }
@@ -482,10 +505,244 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
return sub return sub
} }
func (c *Controller) ServeGetLyrics(_ *http.Request) *spec.Response { func (c *Controller) ServeGetLyrics(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
artist, _ := params.Get("artist")
title, _ := params.Get("title")
var track db.Track
err := c.dbc.
Preload("Album").
Joins("JOIN track_artists ON track_artists.track_id = tracks.id").
Joins("JOIN artists ON artists.id = track_artists.artist_id").
Where("tracks.tag_title LIKE ? AND artists.name LIKE ?", title, artist).
First(&track).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "couldn't find a track with that id")
}
if err != nil {
return spec.NewError(0, "lyrics: %v", err)
}
sub := spec.NewResponse() sub := spec.NewResponse()
sub.Lyrics = &spec.Lyrics{}
sub.Lyrics = &spec.Lyrics{
Artist: track.TagTrackArtist,
Title: track.TagTitle,
Value: "",
}
lyrics, err := lyricsAll(track)
if err != nil {
return spec.NewError(0, "get lyrics: %v", err)
}
if len(lyrics) == 0 {
return sub return sub
}
// prefer unsynced for this endpoint
slices.SortFunc(lyrics, func(a, b *spec.StructuredLyrics) int {
if a.Synced {
return +1
}
return -1
})
lyric := lyrics[0]
var lines []string
for _, l := range lyric.Lines {
lines = append(lines, l.Value)
}
sub.Lyrics.Value = strings.Join(lines, "\n")
return sub
}
func (c *Controller) ServeGetLyricsBySongID(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
id, err := params.GetID("id")
if err != nil {
return spec.NewError(10, "provide an `id` parameter")
}
var track db.Track
q := c.dbc.
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Where("id=?", id.Value).
First(&track)
if err := q.Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "couldn't find a track with that id")
} else {
return spec.NewError(0, "lyrics: %v", err)
}
}
sub := spec.NewResponse()
sub.LyricsList = &spec.LyricsList{
StructuredLyrics: []*spec.StructuredLyrics{},
}
structuredLyrics, err := lyricsAll(track)
if err != nil {
return spec.NewError(0, "get lyrics: %v", err)
}
sub.LyricsList.StructuredLyrics = structuredLyrics
return sub
}
func lyricsAll(track db.Track) ([]*spec.StructuredLyrics, error) {
var r []*spec.StructuredLyrics
fromTags, err := lyricsFromTags(track)
if err != nil {
return nil, fmt.Errorf("from tags: %w", err)
}
if fromTags != nil {
r = append(r, fromTags)
}
fromFile, err := lyricsFromFile(track)
if err != nil {
return nil, fmt.Errorf("from file: %w", err)
}
if fromFile != nil {
r = append(r, fromFile)
}
fromFileUnsynced, err := lyricsFromFileUnsynced(track)
if err != nil {
return nil, fmt.Errorf("from file unsynced: %w", err)
}
if fromFileUnsynced != nil {
r = append(r, fromFileUnsynced)
}
return r, nil
}
func lyricsFromTags(track db.Track) (*spec.StructuredLyrics, error) {
if track.TagLyrics == "" {
return nil, nil
}
r := spec.StructuredLyrics{
Lang: "xxx",
DisplayArtist: track.TagTrackArtist,
DisplayTitle: track.TagTitle,
}
times, lrc, err := lrc.ParseString(track.TagLyrics)
if err != nil {
return nil, err
}
if len(times) > 0 {
lines := make([]spec.Lyric, len(times))
for i, time := range times {
start := time.Milliseconds()
lines[i] = spec.Lyric{
Start: &start,
Value: strings.TrimSpace(lrc[i]),
}
}
r.Synced = true
r.Lines = lines
return &r, nil
}
rawLines := strings.Split(track.TagLyrics, "\n")
lines := make([]spec.Lyric, 0, len(rawLines))
for _, line := range rawLines {
lines = append(lines, spec.Lyric{
Value: strings.TrimSpace(line),
})
}
r.Lines = lines
return &r, nil
}
func lyricsFromFile(track db.Track) (*spec.StructuredLyrics, error) {
filePath := track.AbsPath()
fileDir := filepath.Dir(filePath)
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
lrcContent, err := os.ReadFile(filepath.Join(fileDir, fileName+".lrc"))
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
if err != nil {
return nil, err
}
times, lrc, err := lrc.Parse(lrcContent)
if err != nil {
return nil, err
}
lines := make([]spec.Lyric, len(times))
for i, time := range times {
start := time.Milliseconds()
lines[i] = spec.Lyric{
Start: &start,
Value: strings.TrimSpace(lrc[i]),
}
}
r := spec.StructuredLyrics{
Lang: "xxx",
Synced: true,
Lines: lines,
DisplayArtist: track.TagTrackArtist,
DisplayTitle: track.TagTitle,
}
return &r, nil
}
func lyricsFromFileUnsynced(track db.Track) (*spec.StructuredLyrics, error) {
filePath := track.AbsPath()
fileDir := filepath.Dir(filePath)
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
text, err := os.ReadFile(filepath.Join(fileDir, fileName+".txt"))
if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
if err != nil {
return nil, err
}
r := spec.StructuredLyrics{
Lang: "xxx",
DisplayArtist: track.TagTrackArtist,
DisplayTitle: track.TagTitle,
}
rawLines := strings.Split(string(text), "\n")
lines := make([]spec.Lyric, 0, len(rawLines))
for _, line := range rawLines {
lines = append(lines, spec.Lyric{
Value: strings.TrimSpace(line),
})
}
r.Lines = lines
return &r, nil
} }
func scrobbleStatsUpdateTrack(dbc *db.DB, track *db.Track, userID int, playTime time.Time) error { func scrobbleStatsUpdateTrack(dbc *db.DB, track *db.Track, userID int, playTime time.Time) error {
@@ -522,10 +779,11 @@ func scrobbleStatsUpdatePodcastEpisode(dbc *db.DB, peID int) error {
return nil return nil
} }
func getMusicFolder(musicPaths []MusicPath, p params.Params) string { func getMusicFolder(c *Controller, p params.Params) string {
musicPaths := c.musicPaths
idx, err := p.GetInt("musicFolderId") idx, err := p.GetInt("musicFolderId")
if err != nil { if err != nil {
return "" return c.defaultMusicPath
} }
if idx < 0 || idx >= len(musicPaths) { if idx < 0 || idx >= len(musicPaths) {
return os.DevNull return os.DevNull
+23 -14
View File
@@ -39,7 +39,7 @@ func (c *Controller) ServeGetPlaylists(r *http.Request) *spec.Response {
continue continue
} }
playlistID := playlistIDEncode(path) playlistID := playlistIDEncode(path)
rendered, err := playlistRender(c, params, playlistID, playlist, false) rendered, err := playlistRender(c, params, playlist, playlistID, false)
if err != nil { if err != nil {
return spec.NewError(0, "error rendering playlist %q: %v", path, err) 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 { func (c *Controller) ServeGetPlaylist(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params) params := r.Context().Value(CtxParams).(params.Params)
playlistID, err := params.GetFirst("id", "playlistId") playlistID, err := params.GetFirstID("id", "playlistId")
if err != nil { if err != nil {
return spec.NewError(10, "please provide an `id` parameter") 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) return spec.NewError(70, "playlist with id %s not found", playlistID)
} }
sub := spec.NewResponse() sub := spec.NewResponse()
rendered, err := playlistRender(c, params, playlistID, playlist, true) rendered, err := playlistRender(c, params, playlist, playlistID, true)
if err != nil { if err != nil {
return spec.NewError(0, "error rendering playlist: %v", err) 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) user := r.Context().Value(CtxUser).(*db.User)
params := r.Context().Value(CtxParams).(params.Params) params := r.Context().Value(CtxParams).(params.Params)
playlistID := params.GetFirstOr( /* default */ "", "id", "playlistId") playlistID, _ := params.GetFirstID("id", "playlistId")
playlistPath := playlistIDDecode(playlistID) playlistPath := playlistIDDecode(playlistID)
var playlist playlistp.Playlist var playlist playlistp.Playlist
@@ -112,7 +112,7 @@ func (c *Controller) ServeCreateOrUpdatePlaylist(r *http.Request) *spec.Response
} }
sub := spec.NewResponse() sub := spec.NewResponse()
rendered, err := playlistRender(c, params, playlistID, &playlist, true) rendered, err := playlistRender(c, params, &playlist, playlistID, true)
if err != nil { if err != nil {
return spec.NewError(0, "error rendering playlist: %v", err) 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) user := r.Context().Value(CtxUser).(*db.User)
params := r.Context().Value(CtxParams).(params.Params) 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) playlistPath := playlistIDDecode(playlistID)
playlist, err := c.playlistStore.Read(playlistPath) playlist, err := c.playlistStore.Read(playlistPath)
if err != nil { 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 { func (c *Controller) ServeDeletePlaylist(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params) 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 { if err := c.playlistStore.Delete(playlistIDDecode(playlistID)); err != nil {
return spec.NewError(0, "delete playlist: %v", err) return spec.NewError(0, "delete playlist: %v", err)
} }
return spec.NewResponse() return spec.NewResponse()
} }
func playlistIDEncode(path string) string { func playlistIDEncode(path string) specid.ID {
return base64.URLEncoding.EncodeToString([]byte(path)) return specid.ID{
Type: specid.Playlist,
StringValue: base64.URLEncoding.EncodeToString([]byte(path)),
}
} }
func playlistIDDecode(id string) string { func playlistIDDecode(id specid.ID) string {
path, _ := base64.URLEncoding.DecodeString(id) path, _ := base64.URLEncoding.DecodeString(id.StringValue)
return string(path) 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{} user := &db.User{}
if err := c.dbc.Where("id=?", playlist.UserID).Find(user).Error; err != nil { if err := c.dbc.Where("id=?", playlist.UserID).Find(user).Error; err != nil {
return nil, fmt.Errorf("find user by id: %w", err) 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", "")) transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for _, path := range playlist.Items { 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 { if err != nil {
log.Printf("error looking up path %q: %s", path, err) log.Printf("error looking up path %q: %s", path, err)
continue continue
} }
var trch *spec.TrackChild var trch *spec.TrackChild
switch id := file.SID(); 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").Preload("TrackStar", "user_id=?", user.ID).Preload("TrackRating", "user_id=?", user.ID).Find(&track).Error; errors.Is(err, gorm.ErrRecordNotFound) { 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) {
+12 -13
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{}
@@ -44,17 +47,13 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
} }
func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response { func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response {
user := r.Context().Value(CtxUser).(*db.User)
if !user.IsAdmin {
return spec.NewError(50, "user not admin")
}
params := r.Context().Value(CtxParams).(params.Params) params := r.Context().Value(CtxParams).(params.Params)
id, err := params.GetID("id") id, err := params.GetID("id")
if err != nil || id.Type != specid.PodcastEpisode { if err != nil || id.Type != specid.PodcastEpisode {
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()
} }
@@ -69,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()
} }
@@ -83,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()
} }
@@ -99,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()
} }
@@ -115,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()
} }
+130 -32
View File
@@ -5,22 +5,27 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"image"
"io" "io"
"log" "log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"time" "time"
"github.com/disintegration/imaging" "github.com/disintegration/imaging"
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"go.senan.xyz/wrtag/coverparse"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/infocache/artistinfocache" "go.senan.xyz/gonic/infocache/artistinfocache"
"go.senan.xyz/gonic/playlist"
"go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"go.senan.xyz/gonic/server/ctrlsubsonic/specidpaths" "go.senan.xyz/gonic/server/ctrlsubsonic/specidpaths"
"go.senan.xyz/gonic/tags"
"go.senan.xyz/gonic/transcode" "go.senan.xyz/gonic/transcode"
) )
@@ -32,7 +37,18 @@ import (
const ( const (
coverDefaultSize = 600 coverDefaultSize = 600
coverCacheFormat = "png" )
var (
//nolint:gochecknoglobals
// after the image is decoded with image.Decode, we use the "format" param as the extension
coverCacheFormats = []string{
"jpeg", // from image.RegisterFormat("jpeg") @ image/jpeg/reader.go
"png", // from image.RegisterFormat("png") @ image/png/reader.go
"gif", // from image.RegisterFormat("gif") @ image/gif/reader.go
"bmp", // from image.RegisterFormat("bmp") @ golang.org/x/image/bmp/reader.go
"tiff", // from image.RegisterFormat("tiff") @ golang.org/x/image/tiff/reader.go
}
) )
func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *spec.Response { func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *spec.Response {
@@ -41,33 +57,75 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
if err != nil { if err != nil {
return spec.NewError(10, "please provide an `id` parameter") return spec.NewError(10, "please provide an `id` parameter")
} }
size := params.GetOrInt("size", coverDefaultSize) size := params.GetOrInt("size", coverDefaultSize)
cachePath := filepath.Join( if size <= 0 {
c.cacheCoverPath, return spec.NewError(0, "invalid size")
fmt.Sprintf("%s-%d.%s", id.String(), size, coverCacheFormat), }
)
_, err = os.Stat(cachePath) // cached cover could exist for any supported format
switch { cachePath, err := findCachedCover(c.cacheCoverPath, id.String(), size)
case os.IsNotExist(err): if err != nil && !os.IsNotExist(err) {
reader, err := coverFor(c.dbc, c.artistInfoCache, id) log.Printf("error checking cache: %v", err)
return nil
}
serve := func(p string) {
w.Header().Set("Cache-Control", "public, max-age=1209600")
http.ServeFile(w, r, p)
}
if cachePath != "" {
serve(cachePath)
return nil
}
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()
if err := coverScaleAndSave(reader, cachePath, size); err != nil { img, format, err := image.Decode(reader)
log.Printf("error scaling cover: %v", err) if err != nil {
return nil return spec.NewError(0, "decode for cover %q: %v", id, err)
}
case err != nil:
log.Printf("error stating %q: %v", cachePath, err)
return nil
} }
w.Header().Set("Cache-Control", "public, max-age=1209600") // don't upscale
http.ServeFile(w, r, cachePath) minSize := min(size, max(img.Bounds().Dx(), img.Bounds().Dy()))
cachePath = filepath.Join(c.cacheCoverPath, coverCacheFilename(id.String(), minSize, format))
if minSize != size {
// we down sized, check cache again
if _, err := os.Stat(cachePath); err == nil {
serve(cachePath)
return nil return nil
}
}
resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos)
if err := imaging.Save(resized, cachePath); err != nil {
return spec.NewError(0, "saving cover %q: %v", id, err)
}
serve(cachePath)
return nil
}
func coverCacheFilename(idStr string, size int, format string) string {
return fmt.Sprintf("%s-%d.%s", idStr, size, format)
}
func findCachedCover(cacheDir, idStr string, size int) (string, error) {
for _, format := range coverCacheFormats {
cachePath := filepath.Join(cacheDir, coverCacheFilename(idStr, size, format))
if _, err := os.Stat(cachePath); err == nil {
return cachePath, nil
}
}
return "", os.ErrNotExist
} }
var ( var (
@@ -76,7 +134,7 @@ var (
) )
// TODO: can we use specidpaths.Locate here? // TODO: can we use specidpaths.Locate here?
func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, 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 { switch id.Type {
case specid.Album: case specid.Album:
return coverForAlbum(dbc, id.Value) return coverForAlbum(dbc, id.Value)
@@ -85,7 +143,11 @@ func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, id s
case specid.Podcast: case specid.Podcast:
return coverForPodcast(dbc, id.Value) return coverForPodcast(dbc, id.Value)
case specid.PodcastEpisode: case specid.PodcastEpisode:
return coverGetPathPodcastEpisode(dbc, id.Value) return coverForPodcastEpisode(dbc, id.Value)
case specid.Track:
return coverForTrack(dbc, tagReader, id.Value)
case specid.Playlist:
return coverForPlaylist(playlistStore, id)
default: default:
return nil, errCoverNotFound return nil, errCoverNotFound
} }
@@ -135,7 +197,7 @@ func coverForPodcast(dbc *db.DB, id int) (*os.File, error) {
return os.Open(filepath.Join(podcast.RootDir, podcast.Image)) return os.Open(filepath.Join(podcast.RootDir, podcast.Image))
} }
func coverGetPathPodcastEpisode(dbc *db.DB, id int) (*os.File, error) { func coverForPodcastEpisode(dbc *db.DB, id int) (*os.File, error) {
var pe db.PodcastEpisode var pe db.PodcastEpisode
err := dbc. err := dbc.
Preload("Podcast"). Preload("Podcast").
@@ -150,20 +212,56 @@ func coverGetPathPodcastEpisode(dbc *db.DB, id int) (*os.File, error) {
return os.Open(filepath.Join(pe.Podcast.RootDir, pe.Podcast.Image)) return os.Open(filepath.Join(pe.Podcast.RootDir, pe.Podcast.Image))
} }
func coverScaleAndSave(reader io.Reader, cachePath string, size int) error { func coverForTrack(dbc *db.DB, tagReader tags.Reader, id int) (io.ReadCloser, error) {
src, err := imaging.Decode(reader) var tr db.Track
err := dbc.
Preload("Album").
First(&tr, id).
Error
if err != nil { if err != nil {
return fmt.Errorf("resizing: %w", err) return nil, fmt.Errorf("select track: %w", err)
} }
width := size
if width > src.Bounds().Dx() { absPath := tr.AbsPath()
// don't upscale images
width = src.Bounds().Dx() cover, err := tagReader.ReadCover(absPath)
if err != nil {
return nil, fmt.Errorf("read cover: %w", err)
} }
if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil { if len(cover) == 0 {
return fmt.Errorf("caching %q: %w", cachePath, err) return nil, errCoverEmpty
} }
return nil
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 { func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.Response {
+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()
}
+3 -4
View File
@@ -27,6 +27,7 @@ package params
import ( import (
"errors" "errors"
"maps"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@@ -44,9 +45,7 @@ func New(r *http.Request) Params {
params := r.URL.Query() params := r.URL.Query()
// also if there's any in the post body, use those too // also if there's any in the post body, use those too
if err := r.ParseForm(); err == nil { if err := r.ParseForm(); err == nil {
for k, v := range r.Form { maps.Copy(params, r.Form)
params[k] = v
}
} }
return Params(params) return Params(params)
} }
@@ -389,7 +388,7 @@ func parseTime(in string) (time.Time, error) {
return time.Unix(0, ns), nil return time.Unix(0, ns), nil
} }
func parse(values []string, i interface{}) error { func parse(values []string, i any) error {
if len(values) == 0 { if len(values) == 0 {
return ErrNoValues return ErrNoValues
} }
+30 -11
View File
@@ -3,6 +3,7 @@ package spec
import ( import (
"cmp" "cmp"
"path/filepath" "path/filepath"
"sort"
"go.senan.xyz/gonic/db" "go.senan.xyz/gonic/db"
) )
@@ -19,7 +20,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
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 {
@@ -30,6 +31,8 @@ func NewAlbumByFolder(f *db.Album) *Album {
} }
if f.Cover != "" { if f.Cover != "" {
a.CoverID = f.SID() a.CoverID = f.SID()
} else if f.EmbeddedCoverTrackID != nil {
a.CoverID = f.EmbeddedCoverTrackSID()
} }
return a return a
} }
@@ -41,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 {
@@ -52,7 +55,10 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
} }
if f.Cover != "" { if f.Cover != "" {
trCh.CoverID = f.SID() trCh.CoverID = f.SID()
} else if f.EmbeddedCoverTrackID != nil {
trCh.CoverID = f.EmbeddedCoverTrackSID()
} }
return trCh return trCh
} }
@@ -62,7 +68,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
ContentType: t.MIME(), ContentType: t.MIME(),
Suffix: formatExt(t.Ext()), Suffix: formatExt(t.Ext()),
Size: t.Size, Size: t.Size,
Artist: t.TagTrackArtist, DisplayArtist: t.TagTrackArtist,
Title: cmp.Or(t.TagTitle, t.Filename), Title: cmp.Or(t.TagTitle, t.Filename),
TrackNumber: t.TagTrackNumber, TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber, DiscNumber: t.TagDiscNumber,
@@ -73,20 +79,27 @@ 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
} }
if parent.Cover != "" {
switch {
case t.HasEmbeddedCover:
trCh.CoverID = t.SID()
case parent.Cover != "":
trCh.CoverID = parent.SID() trCh.CoverID = parent.SID()
case parent.EmbeddedCoverTrackID != nil:
trCh.CoverID = parent.EmbeddedCoverTrackSID()
} }
if t.Album != nil { if t.Album != nil {
trCh.Album = t.Album.RightPath trCh.Album = t.Album.RightPath
trCh.AlbumID = t.Album.SID() trCh.AlbumID = t.Album.SID()
@@ -103,10 +116,14 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
for _, g := range t.Genres { for _, g := range t.Genres {
trCh.Genres = append(trCh.Genres, &GenreRef{Name: g.Name}) trCh.Genres = append(trCh.Genres, &GenreRef{Name: g.Name})
} }
for _, a := range t.Artists { sort.Slice(t.Artists, func(i, j int) bool {
if a.Name == t.TagTrackArtist { return t.Artists[i].ID < t.Artists[j].ID
trCh.ArtistID = a.SID() })
if len(t.Artists) > 0 {
trCh.Artist = t.Artists[0].Name
trCh.ArtistID = t.Artists[0].SID()
} }
for _, a := range t.Artists {
trCh.Artists = append(trCh.Artists, &ArtistRef{ID: a.SID(), Name: a.Name}) trCh.Artists = append(trCh.Artists, &ArtistRef{ID: a.SID(), Name: a.Name})
} }
if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 { if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 {
@@ -153,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
@@ -163,6 +180,8 @@ func NewArtistByFolder(f *db.Album) *Artist {
} }
if f.Cover != "" { if f.Cover != "" {
a.CoverID = f.SID() a.CoverID = f.SID()
} else if f.EmbeddedCoverTrackID != nil {
a.CoverID = f.EmbeddedCoverTrackSID()
} }
return a return a
} }
@@ -173,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
+64 -13
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,12 +24,15 @@ 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{},
} }
if a.Cover != "" { if a.Cover != "" {
ret.CoverID = a.SID() ret.CoverID = a.SID()
} else if a.EmbeddedCoverTrackID != nil {
ret.CoverID = a.EmbeddedCoverTrackSID()
} }
if a.AlbumStar != nil { if a.AlbumStar != nil {
ret.Starred = &a.AlbumStar.StarDate ret.Starred = &a.AlbumStar.StarDate
@@ -57,6 +62,17 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
if a.Play != nil { if a.Play != nil {
ret.PlayCount = a.Play.Count 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 return ret
} }
@@ -65,7 +81,6 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
ID: t.SID(), ID: t.SID(),
Album: album.TagTitle, Album: album.TagTitle,
AlbumID: album.SID(), AlbumID: album.SID(),
Artist: t.TagTrackArtist,
Artists: []*ArtistRef{}, Artists: []*ArtistRef{},
DisplayArtist: t.TagTrackArtist, DisplayArtist: t.TagTrackArtist,
AlbumArtists: []*ArtistRef{}, AlbumArtists: []*ArtistRef{},
@@ -84,37 +99,73 @@ 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,
} }
if album.Cover != "" {
switch {
case t.HasEmbeddedCover:
ret.CoverID = t.SID()
case album.Cover != "":
ret.CoverID = album.SID() ret.CoverID = album.SID()
case album.EmbeddedCoverTrackID != nil:
ret.CoverID = album.EmbeddedCoverTrackSID()
} }
if t.TrackStar != nil { if t.TrackStar != nil {
ret.Starred = &t.TrackStar.StarDate ret.Starred = &t.TrackStar.StarDate
} }
if t.TrackRating != nil { if t.TrackRating != nil {
ret.UserRating = t.TrackRating.Rating ret.UserRating = t.TrackRating.Rating
} }
if len(album.Artists) > 0 {
sort.Slice(album.Artists, func(i, j int) bool { slices.SortFunc(t.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.ID) })
return album.Artists[i].ID < album.Artists[j].ID slices.SortFunc(album.Artists, func(a, b *db.Artist) int { return cmp.Compare(a.ID, b.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() 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 { if len(t.Genres) > 0 {
ret.Genre = t.Genres[0].Name ret.Genre = t.Genres[0].Name
} }
for _, g := range t.Genres { for _, g := range t.Genres {
ret.Genres = append(ret.Genres, &GenreRef{Name: g.Name}) 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 { 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,
@@ -132,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()
@@ -10,3 +10,13 @@ func NewInternetRadioStation(irs *db.InternetRadioStation) *InternetRadioStation
HomepageURL: irs.HomepageURL, HomepageURL: irs.HomepageURL,
} }
} }
func NewTCInternetRadioStation(irs *db.InternetRadioStation) *TrackChild {
return &TrackChild{
ID: irs.SID(),
Title: irs.Name,
IsDir: false,
IsVideo: false,
Type: "internetradio",
}
}
+52 -21
View File
@@ -2,14 +2,15 @@ package spec
import ( import (
"fmt" "fmt"
"html"
"regexp" "regexp"
"strings" "strings"
"time" "time"
"unicode" "unicode"
"github.com/microcosm-cc/bluemonday"
"go.senan.xyz/gonic" "go.senan.xyz/gonic"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid" "go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"jaytaylor.com/html2text"
) )
// https://web.archive.org/web/20220707025402/https://www.subsonic.org/pages/api.jsp // https://web.archive.org/web/20220707025402/https://www.subsonic.org/pages/api.jsp
@@ -70,6 +71,7 @@ type Response struct {
SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"` SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"`
InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"` InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"`
Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"` Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"`
LyricsList *LyricsList `xml:"lyricsList" json:"lyricsList,omitempty"`
} }
func NewResponse() *Response { func NewResponse() *Response {
@@ -100,7 +102,7 @@ type Error struct {
Message string `xml:"message,attr" json:"message"` Message string `xml:"message,attr" json:"message"`
} }
func NewError(code int, message string, a ...interface{}) *Response { func NewError(code int, message string, a ...any) *Response {
r := NewResponse() r := NewResponse()
r.Status = "failed" r.Status = "failed"
r.Error = &Error{ r.Error = &Error{
@@ -123,17 +125,28 @@ 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 {
Disc int `xml:"disc,attr" json:"disc"`
Title string `xml:"title,attr" json:"title"`
}
// https://opensubsonic.netlify.app/docs/responses/albumid3/ // https://opensubsonic.netlify.app/docs/responses/albumid3/
type Album struct { type Album struct {
ID *specid.ID `xml:"id,attr,omitempty" json:"id"` ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` Created time.Time `xml:"created,attr,omitempty" json:"created"`
// legacy or single tag mode // legacy or single tag mode
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"` ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Artist string `xml:"artist,attr" json:"artist"` Artist string `xml:"artist,attr" json:"artist"`
Artists []*ArtistRef `xml:"artists" json:"artists"` Artists []*ArtistRef `xml:"artists" json:"artists"`
DisplayArtist string `xml:"diplayArtist,attr" json:"displayArtist"` DisplayArtist string `xml:"displayArtist,attr" json:"displayArtist"`
// folder stuff // folder stuff
Title string `xml:"title,attr,omitempty" json:"title"` Title string `xml:"title,attr,omitempty" json:"title"`
@@ -153,11 +166,12 @@ type Album struct {
IsCompilation bool `xml:"isCompilation" json:"isCompilation"` IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"` ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
DiscTitles []*DiscTitle `xml:"discTitles" json:"discTitles"`
// 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 {
@@ -191,15 +205,18 @@ type TrackChild struct {
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"` ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Artists []*ArtistRef `xml:"artists" json:"artists"` 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"` AlbumArtists []*ArtistRef `xml:"albumArtists" json:"albumArtists"`
AlbumDisplayArtist string `xml:"diplayAlbumArtist,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"`
CreatedAt time.Time `xml:"created,attr,omitempty" json:"created,omitempty"` CreatedAt time.Time `xml:"created,attr,omitempty" json:"created"`
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"` Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"` Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"` Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"`
@@ -220,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"`
@@ -241,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 {
@@ -261,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"`
} }
@@ -318,7 +335,7 @@ type Playlists struct {
} }
type Playlist 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"` Name string `xml:"name,attr" json:"name"`
Comment string `xml:"comment,attr" json:"comment"` Comment string `xml:"comment,attr" json:"comment"`
Owner string `xml:"owner,attr" json:"owner"` Owner string `xml:"owner,attr" json:"owner"`
@@ -465,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 {
@@ -474,6 +491,24 @@ type Lyrics struct {
Title string `xml:"title,attr,omitempty" json:"title,omitempty"` Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
} }
type Lyric struct {
Start *int64 `xml:"start,attr,omitempty" json:"start,omitempty"`
Value string `xml:",chardata" json:"value"`
}
type LyricsList struct {
StructuredLyrics []*StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
}
type StructuredLyrics struct {
Lang string `xml:"lang,attr" json:"lang"` // ISO 639 (or und, xxx if unknown)
Synced bool `xml:"synced,attr" json:"synced"`
Lines []Lyric `xml:"line" json:"line"`
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
DisplayTitle string `xml:"displayTitle,attr,omitempty" json:"displayTitle,omitempty"`
Offset int `xml:"offset,attr,omitempty" json:"offset,omitempty"`
}
type OpenSubsonicExtension struct { type OpenSubsonicExtension struct {
Name string `xml:"name,attr" json:"name"` Name string `xml:"name,attr" json:"name"`
Versions []int `xml:"versions" json:"versions"` Versions []int `xml:"versions" json:"versions"`
@@ -481,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, ".")
} }
@@ -515,8 +543,11 @@ var doublePuncExpr = regexp.MustCompile(`\.\s+\.\s+`)
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`) var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`) var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
var bluemondayPolicy = bluemonday.StrictPolicy() //nolint:gochecknoglobals
func CleanExternalText(text string) string { func CleanExternalText(text string) string {
text, _ = html2text.FromString(text, html2text.Options{TextOnly: true}) text = bluemondayPolicy.Sanitize(text)
text = html.UnescapeString(text)
text = licenceExpr.ReplaceAllString(text, "") text = licenceExpr.ReplaceAllString(text, "")
text = readMoreExpr.ReplaceAllString(text, "") text = readMoreExpr.ReplaceAllString(text, "")
text = doublePuncExpr.ReplaceAllString(text, ". ") text = doublePuncExpr.ReplaceAllString(text, ". ")
+15 -3
View File
@@ -27,6 +27,7 @@ const (
Podcast IDT = "pd" Podcast IDT = "pd"
PodcastEpisode IDT = "pe" PodcastEpisode IDT = "pe"
InternetRadioStation IDT = "ir" InternetRadioStation IDT = "ir"
Playlist IDT = "pl"
separator = "-" separator = "-"
) )
@@ -34,6 +35,7 @@ const (
type ID struct { type ID struct {
Type IDT Type IDT
Value int Value int
StringValue string
} }
func New(in string) (ID, error) { func New(in string) (ID, error) {
@@ -41,10 +43,17 @@ func New(in string) (ID, error) {
if !ok { if !ok {
return ID{}, ErrBadSeparator return ID{}, ErrBadSeparator
} }
switch IDT(partType) {
case Playlist:
return ID{Type: Playlist, StringValue: partValue}, nil
}
val, err := strconv.Atoi(partValue) val, err := strconv.Atoi(partValue)
if err != nil { if err != nil {
return ID{}, fmt.Errorf("%q: %w", partValue, ErrNotAnInt) return ID{}, fmt.Errorf("%q: %w", partValue, ErrNotAnInt)
} }
switch IDT(partType) { switch IDT(partType) {
case Artist: case Artist:
return ID{Type: Artist, Value: val}, nil return ID{Type: Artist, Value: val}, nil
@@ -64,10 +73,13 @@ func New(in string) (ID, error) {
} }
func (i ID) String() string { func (i ID) String() string {
if i.Value == 0 { switch {
return "-1" case i.Value != 0:
}
return fmt.Sprintf("%s%s%d", i.Type, separator, i.Value) 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 "-1"
} }
func (i ID) MarshalJSON() ([]byte, error) { func (i ID) MarshalJSON() ([]byte, error) {
-1
View File
@@ -24,7 +24,6 @@ func TestParseID(t *testing.T) {
} }
for _, tcase := range tcases { for _, tcase := range tcases {
tcase := tcase // pin
t.Run(tcase.param, func(t *testing.T) { t.Run(tcase.param, func(t *testing.T) {
t.Parallel() t.Parallel()
+25 -16
View File
@@ -37,33 +37,41 @@ func Locate(dbc *db.DB, id specid.ID) (Result, error) {
} }
} }
// Locate maps a location on the filesystem to a specid // Lookup maps a location on the filesystem to a specid
func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (Result, error) { func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (*specid.ID, error) {
if !strings.HasPrefix(path, "http") && !filepath.IsAbs(path) { if !strings.HasPrefix(path, "http") && !filepath.IsAbs(path) {
return nil, ErrNotAbs return nil, ErrNotAbs
} }
if strings.HasPrefix(path, podcastsPath) { if strings.HasPrefix(path, podcastsPath) {
podcastPath, episodeFilename := filepath.Split(path) podcastPath, episodeFilename := filepath.Split(path)
q := dbc. q := dbc.
Select("podcast_episodes.id").
Model(db.PodcastEpisode{}).
Joins(`JOIN podcasts ON podcasts.id=podcast_episodes.podcast_id`). Joins(`JOIN podcasts ON podcasts.id=podcast_episodes.podcast_id`).
Where(`podcasts.root_dir=? AND podcast_episodes.filename=?`, filepath.Clean(podcastPath), filepath.Clean(episodeFilename)) Where(`podcasts.root_dir=? AND podcast_episodes.filename=?`, filepath.Clean(podcastPath), filepath.Clean(episodeFilename))
var pe db.PodcastEpisode var id int
if err := q.First(&pe).Error; err == nil { if err := q.Row().Scan(&id); err != nil {
return &pe, nil
}
return nil, ErrNotFound return nil, ErrNotFound
} }
return &specid.ID{Type: specid.PodcastEpisode, Value: id}, nil
}
// probably internet radio // probably internet radio
if strings.HasPrefix(path, "http") { if strings.HasPrefix(path, "http") {
var irs db.InternetRadioStation q := dbc.
if err := dbc.First(&irs, "stream_url=?", path).Error; err == nil { Select("internet_radio_stations.id").
return &irs, nil 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 var musicPath string
for _, mp := range musicPaths { for _, mp := range musicPaths {
@@ -81,13 +89,14 @@ func Lookup(dbc *db.DB, musicPaths []string, podcastsPath string, path string) (
leftPath, rightPath := filepath.Split(filepath.Clean(relDir)) leftPath, rightPath := filepath.Split(filepath.Clean(relDir))
q := dbc. 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). 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`). Joins(`JOIN albums ON tracks.album_id=albums.id`)
Preload("Album")
var track db.Track var id int
if err := q.First(&track).Error; err == nil { if err := q.Row().Scan(&id); err != nil {
return &track, nil
}
return nil, ErrNotFound return nil, ErrNotFound
}
return &specid.ID{Type: specid.Track, Value: id}, nil
} }
@@ -23,7 +23,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -41,7 +42,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -59,7 +61,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -77,7 +80,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -113,7 +118,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -131,7 +137,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -149,7 +156,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
} }
] ]
} }
+18 -9
View File
@@ -23,7 +23,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -41,7 +42,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -59,7 +61,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -77,7 +80,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -113,7 +118,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -131,7 +137,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -149,7 +156,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
} }
] ]
} }
+18 -9
View File
@@ -23,7 +23,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -41,7 +42,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -59,7 +61,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -77,7 +80,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -95,7 +99,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -113,7 +118,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -131,7 +137,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -149,7 +156,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -167,7 +175,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
} }
] ]
} }
+63 -54
View File
@@ -8,22 +8,23 @@
"albumList": { "albumList": {
"album": [ "album": [
{ {
"id": "al-11", "id": "al-8",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artist": "artist-2", "artist": "artist-1",
"artists": null, "artists": null,
"displayArtist": "", "displayArtist": "",
"title": "album-0", "title": "album-1",
"album": "album-0", "album": "album-1",
"parent": "al-10", "parent": "al-6",
"isDir": true, "isDir": true,
"coverArt": "al-11", "coverArt": "al-8",
"name": "album-0", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -41,7 +42,27 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -59,25 +80,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "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": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -95,25 +99,8 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "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": []
}, },
{ {
"id": "al-3", "id": "al-3",
@@ -131,7 +118,27 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -149,25 +156,27 @@
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
}, },
{ {
"id": "al-8", "id": "al-12",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
"artist": "artist-1", "artist": "artist-2",
"artists": null, "artists": null,
"displayArtist": "", "displayArtist": "",
"title": "album-1", "title": "album-1",
"album": "album-1", "album": "album-1",
"parent": "al-6", "parent": "al-10",
"isDir": true, "isDir": true,
"coverArt": "al-8", "coverArt": "al-12",
"name": "album-1", "name": "album-1",
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [] "releaseTypes": [],
"discTitles": null
} }
] ]
} }
@@ -21,9 +21,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -39,9 +42,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -57,9 +63,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -75,9 +84,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -93,9 +105,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -111,9 +126,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -129,9 +147,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -147,9 +168,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -165,9 +189,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
@@ -21,9 +21,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -39,9 +42,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -57,9 +63,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -75,9 +84,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -93,9 +105,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -111,9 +126,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -129,9 +147,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -147,9 +168,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -165,9 +189,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
+36 -9
View File
@@ -21,9 +21,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -39,9 +42,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -57,9 +63,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -75,9 +84,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -93,9 +105,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -111,9 +126,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -129,9 +147,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -147,9 +168,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -165,9 +189,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
+155 -128
View File
@@ -7,42 +7,6 @@
"openSubsonic": true, "openSubsonic": true,
"albumList2": { "albumList2": {
"album": [ "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,
"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,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{ {
"id": "al-8", "id": "al-8",
"created": "2019-11-30T00:00:00Z", "created": "2019-11-30T00:00:00Z",
@@ -57,99 +21,12 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
}, "discTitles": []
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-2",
"album": "album-2",
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["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,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"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,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"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,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -165,9 +42,159 @@
"songCount": 3, "songCount": 3,
"duration": 300, "duration": 300,
"playCount": 0, "playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "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-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-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"],
"discTitles": []
},
{
"id": "al-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": []
},
{
"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": []
} }
] ]
} }
+8 -1
View File
@@ -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",
@@ -109,7 +115,8 @@
} }
], ],
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
} }
} }
+2 -1
View File
@@ -18,7 +18,8 @@
"duration": 0, "duration": 0,
"playCount": 0, "playCount": 0,
"isCompilation": false, "isCompilation": false,
"releaseTypes": [""] "releaseTypes": [""],
"discTitles": []
} }
} }
} }
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
+6 -3
View File
@@ -28,7 +28,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -48,7 +49,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -68,7 +70,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
@@ -17,9 +17,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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,9 +47,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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,9 +77,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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,
+18 -9
View File
@@ -25,7 +25,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-4", "id": "al-4",
@@ -45,7 +46,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-5", "id": "al-5",
@@ -65,7 +67,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-7", "id": "al-7",
@@ -85,7 +88,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-8", "id": "al-8",
@@ -105,7 +109,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-9", "id": "al-9",
@@ -125,7 +130,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-11", "id": "al-11",
@@ -145,7 +151,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-12", "id": "al-12",
@@ -165,7 +172,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
}, },
{ {
"id": "al-13", "id": "al-13",
@@ -185,7 +193,8 @@
"genres": [{ "name": "Unknown Genre" }], "genres": [{ "name": "Unknown Genre" }],
"year": 2021, "year": 2021,
"isCompilation": false, "isCompilation": false,
"releaseTypes": ["Album"] "releaseTypes": ["Album"],
"discTitles": []
} }
] ]
} }
+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,
+60 -20
View File
@@ -14,9 +14,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -42,9 +44,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -70,9 +74,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -98,9 +104,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -126,9 +134,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -154,9 +164,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -182,9 +194,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -210,9 +224,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -238,9 +254,11 @@
"artist": "artist-0", "artist": "artist-0",
"artistId": "ar-1", "artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }], "artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "", "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",
@@ -266,9 +284,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -294,9 +314,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -322,9 +344,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -350,9 +374,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -378,9 +404,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -406,9 +434,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -434,9 +464,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -462,9 +494,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -490,9 +524,11 @@
"artist": "artist-1", "artist": "artist-1",
"artistId": "ar-2", "artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }], "artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "", "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",
@@ -518,9 +554,11 @@
"artist": "artist-2", "artist": "artist-2",
"artistId": "ar-3", "artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }], "artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "", "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",
@@ -546,9 +584,11 @@
"artist": "artist-2", "artist": "artist-2",
"artistId": "ar-3", "artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }], "artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "", "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",
+82
View File
@@ -0,0 +1,82 @@
package ffprobe
import (
"encoding/json"
"fmt"
"os/exec"
"path/filepath"
"strconv"
"strings"
"time"
"go.senan.xyz/gonic/tags"
)
var _ tags.Reader = Reader{}
type Reader struct{}
func (Reader) CanRead(absPath string) bool {
switch ext := strings.ToLower(filepath.Ext(absPath)); ext {
case ".3ga", ".3gp", ".669", ".aa3", ".aac", ".aif", ".aiff", ".aifc", ".ape", ".caf", ".dsf", ".f4a", ".f4b", ".flac", ".it", ".m4a", ".m4b", ".m4r", ".mka", ".mkv", ".mod", ".mov", ".mp1", ".mp2", ".mp3", ".mp4", ".mpc", ".mpp", ".oga", ".ogg", ".oma", ".opus", ".ra", ".rf64", ".rm", ".s3m", ".sph", ".spx", ".stm", ".tak", ".tta", ".wav", ".webm", ".w64", ".wma", ".wv", ".asf":
return true
}
return false
}
func (Reader) Read(absPath string) (tags.Properties, tags.Tags, error) {
out, err := exec.Command("ffprobe", "-hide_banner", "-v", "0", "-i", absPath, "-show_entries", "format:stream=codec_type", "-of", "json").Output()
if err != nil {
return tags.Properties{}, nil, fmt.Errorf("output: %w", err)
}
var d struct {
Streams []struct {
CodecType string `json:"codec_type"`
} `json:"streams"`
Format struct {
Duration string `json:"duration"`
BitRate string `json:"bit_rate"`
Tags map[string]string `json:"tags"`
} `json:"format"`
}
if err := json.Unmarshal(out, &d); err != nil {
return tags.Properties{}, nil, fmt.Errorf("read json: %w", err)
}
durationSecs, _ := strconv.ParseFloat(d.Format.Duration, 64)
bitRateBitsPerSec, _ := strconv.Atoi(d.Format.BitRate)
var tgs = map[string][]string{}
for k, vs := range d.Format.Tags {
switch k {
case "OK":
continue
}
tgs[k] = strings.Split(vs, ";")
}
var hasCover bool
for _, s := range d.Streams {
if s.CodecType == "video" {
hasCover = true
break
}
}
props := tags.Properties{
Length: time.Duration(durationSecs) * time.Second,
Bitrate: uint(bitRateBitsPerSec / 1000),
HasCover: hasCover,
}
return props, tgs, nil
}
func (Reader) ReadCover(absPath string) ([]byte, error) {
out, err := exec.Command("ffmpeg", "-i", absPath, "-map", "0:v", "-c", "copy", "-f", "image2pipe", "-").Output()
if err != nil {
return nil, fmt.Errorf("exec: %w", err)
}
return out, nil
}
-114
View File
@@ -1,114 +0,0 @@
package tagcommon
import (
"errors"
)
var ErrUnsupported = errors.New("filetype unsupported")
type Reader interface {
CanRead(absPath string) bool
Read(absPath string) (Info, error)
}
type Info interface {
Title() string
BrainzID() string // musicbrainz recording ID
Artist() string
Artists() []string
Album() string
AlbumArtist() string
AlbumArtists() []string
AlbumBrainzID() string
Genre() string
Genres() []string
TrackNumber() int
DiscNumber() int
Year() int
Compilation() bool
ReleaseType() string
ReplayGainTrackGain() float32
ReplayGainTrackPeak() float32
ReplayGainAlbumGain() float32
ReplayGainAlbumPeak() float32
Length() int
Bitrate() int
}
const (
FallbackAlbum = "Unknown Album"
FallbackArtist = "Unknown Artist"
FallbackGenre = "Unknown Genre"
)
func MustAlbum(p Info) string {
if r := p.Album(); r != "" {
return r
}
return FallbackAlbum
}
func MustArtist(p Info) string {
if r := p.Artist(); r != "" {
return r
}
return FallbackArtist
}
func MustArtists(p Info) []string {
if r := p.Artists(); len(r) > 0 {
return r
}
return []string{MustArtist(p)}
}
func MustAlbumArtist(p Info) string {
if r := p.AlbumArtist(); r != "" {
return r
}
return MustArtist(p)
}
func MustAlbumArtists(p Info) []string {
if r := p.AlbumArtists(); len(r) > 0 {
return r
}
return []string{MustAlbumArtist(p)}
}
func MustGenre(p Info) string {
if r := p.Genre(); r != "" {
return r
}
return FallbackGenre
}
func MustGenres(p Info) []string {
if r := p.Genres(); len(r) > 0 {
return r
}
return []string{MustGenre(p)}
}
type ChainReader []Reader
func (cr ChainReader) CanRead(absPath string) bool {
for _, reader := range cr {
if reader.CanRead(absPath) {
return true
}
}
return false
}
func (cr ChainReader) Read(absPath string) (Info, error) {
for _, reader := range cr {
if reader.CanRead(absPath) {
return reader.Read(absPath)
}
}
return nil, ErrUnsupported
}
+17 -93
View File
@@ -3,114 +3,38 @@ package taglib
import ( import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"strconv"
"strings" "strings"
"github.com/sentriz/audiotags" "go.senan.xyz/gonic/tags"
"go.senan.xyz/gonic/tags/tagcommon" "go.senan.xyz/taglib"
) )
type TagLib struct{} var _ tags.Reader = Reader{}
func (TagLib) CanRead(absPath string) bool { type Reader struct{}
func (Reader) CanRead(absPath string) bool {
switch ext := strings.ToLower(filepath.Ext(absPath)); ext { switch ext := strings.ToLower(filepath.Ext(absPath)); ext {
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv": case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv", ".ape":
return true return true
} }
return false return false
} }
func (TagLib) Read(absPath string) (tagcommon.Info, error) { func (Reader) Read(absPath string) (tags.Properties, tags.Tags, error) {
f, err := audiotags.Open(absPath) tp, err := taglib.ReadProperties(absPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("open: %w", err) return tags.Properties{}, nil, fmt.Errorf("read properties: %w", err)
} }
defer f.Close()
props := f.ReadAudioProperties()
raw := f.ReadTags()
return &info{raw, props}, nil
}
type info struct { tag, err := taglib.ReadTags(absPath)
raw map[string][]string if err != nil {
props *audiotags.AudioProperties return tags.Properties{}, nil, fmt.Errorf("read tags: %w", err)
}
// https://picard-docs.musicbrainz.org/downloads/MusicBrainz_Picard_Tag_Map.html
func (i *info) Title() string { return first(find(i.raw, "title")) }
func (i *info) BrainzID() string { return first(find(i.raw, "musicbrainz_trackid")) } // musicbrainz recording ID
func (i *info) Artist() string { return first(find(i.raw, "artist")) }
func (i *info) Artists() []string { return find(i.raw, "artists") }
func (i *info) Album() string { return first(find(i.raw, "album")) }
func (i *info) AlbumArtist() string { return first(find(i.raw, "albumartist", "album artist")) }
func (i *info) AlbumArtists() []string { return find(i.raw, "albumartists", "album_artists") }
func (i *info) AlbumBrainzID() string { return first(find(i.raw, "musicbrainz_albumid")) } // musicbrainz release ID
func (i *info) Genre() string { return first(find(i.raw, "genre")) }
func (i *info) Genres() []string { return find(i.raw, "genres") }
func (i *info) TrackNumber() int { return intSep("/", first(find(i.raw, "tracknumber"))) } // eg. 5/12
func (i *info) DiscNumber() int { return intSep("/", first(find(i.raw, "discnumber"))) } // eg. 1/2
func (i *info) Year() int { return intSep("-", first(find(i.raw, "originaldate", "date", "year"))) } // eg. 2023-12-01
func (i *info) Compilation() bool { return bl(first(find(i.raw, "compilation"))) }
func (i *info) ReleaseType() string { return first(find(i.raw, "releasetype")) }
func (i *info) ReplayGainTrackGain() float32 { return dB(first(find(i.raw, "replaygain_track_gain"))) }
func (i *info) ReplayGainTrackPeak() float32 { return flt(first(find(i.raw, "replaygain_track_peak"))) }
func (i *info) ReplayGainAlbumGain() float32 { return dB(first(find(i.raw, "replaygain_album_gain"))) }
func (i *info) ReplayGainAlbumPeak() float32 { return flt(first(find(i.raw, "replaygain_album_peak"))) }
func (i *info) Length() int { return i.props.Length }
func (i *info) Bitrate() int { return i.props.Bitrate }
func first[T comparable](is []T) T {
var z T
for _, i := range is {
if i != z {
return i
} }
}
return z return tags.Properties{Length: tp.Length, Bitrate: tp.Bitrate, HasCover: len(tp.Images) > 0}, tag, nil
} }
func find(m map[string][]string, keys ...string) []string { func (Reader) ReadCover(absPath string) ([]byte, error) {
for _, k := range keys { return taglib.ReadImage(absPath)
if r := filterStr(m[k]); len(r) > 0 {
return r
}
}
return nil
}
func filterStr(ss []string) []string {
var r []string
for _, s := range ss {
if strings.TrimSpace(s) != "" {
r = append(r, s)
}
}
return r
}
func flt(in string) float32 {
f, _ := strconv.ParseFloat(in, 32)
return float32(f)
}
func bl(in string) bool {
b, _ := strconv.ParseBool(in)
return b
}
func dB(in string) float32 {
in = strings.ToLower(in)
in = strings.TrimSuffix(in, " db")
in = strings.TrimSuffix(in, "db")
return flt(in)
}
func intSep(sep, in string) int {
start, _, _ := strings.Cut(in, sep)
out, _ := strconv.Atoi(start)
return out
} }
+130
View File
@@ -0,0 +1,130 @@
package tags
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
"github.com/araddon/dateparse"
"go.senan.xyz/wrtag/tags/normtag"
)
var ErrUnsupported = errors.New("filetype unsupported")
type Reader interface {
CanRead(absPath string) bool
Read(absPath string) (properties Properties, tags Tags, err error)
ReadCover(absPath string) ([]byte, error)
}
type Tags = map[string][]string
type Properties struct {
Length time.Duration
Bitrate uint
HasCover bool
}
const (
FallbackAlbum = "Unknown Album"
FallbackArtist = "Unknown Artist"
FallbackGenre = "Unknown Genre"
)
func FirstValues(p Tags, keys ...string) []string {
for _, k := range keys {
if v := normtag.Values(p, k); len(v) > 0 {
return v
}
}
return nil
}
func MustAlbum(p Tags) string {
if r := normtag.Get(p, normtag.Album); r != "" {
return r
}
return FallbackAlbum
}
func MustArtist(p Tags) string {
if r := normtag.Get(p, normtag.Artist); r != "" {
return r
}
return FallbackArtist
}
func MustArtists(p Tags) []string {
if r := FirstValues(p, normtag.Artists, normtag.Artist); len(r) > 0 {
return r
}
return []string{FallbackArtist}
}
func MustAlbumArtist(p Tags) string {
if r := normtag.Get(p, normtag.AlbumArtist); r != "" {
return r
}
return MustArtist(p)
}
func MustAlbumArtists(p Tags) []string {
if r := FirstValues(p, normtag.AlbumArtists, normtag.AlbumArtist); len(r) > 0 {
return r
}
return []string{MustArtist(p)}
}
func MustGenre(p Tags) string {
if r := normtag.Get(p, normtag.Genre); r != "" {
return r
}
return FallbackGenre
}
func MustGenres(p Tags) []string {
if r := FirstValues(p, normtag.Genres, normtag.Genre); len(r) > 0 {
return r
}
return []string{FallbackGenre}
}
func MustYear(p Tags) int {
if t := ParseDate(normtag.Get(p, normtag.OriginalDate)); !t.IsZero() {
return t.Year()
}
if t := ParseDate(normtag.Get(p, normtag.Date)); !t.IsZero() {
return t.Year()
}
return 0
}
func ParseFloat(in string) float32 {
f, _ := strconv.ParseFloat(in, 32)
return float32(f)
}
func ParseBool(in string) bool {
b, _ := strconv.ParseBool(in)
return b
}
func ParseDB(in string) float32 {
in = strings.ToLower(in)
in = strings.TrimSuffix(in, " db")
in = strings.TrimSuffix(in, "db")
return ParseFloat(in)
}
func ParseInt(in string) int {
var i int
_, _ = fmt.Sscanf(in, "%d", &i)
return i
}
func ParseDate(in string) time.Time {
t, _ := dateparse.ParseAny(in)
return t
}
+3 -6
View File
@@ -116,15 +116,12 @@ func TestCachingParallelism(t *testing.T) {
cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024) cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024)
var wg sync.WaitGroup var wg sync.WaitGroup
for i := 0; i < 5; i++ { for range 5 {
wg.Add(1) wg.Go(func() {
go func() {
defer wg.Done()
var buf bytes.Buffer var buf bytes.Buffer
require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf)) require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf))
require.Equal(t, 5*bytesPerSec, buf.Len()) require.Equal(t, 5*bytesPerSec, buf.Len())
}() })
} }
wg.Wait() wg.Wait()
+1 -1
View File
@@ -1 +1 @@
0.17.0 0.20.1