Merge branch 'master' into ldap_auth
This commit is contained in:
No files matched your search
@@ -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 }}
|
||||
@@ -2,7 +2,12 @@ name: Nightly Release
|
||||
on:
|
||||
schedule:
|
||||
- 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:
|
||||
check-date:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -22,16 +27,12 @@ jobs:
|
||||
if: ${{ needs.check-date.outputs.should_run == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
with:
|
||||
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
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
@@ -39,21 +40,15 @@ jobs:
|
||||
version: v2.4.0
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
build-release:
|
||||
build-docker:
|
||||
name: Build and release Docker image
|
||||
needs: [check-date, test]
|
||||
if: ${{ needs.check-date.outputs.should_run == 'true' }}
|
||||
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
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
@@ -63,19 +58,24 @@ jobs:
|
||||
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: Generate short hash
|
||||
- name: Generate short hash and set tag
|
||||
run: |
|
||||
_short_hash=${{ github.sha }}
|
||||
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
|
||||
uses: docker/build-push-action@v2
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
||||
push: true
|
||||
tags: |
|
||||
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 }}:nightly
|
||||
${{ github.repository }}:${{ env.TAG_NAME }}
|
||||
@@ -8,16 +8,12 @@ jobs:
|
||||
name: Lint and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
with:
|
||||
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
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
@@ -43,32 +39,61 @@ jobs:
|
||||
release-type: simple
|
||||
changelog-path: CHANGELOG.md
|
||||
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 Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
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
|
||||
runs-on: ubuntu-latest
|
||||
needs: [release-please]
|
||||
if: ${{ needs.release-please.outputs.release_created }}
|
||||
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: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- 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
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
@@ -79,6 +104,8 @@ jobs:
|
||||
ghcr.io/${{ github.repository }}:latest
|
||||
${{ github.repository }}:${{ needs.release-please.outputs.tag_name }}
|
||||
${{ github.repository }}:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
notify-irc:
|
||||
needs: [release-please]
|
||||
name: Notify IRC
|
||||
|
||||
@@ -9,16 +9,12 @@ jobs:
|
||||
name: Lint and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
with:
|
||||
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
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# Changelog
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
+9
-20
@@ -1,19 +1,16 @@
|
||||
FROM golang:1.25-alpine3.22 AS builder
|
||||
RUN apk add -U --no-cache \
|
||||
build-base \
|
||||
ca-certificates \
|
||||
git \
|
||||
sqlite \
|
||||
zlib-dev \
|
||||
taglib-dev \
|
||||
go
|
||||
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM --platform=$BUILDPLATFORM golang:1.25-alpine3.22 AS builder
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
WORKDIR /src
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
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
|
||||
LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic
|
||||
@@ -24,15 +21,7 @@ RUN apk add -U --no-cache \
|
||||
tzdata \
|
||||
tini \
|
||||
shared-mime-info
|
||||
|
||||
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/
|
||||
COPY --from=builder /out/* /usr/local/bin/
|
||||
VOLUME ["/cache", "/data", "/music", "/podcasts"]
|
||||
EXPOSE 80
|
||||
ENV TZ=
|
||||
|
||||
@@ -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
|
||||
@@ -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"]
|
||||
@@ -49,31 +49,32 @@ password can then be changed from the web interface
|
||||
|
||||
## configuration options
|
||||
|
||||
| env var | command line arg | description |
|
||||
| -------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) |
|
||||
| `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory |
|
||||
| `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. |
|
||||
| `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc |
|
||||
| `GONIC_DB_PATH` | `-db-path` | **optional** path to database file |
|
||||
| `GONIC_HTTP_LOG` | `-http-log` | **optional** http request logging, enabled by default |
|
||||
| `GONIC_LISTEN_ADDR` | `-listen-addr` | **optional** host and port to listen on (eg. `0.0.0.0:4747`, `127.0.0.1:4747`) (_default_ `0.0.0.0:4747`) |
|
||||
| `GONIC_TLS_CERT` | `-tls-cert` | **optional** path to a TLS cert (enables HTTPS listening) |
|
||||
| `GONIC_TLS_KEY` | `-tls-key` | **optional** path to a TLS key (enables HTTPS listening) |
|
||||
| `GONIC_PROXY_PREFIX` | `-proxy-prefix` | **optional** url path prefix to use if behind reverse proxy. eg `/gonic` (see example configs below) |
|
||||
| `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_WATCHER_ENABLED` | `-scan-watcher-enabled` | **optional** whether to watch file system for new music and rescan |
|
||||
| `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_PODCAST_PURGE_AGE` | `-podcast-purge-age` | **optional** age (in days) to purge podcast episodes if not accessed |
|
||||
| `GONIC_EXCLUDE_PATTERN` | `-exclude-pattern` | **optional** files matching this regex pattern will not be imported. eg <code>@eaDir\|[aA]rtwork\|[cC]overs\|[sS]cans\|[sS]pectrals</code> |
|
||||
| `GONIC_MULTI_VALUE_GENRE` | `-multi-value-genre` | **optional** setting for multi-valued genre tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_MULTI_VALUE_ARTIST` | `-multi-value-artist` | **optional** setting for multi-valued artist tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_MULTI_VALUE_ALBUM_ARTIST` | `-multi-value-album-artist` | **optional** setting for multi-valued album artist tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_TRANSCODE_CACHE_SIZE` | `-transcode-cache-size` | **optional** size of the transcode cache in MB (0 = no limit) |
|
||||
| `GONIC_TRANSCODE_EJECT_INTERVAL` | `-transcode-eject-interval` | **optional** interval (in minutes) to eject transcode cache (0 = never) |
|
||||
| `GONIC_EXPVAR` | `-expvar` | **optional** enable the /debug/vars endpoint (exposes useful debugging attributes as well as database stats) |
|
||||
| env var | command line arg | description |
|
||||
| ----------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `GONIC_MUSIC_PATH` | `-music-path` | path to your music collection (see also multi-folder support below) |
|
||||
| `GONIC_PODCAST_PATH` | `-podcast-path` | path to a podcasts directory |
|
||||
| `GONIC_PLAYLISTS_PATH` | `-playlists-path` | path to new or existing directory with m3u files for subsonic playlists. items in the directory should be in the format `<userid>/<name>.m3u`. for example the admin user could have `1/my-playlist.m3u`. gonic create and make changes to these playlists over the subsonic api. |
|
||||
| `GONIC_CACHE_PATH` | `-cache-path` | path to store audio transcodes, covers, etc |
|
||||
| `GONIC_DB_PATH` | `-db-path` | **optional** path to database file |
|
||||
| `GONIC_HTTP_LOG` | `-http-log` | **optional** http request logging, enabled by default |
|
||||
| `GONIC_LISTEN_ADDR` | `-listen-addr` | **optional** host and port to listen on (eg. `0.0.0.0:4747`, `127.0.0.1:4747`) (_default_ `0.0.0.0:4747`) |
|
||||
| `GONIC_TLS_CERT` | `-tls-cert` | **optional** path to a TLS cert (enables HTTPS listening) |
|
||||
| `GONIC_TLS_KEY` | `-tls-key` | **optional** path to a TLS key (enables HTTPS listening) |
|
||||
| `GONIC_PROXY_PREFIX` | `-proxy-prefix` | **optional** url path prefix to use if behind reverse proxy. eg `/gonic` (see example configs below) |
|
||||
| `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_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_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_EXCLUDE_PATTERN` | `-exclude-pattern` | **optional** files matching this regex pattern will not be imported. eg <code>@eaDir\|[aA]rtwork\|[cC]overs\|[sS]cans\|[sS]pectrals</code> |
|
||||
| `GONIC_MULTI_VALUE_GENRE` | `-multi-value-genre` | **optional** setting for multi-valued genre tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_MULTI_VALUE_ARTIST` | `-multi-value-artist` | **optional** setting for multi-valued artist tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_MULTI_VALUE_ALBUM_ARTIST` | `-multi-value-album-artist` | **optional** setting for multi-valued album artist tags when scanning ([see more](#multi-valued-tags-v016)) |
|
||||
| `GONIC_TRANSCODE_CACHE_SIZE` | `-transcode-cache-size` | **optional** size of the transcode cache in MB (0 = no limit) |
|
||||
| `GONIC_TRANSCODE_EJECT_INTERVAL` | `-transcode-eject-interval` | **optional** interval (in minutes) to eject transcode cache (0 = never) |
|
||||
| `GONIC_EXPVAR` | `-expvar` | **optional** enable the /debug/vars endpoint (exposes useful debugging attributes as well as database stats) |
|
||||
|
||||
## multi valued tags (v0.16+)
|
||||
|
||||
|
||||
+4
-11
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"github.com/google/shlex"
|
||||
"github.com/gorilla/securecookie"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/sentriz/gormstore"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
@@ -46,8 +45,6 @@ import (
|
||||
"go.senan.xyz/gonic/scrobble"
|
||||
"go.senan.xyz/gonic/server/ctrladmin"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic"
|
||||
"go.senan.xyz/gonic/tags/tagcommon"
|
||||
"go.senan.xyz/gonic/tags/taglib"
|
||||
"go.senan.xyz/gonic/transcode"
|
||||
)
|
||||
|
||||
@@ -72,6 +69,7 @@ func main() {
|
||||
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)")
|
||||
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)")
|
||||
confJukeboxMPVExtraArgs := flag.String("jukebox-mpv-extra-args", "", "extra command line arguments to pass to the jukebox mpv daemon (optional)")
|
||||
@@ -199,15 +197,9 @@ func main() {
|
||||
log.Printf("provided config\n")
|
||||
flag.VisitAll(func(f *flag.Flag) {
|
||||
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{
|
||||
taglib.TagLib{},
|
||||
// ffprobe reader?
|
||||
// nfo reader?
|
||||
}
|
||||
|
||||
scannr := scanner.New(
|
||||
ctrlsubsonic.MusicPaths(musicPaths),
|
||||
dbc,
|
||||
@@ -218,6 +210,7 @@ func main() {
|
||||
},
|
||||
tagReader,
|
||||
*confExcludePattern,
|
||||
*confScanEmbeddedCover,
|
||||
)
|
||||
podcast := podcast.New(dbc, *confPodcastPath, tagReader)
|
||||
transcoder := transcode.NewCachingTranscoder(
|
||||
@@ -277,7 +270,7 @@ func main() {
|
||||
if err != nil {
|
||||
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, ldapConfig)
|
||||
ctrlSubsonic, err := ctrlsubsonic.New(dbc, scannr, musicPaths, *confPodcastPath, cacheDirAudio, cacheDirCovers, jukebx, playlistStore, scrobblers, podcast, transcoder, lastfmClient, artistInfoCache, albumInfoCache, tagReader, resolveProxyPath, ldapConfig)
|
||||
if err != nil {
|
||||
log.Panicf("error creating subsonic controller: %v\n", err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build !nowasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
// Cgo-free Wasm database
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
|
||||
// Cgo-free Wasm tagger
|
||||
"go.senan.xyz/gonic/tags/taglib"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var tagReader = taglib.Reader{}
|
||||
@@ -0,0 +1,14 @@
|
||||
//go:build nowasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
// Cgo database
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
// Cgo tagger
|
||||
"go.senan.xyz/gonic/tags/ffprobe"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var tagReader = ffprobe.Reader{}
|
||||
@@ -1,7 +1,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -13,7 +12,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/mattn/go-sqlite3"
|
||||
|
||||
// TODO: remove this dep
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
@@ -43,7 +41,6 @@ type DB struct {
|
||||
}
|
||||
|
||||
func New(path string, options url.Values) (*DB, error) {
|
||||
// https://github.com/mattn/go-sqlite3#connection-string
|
||||
url := url.URL{
|
||||
Scheme: "file",
|
||||
Opaque: path,
|
||||
@@ -239,6 +236,8 @@ type Track struct {
|
||||
ReplayGainAlbumGain float32
|
||||
ReplayGainAlbumPeak float32
|
||||
|
||||
HasEmbeddedCover bool
|
||||
|
||||
TrackStar *TrackStar
|
||||
TrackRating *TrackRating
|
||||
AverageRating float64 `sql:"default: null"`
|
||||
@@ -319,33 +318,34 @@ type Play struct {
|
||||
}
|
||||
|
||||
type Album struct {
|
||||
ID int `gorm:"primary_key"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ModifiedAt time.Time
|
||||
LeftPath string `gorm:"unique_index:idx_album_abs_path"`
|
||||
RightPath string `gorm:"not null; unique_index:idx_album_abs_path" sql:"default: null"`
|
||||
RightPathUDec string `sql:"default: null"`
|
||||
Parent *Album
|
||||
ParentID int `sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
|
||||
RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"`
|
||||
Genres []*Genre `gorm:"many2many:album_genres"`
|
||||
Cover string `sql:"default: null"`
|
||||
Artists []*Artist `gorm:"many2many:album_artists"`
|
||||
TagTitle string `sql:"default: null"`
|
||||
TagAlbumArtist string // display purposes only
|
||||
TagTitleUDec string `sql:"default: null"`
|
||||
TagBrainzID string `sql:"default: null"`
|
||||
TagYear int `sql:"default: null"`
|
||||
TagCompilation bool `sql:"default: null"`
|
||||
TagReleaseType string `sql:"default: null"`
|
||||
Tracks []*Track
|
||||
ChildCount int `sql:"-"`
|
||||
Duration int `sql:"-"`
|
||||
AlbumStar *AlbumStar
|
||||
AlbumRating *AlbumRating
|
||||
AverageRating float64 `sql:"default: null"`
|
||||
Play *Play
|
||||
ID int `gorm:"primary_key"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ModifiedAt time.Time
|
||||
LeftPath string `gorm:"unique_index:idx_album_abs_path"`
|
||||
RightPath string `gorm:"not null; unique_index:idx_album_abs_path" sql:"default: null"`
|
||||
RightPathUDec string `sql:"default: null"`
|
||||
Parent *Album
|
||||
ParentID int `sql:"default: null; type:int REFERENCES albums(id) ON DELETE CASCADE"`
|
||||
RootDir string `gorm:"unique_index:idx_album_abs_path" sql:"default: null"`
|
||||
Genres []*Genre `gorm:"many2many:album_genres"`
|
||||
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"`
|
||||
TagTitle string `sql:"default: null"`
|
||||
TagAlbumArtist string // display purposes only
|
||||
TagTitleUDec string `sql:"default: null"`
|
||||
TagBrainzID string `sql:"default: null"`
|
||||
TagYear int `sql:"default: null"`
|
||||
TagCompilation bool `sql:"default: null"`
|
||||
TagReleaseType string `sql:"default: null"`
|
||||
Tracks []*Track
|
||||
ChildCount int `sql:"-"`
|
||||
Duration int `sql:"-"`
|
||||
AlbumStar *AlbumStar
|
||||
AlbumRating *AlbumRating
|
||||
AverageRating float64 `sql:"default: null"`
|
||||
Play *Play
|
||||
}
|
||||
|
||||
func (a *Album) SID() *specid.ID {
|
||||
@@ -356,6 +356,10 @@ func (a *Album) ParentSID() *specid.ID {
|
||||
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 {
|
||||
if len(a.RightPathUDec) > 0 {
|
||||
return a.RightPathUDec
|
||||
@@ -620,45 +624,3 @@ func join[T fmt.Stringer](in []T, sep string) string {
|
||||
}
|
||||
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 any) error {
|
||||
return connSrc.Raw(func(connSrc any) 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
|
||||
}
|
||||
+10
-9
@@ -2,7 +2,6 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -59,7 +58,6 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
||||
construct(ctx, "202206101425", migrateUser),
|
||||
construct(ctx, "202207251148", migrateStarRating),
|
||||
construct(ctx, "202211111057", migratePlaylistsQueuesToFullID),
|
||||
constructNoTx(ctx, "202212272312", backupDBPre016),
|
||||
construct(ctx, "202304221528", migratePlaylistsToM3U),
|
||||
construct(ctx, "202305301718", migratePlayCountToLength),
|
||||
construct(ctx, "202307281628", migrateAlbumArtistsMany2Many),
|
||||
@@ -81,6 +79,8 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
||||
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
|
||||
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
|
||||
construct(ctx, "202508261102", migrateAddLyrics),
|
||||
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
|
||||
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
|
||||
}
|
||||
|
||||
return gormigrate.
|
||||
@@ -738,13 +738,6 @@ func migratePlaylistsPaths(tx *gorm.DB, ctx MigrationContext) error {
|
||||
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 {
|
||||
return tx.AutoMigrate(Album{}).Error
|
||||
}
|
||||
@@ -866,3 +859,11 @@ func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) 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
|
||||
}
|
||||
@@ -5,6 +5,7 @@ go 1.25
|
||||
require (
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible
|
||||
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/disintegration/imaging v1.6.2
|
||||
github.com/djherbis/times v1.6.0
|
||||
@@ -23,16 +24,17 @@ require (
|
||||
github.com/microcosm-cc/bluemonday v1.0.27
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/mmcdole/gofeed v1.3.0
|
||||
github.com/ncruces/go-sqlite3 v0.29.1
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
|
||||
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6
|
||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.senan.xyz/flagconf v0.1.9
|
||||
go.senan.xyz/wrtag v0.17.1
|
||||
golang.org/x/net v0.43.0
|
||||
golang.org/x/sync v0.16.0
|
||||
go.senan.xyz/taglib v0.10.1
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e
|
||||
golang.org/x/net v0.44.0
|
||||
golang.org/x/sync v0.17.0
|
||||
gopkg.in/gormigrate.v1 v1.6.0
|
||||
)
|
||||
|
||||
@@ -44,8 +46,8 @@ require (
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.22.0 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.22.1 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.25.1 // 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
|
||||
@@ -59,11 +61,13 @@ require (
|
||||
github.com/mmcdole/goxpp v1.1.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/ncruces/julianday v1.0.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/crypto v0.41.0 // indirect
|
||||
golang.org/x/image v0.30.0 // indirect
|
||||
golang.org/x/sys v0.35.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.42.0 // indirect
|
||||
golang.org/x/image v0.31.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@@ -10,9 +10,13 @@ github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuN
|
||||
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.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
|
||||
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
|
||||
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||
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=
|
||||
@@ -41,10 +45,10 @@ github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
||||
github.com/go-openapi/jsonpointer v0.22.0 h1:TmMhghgNef9YXxTu1tOopo+0BGEytxA+okbry0HjZsM=
|
||||
github.com/go-openapi/jsonpointer v0.22.0/go.mod h1:xt3jV88UtExdIkkL7NloURjRQjbeUgcxFblMjq2iaiU=
|
||||
github.com/go-openapi/swag/jsonname v0.24.0 h1:2wKS9bgRV/xB8c62Qg16w4AUiIrqqiniJFtZGi3dg5k=
|
||||
github.com/go-openapi/swag/jsonname v0.24.0/go.mod h1:GXqrPzGJe611P7LG4QB9JKPtUZ7flE4DOVechNaDd7Q=
|
||||
github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk=
|
||||
github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM=
|
||||
github.com/go-openapi/swag/jsonname v0.25.1 h1:Sgx+qbwa4ej6AomWC6pEfXrA6uP2RkaNjA9BR8a1RJU=
|
||||
github.com/go-openapi/swag/jsonname v0.25.1/go.mod h1:71Tekow6UOLBD3wS7XhdT98g5J5GR13NOTQ9/6Q11Zo=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
@@ -101,6 +105,7 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||
@@ -122,6 +127,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/ncruces/go-sqlite3 v0.29.1 h1:NIi8AISWBToRHyoz01FXiTNvU147Tqdibgj2tFzJCqM=
|
||||
github.com/ncruces/go-sqlite3 v0.29.1/go.mod h1:PpccBNNhvjwUOwDQEn2gXQPFPTWdlromj0+fSkd5KSg=
|
||||
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/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA=
|
||||
@@ -130,24 +139,29 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
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/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
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/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6 h1:WCZxu77OR9yzKGZugQC1dHhslXROOJT+UL5JCtJbBq8=
|
||||
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6/go.mod h1:+pmkMFDEXJuu/u4h2OYJVfYF2qIhXJD7kqvWq6q5Zo0=
|
||||
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
|
||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981 h1:sLILANWN76ja66/K4k/mBqJuCjDZaM67w+Ru6rEB0s0=
|
||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981/go.mod h1:Rx8XB1ck+so+41uu9VY1gMKs1CPQ2NTq0pzf+OCCQHo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||
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.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
|
||||
go.senan.xyz/wrtag v0.17.1 h1:QC40z0rRAZ8zjIwwIrFIhldviP9cW0Jpe9EDh5Bt2J8=
|
||||
go.senan.xyz/wrtag v0.17.1/go.mod h1:rrC+QaFcZACW/hcsZpQj6kTh69rjhxIoePk3MZG3/rA=
|
||||
go.senan.xyz/taglib v0.10.1 h1:ez+lr7APh7BD3ft8PYgRM2Q8HKaiBkWZrZDHWwr4aDw=
|
||||
go.senan.xyz/taglib v0.10.1/go.mod h1:UMXxjvVuML3bZ63elOoUFtY2ZjwH88KB+DKWfF50ln8=
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e h1:Q81nHdKVLExGp7+NosXA63dmPSwhijKZKzAhkC6gY4g=
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e/go.mod h1:iBOnQIdvi55Y47SJxc4e5k1eu1bSeUwsq4hbFZOnXHU=
|
||||
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -157,11 +171,11 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
||||
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
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.30.0/go.mod h1:SAEUTxCCMWSrJcCy/4HwavEsfZZJlYxeHLc6tTiAe/c=
|
||||
golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA=
|
||||
golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
@@ -181,8 +195,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -190,8 +204,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -206,8 +220,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@@ -217,8 +231,6 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
@@ -228,16 +240,16 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
|
||||
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
|
||||
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"go.senan.xyz/gonic/lastfm"
|
||||
"go.senan.xyz/gonic/lastfm/mockclient"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
)
|
||||
|
||||
func TestInfoCache(t *testing.T) {
|
||||
|
||||
+50
-82
@@ -2,7 +2,6 @@
|
||||
package mockfs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -13,7 +12,8 @@ import (
|
||||
|
||||
"go.senan.xyz/gonic/db"
|
||||
"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")
|
||||
@@ -68,7 +68,7 @@ func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
|
||||
}
|
||||
|
||||
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{
|
||||
t: tb,
|
||||
@@ -79,9 +79,9 @@ func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockFS) DB() *db.DB { return m.db }
|
||||
func (m *MockFS) TmpDir() string { return m.dir }
|
||||
func (m *MockFS) TagReader() tagcommon.Reader { return m.tagReader }
|
||||
func (m *MockFS) DB() *db.DB { return m.db }
|
||||
func (m *MockFS) TmpDir() string { return m.dir }
|
||||
func (m *MockFS) TagReader() tags.Reader { return m.tagReader }
|
||||
|
||||
func (m *MockFS) ScanAndClean() *scanner.State {
|
||||
m.t.Helper()
|
||||
@@ -119,6 +119,7 @@ func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
|
||||
p := func(format string, a ...any) string {
|
||||
return filepath.Join(prefix, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
for ar := range 3 {
|
||||
for al := range 3 {
|
||||
for tr := range 3 {
|
||||
@@ -128,13 +129,14 @@ func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
|
||||
}
|
||||
|
||||
m.AddTrack(path)
|
||||
m.SetTags(path, func(tags *TagInfo) {
|
||||
tags.RawArtist = fmt.Sprintf("artist-%d", ar)
|
||||
tags.RawAlbumArtist = fmt.Sprintf("artist-%d", ar)
|
||||
tags.RawAlbum = fmt.Sprintf("album-%d", al)
|
||||
tags.RawTitle = fmt.Sprintf("title-%d", tr)
|
||||
m.SetTags(path, func(info *TagInfo) {
|
||||
normtag.Set(info.Tags, normtag.Artist, fmt.Sprintf("artist-%d", ar))
|
||||
normtag.Set(info.Tags, normtag.AlbumArtist, fmt.Sprintf("artist-%d", ar))
|
||||
normtag.Set(info.Tags, normtag.Album, fmt.Sprintf("album-%d", al))
|
||||
normtag.Set(info.Tags, normtag.Title, fmt.Sprintf("title-%d", tr))
|
||||
})
|
||||
}
|
||||
|
||||
if covers {
|
||||
path := p("artist-%d/album-%d/cover.png", ar, al)
|
||||
if !match(onlyGlob, path) {
|
||||
@@ -172,7 +174,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)
|
||||
if err := os.Remove(abspath); err != nil {
|
||||
m.t.Fatalf("remove all: %v", err)
|
||||
@@ -182,8 +184,8 @@ func (m *MockFS) SetRealAudio(path string, length int, audioPath string) {
|
||||
m.t.Fatalf("symlink: %v", err)
|
||||
}
|
||||
m.SetTags(path, func(tags *TagInfo) {
|
||||
tags.RawLength = length
|
||||
tags.RawBitrate = 0
|
||||
tags.Length = length
|
||||
tags.Bitrate = bitrate
|
||||
})
|
||||
}
|
||||
|
||||
@@ -288,33 +290,33 @@ func (m *MockFS) AddCover(path string) {
|
||||
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)) {
|
||||
absPath := filepath.Join(m.dir, path)
|
||||
if err := os.Chtimes(absPath, time.Time{}, time.Now()); err != nil {
|
||||
m.t.Fatalf("touch track: %v", err)
|
||||
}
|
||||
if _, ok := m.tagReader.paths[absPath]; !ok {
|
||||
m.tagReader.paths[absPath] = &TagInfo{}
|
||||
m.tagReader.paths[absPath] = newTagInfo()
|
||||
}
|
||||
cb(m.tagReader.paths[absPath])
|
||||
}
|
||||
|
||||
func (m *MockFS) DumpDB(suffix ...string) {
|
||||
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)
|
||||
}
|
||||
var _ tags.Reader = (*tagReader)(nil)
|
||||
|
||||
type tagReader struct {
|
||||
paths map[string]*TagInfo
|
||||
@@ -325,65 +327,31 @@ func (m *tagReader) CanRead(absPath string) bool {
|
||||
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]
|
||||
if !ok {
|
||||
return nil, ErrPathNotFound
|
||||
return tags.Properties{}, nil, ErrPathNotFound
|
||||
}
|
||||
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 {
|
||||
RawTitle string
|
||||
RawArtist string
|
||||
RawArtists []string
|
||||
RawAlbum string
|
||||
RawAlbumArtist string
|
||||
RawAlbumArtists []string
|
||||
RawGenre string
|
||||
RawBitrate int
|
||||
RawLength int
|
||||
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) Lyrics() string { return "[00:01.58] Line one\n[00:03.44] Line two\n" }
|
||||
|
||||
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
|
||||
Tags map[string][]string
|
||||
Length time.Duration
|
||||
Bitrate uint
|
||||
Error error
|
||||
}
|
||||
|
||||
func match(pattern, name string) bool {
|
||||
|
||||
+6
-6
@@ -21,7 +21,7 @@ import (
|
||||
|
||||
"go.senan.xyz/gonic/db"
|
||||
"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")
|
||||
@@ -34,10 +34,10 @@ type Podcasts struct {
|
||||
httpClient *http.Client
|
||||
db *db.DB
|
||||
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{
|
||||
db: db,
|
||||
baseDir: base,
|
||||
@@ -536,14 +536,14 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
|
||||
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 {
|
||||
return fmt.Errorf("read podcast tags: %w", err)
|
||||
}
|
||||
|
||||
podcastEpisode.Status = db.PodcastEpisodeStatusCompleted
|
||||
podcastEpisode.Bitrate = podcastTags.Bitrate()
|
||||
podcastEpisode.Length = podcastTags.Length()
|
||||
podcastEpisode.Bitrate = int(podcastProps.Bitrate)
|
||||
podcastEpisode.Length = int(podcastProps.Length.Seconds())
|
||||
|
||||
stat, _ := file.Stat()
|
||||
podcastEpisode.Size = int(stat.Size())
|
||||
|
||||
+149
-72
@@ -25,8 +25,9 @@ import (
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/fileutil"
|
||||
"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/tags/normtag"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -38,12 +39,13 @@ type Scanner struct {
|
||||
db *db.DB
|
||||
musicDirs []string
|
||||
multiValueSettings map[Tag]MultiValueSetting
|
||||
tagReader tagcommon.Reader
|
||||
tagReader tags.Reader
|
||||
excludePattern *regexp.Regexp
|
||||
scanEmbeddedCover bool
|
||||
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
|
||||
if excludePattern != "" {
|
||||
excludePatternRegExp = regexp.MustCompile(excludePattern)
|
||||
@@ -55,13 +57,14 @@ func New(musicDirs []string, db *db.DB, multiValueSettings map[Tag]MultiValueSet
|
||||
multiValueSettings: multiValueSettings,
|
||||
tagReader: tagReader,
|
||||
excludePattern: excludePatternRegExp,
|
||||
scanEmbeddedCover: scanEmbeddedCover,
|
||||
scanning: new(int32),
|
||||
}
|
||||
}
|
||||
|
||||
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) StopScanning() { defer atomic.StoreInt32(s.scanning, 0) }
|
||||
func (s *Scanner) StopScanning() { atomic.StoreInt32(s.scanning, 0) }
|
||||
|
||||
type ScanOptions struct {
|
||||
IsFull bool
|
||||
@@ -250,16 +253,15 @@ func (s *Scanner) scanCallback(st *State, absPath string, d fs.DirEntry, err err
|
||||
|
||||
log.Printf("processing folder %q", absPath)
|
||||
|
||||
return s.db.Transaction(func(tx *db.DB) error {
|
||||
if err := s.scanDir(tx, st, absPath); err != nil {
|
||||
st.errs = append(st.errs, fmt.Errorf("%q: %w", absPath, err))
|
||||
return nil
|
||||
}
|
||||
if err := s.scanDir(st, absPath); err != nil {
|
||||
st.errs = append(st.errs, fmt.Errorf("%q: %w", absPath, err))
|
||||
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)
|
||||
if musicDir == absPath {
|
||||
return nil
|
||||
@@ -270,7 +272,7 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var tracks []string
|
||||
var trackPaths []string
|
||||
var cover string
|
||||
for _, item := range items {
|
||||
absPath := filepath.Join(absPath, item.Name())
|
||||
@@ -287,14 +289,14 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
|
||||
continue
|
||||
}
|
||||
if s.tagReader.CanRead(absPath) {
|
||||
tracks = append(tracks, item.Name())
|
||||
trackPaths = append(trackPaths, item.Name())
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
pdir, pbasename := filepath.Split(filepath.Dir(relPath))
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -302,46 +304,81 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
|
||||
|
||||
dir, basename := filepath.Split(relPath)
|
||||
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)
|
||||
}
|
||||
|
||||
st.seenAlbums[album.ID] = struct{}{}
|
||||
|
||||
sort.Strings(tracks)
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get times %q: %w", basename, err)
|
||||
}
|
||||
|
||||
var track db.Track
|
||||
if err := tx.Where("album_id=? AND filename=?", album.ID, filepath.Base(basename)).First(&track).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return fmt.Errorf("query track: %w", err)
|
||||
}
|
||||
|
||||
if !st.isFull && track.ID != 0 && timeSpec.ModTime().Before(track.UpdatedAt) {
|
||||
st.seenTracks[track.ID] = struct{}{}
|
||||
if len(trackPaths) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
trags, err := s.tagReader.Read(absPath)
|
||||
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)
|
||||
|
||||
timeSpec, err := times.Stat(absPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get times %q: %w", basename, err)
|
||||
}
|
||||
|
||||
// might be nil if new track
|
||||
track := trackMap[basename]
|
||||
|
||||
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 len(trackUpdates) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return s.db.Transaction(func(tx *db.DB) error {
|
||||
for _, t := range trackUpdates {
|
||||
if err := s.populateTrackAndArtists(tx, st, t.i, &album, t.track, t.timeSpec, t.basename, t.absPath); err != nil {
|
||||
return fmt.Errorf("populate track %q: %w", t.basename, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db.Album, track *db.Track, timeSpec times.Timespec, basename, absPath string) error {
|
||||
trprops, trags, err := s.tagReader.Read(absPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %w", err, ErrReadingTags)
|
||||
}
|
||||
|
||||
genreNames := ParseMulti(s.multiValueSettings[Genre], tagcommon.MustGenres(trags), tagcommon.MustGenre(trags))
|
||||
genreNames := ParseMulti(s.multiValueSettings[Genre], tags.MustGenres(trags), tags.MustGenre(trags))
|
||||
genreIDs, err := populateGenres(tx, genreNames)
|
||||
if err != nil {
|
||||
return fmt.Errorf("populate genres: %w", err)
|
||||
@@ -353,7 +390,7 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
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
|
||||
for _, albumArtistName := range albumArtistNames {
|
||||
albumArtist, err := populateArtist(tx, albumArtistName)
|
||||
@@ -387,14 +424,19 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
if err := populateTrackGenres(tx, &track, genreIDs); err != nil {
|
||||
if err := populateTrackGenres(tx, track, genreIDs); err != nil {
|
||||
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
|
||||
for _, trackArtistName := range trackArtistNames {
|
||||
trackArtist, err := populateArtist(tx, trackArtistName)
|
||||
@@ -403,7 +445,7 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -411,28 +453,58 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
return fmt.Errorf("populate track artists: %w", err)
|
||||
}
|
||||
|
||||
// possible album level embedded covers come only from the first track
|
||||
if i == 0 {
|
||||
if err := populateAlbumEmbeddedCover(tx, album, track, trprops); err != nil {
|
||||
return fmt.Errorf("populate embedded cover: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
st.seenTracks[track.ID] = struct{}{}
|
||||
st.seenTracksNew++
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime, createTime time.Time) error {
|
||||
albumName := tagcommon.MustAlbum(trags)
|
||||
func populateAlbumEmbeddedCover(tx *db.DB, album *db.Album, track *db.Track, trprops tags.Properties) error {
|
||||
var trackID int
|
||||
if 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.TagTitleUDec = decoded(albumName)
|
||||
album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags)
|
||||
album.TagBrainzID = trags.AlbumBrainzID()
|
||||
album.TagYear = trags.Year()
|
||||
album.TagCompilation = trags.Compilation()
|
||||
album.TagReleaseType = trags.ReleaseType()
|
||||
album.TagAlbumArtist = tags.MustAlbumArtist(trags)
|
||||
album.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzReleaseID)
|
||||
album.TagYear = tags.MustYear(trags)
|
||||
album.TagCompilation = tags.ParseBool(normtag.Get(trags, normtag.Compilation))
|
||||
album.TagReleaseType = normtag.Get(trags, normtag.ReleaseType)
|
||||
|
||||
album.ModifiedAt = modTime
|
||||
if album.CreatedAt.After(createTime) {
|
||||
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 nil
|
||||
@@ -455,38 +527,43 @@ func populateAlbumBasics(tx *db.DB, musicDir string, parent, album *db.Album, di
|
||||
album.RightPathUDec = decoded(basename)
|
||||
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 nil
|
||||
}
|
||||
|
||||
func populateTrack(tx *db.DB, album *db.Album, track *db.Track, trags tagcommon.Info, absPath string, size int) error {
|
||||
basename := filepath.Base(absPath)
|
||||
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 {
|
||||
track.Filename = basename
|
||||
track.FilenameUDec = decoded(basename)
|
||||
track.Size = size
|
||||
track.AlbumID = album.ID
|
||||
track.TagLyrics = trags.Lyrics()
|
||||
track.TagLyrics = normtag.Get(trags, normtag.Lyrics)
|
||||
|
||||
track.TagTitle = trags.Title()
|
||||
track.TagTitleUDec = decoded(trags.Title())
|
||||
track.TagTrackArtist = tagcommon.MustArtist(trags)
|
||||
track.TagTrackNumber = trags.TrackNumber()
|
||||
track.TagDiscNumber = trags.DiscNumber()
|
||||
track.TagBrainzID = trags.BrainzID()
|
||||
trackTitle := normtag.Get(trags, normtag.Title)
|
||||
track.TagTitle = trackTitle
|
||||
track.TagTitleUDec = decoded(trackTitle)
|
||||
track.TagTrackArtist = tags.MustArtist(trags)
|
||||
track.TagTrackNumber = tags.ParseInt(normtag.Get(trags, normtag.TrackNumber))
|
||||
track.TagDiscNumber = tags.ParseInt(normtag.Get(trags, normtag.DiscNumber))
|
||||
track.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzRecordingID)
|
||||
|
||||
track.ReplayGainTrackGain = trags.ReplayGainTrackGain()
|
||||
track.ReplayGainTrackPeak = trags.ReplayGainTrackPeak()
|
||||
track.ReplayGainAlbumGain = trags.ReplayGainAlbumGain()
|
||||
track.ReplayGainAlbumPeak = trags.ReplayGainAlbumPeak()
|
||||
track.ReplayGainTrackGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainTrackGain))
|
||||
track.ReplayGainTrackPeak = tags.ParseFloat(normtag.Get(trags, normtag.ReplayGainTrackPeak))
|
||||
track.ReplayGainAlbumGain = tags.ParseDB(normtag.Get(trags, normtag.ReplayGainAlbumGain))
|
||||
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
|
||||
track.Length = trags.Length()
|
||||
track.Bitrate = trags.Bitrate()
|
||||
track.Length = int(trprops.Length.Seconds())
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
+54
-53
@@ -17,6 +17,7 @@ import (
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
"go.senan.xyz/gonic/scanner"
|
||||
"go.senan.xyz/wrtag/tags/normtag"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -128,10 +129,10 @@ func TestUpdatedTags(t *testing.T) {
|
||||
|
||||
m.AddTrack("artist-10/album-10/track-10.flac")
|
||||
m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawArtist = "artist"
|
||||
tags.RawAlbumArtist = "album-artist"
|
||||
tags.RawAlbum = "album"
|
||||
tags.RawTitle = "title"
|
||||
normtag.Set(tags.Tags, normtag.Artist, "artist")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "album-artist")
|
||||
normtag.Set(tags.Tags, normtag.Album, "album")
|
||||
normtag.Set(tags.Tags, normtag.Title, "title")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
@@ -147,10 +148,10 @@ func TestUpdatedTags(t *testing.T) {
|
||||
assert.Equal(t, "album-artist", trackArtistA.Name) // track has tags
|
||||
|
||||
m.SetTags("artist-10/album-10/track-10.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawArtist = "artist-upd"
|
||||
tags.RawAlbumArtist = "album-artist-upd"
|
||||
tags.RawAlbum = "album-upd"
|
||||
tags.RawTitle = "title-upd"
|
||||
normtag.Set(tags.Tags, normtag.Artist, "artist-upd")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "album-artist-upd")
|
||||
normtag.Set(tags.Tags, normtag.Album, "album-upd")
|
||||
normtag.Set(tags.Tags, normtag.Title, "title-upd")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
@@ -174,7 +175,7 @@ func TestUpdatedAlbumGenre(t *testing.T) {
|
||||
|
||||
m.AddItems()
|
||||
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()
|
||||
@@ -184,7 +185,7 @@ func TestUpdatedAlbumGenre(t *testing.T) {
|
||||
assert.Equal(t, []string{"gen-a", "gen-b"}, genreStrings(album))
|
||||
|
||||
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()
|
||||
@@ -279,10 +280,10 @@ func TestGenres(t *testing.T) {
|
||||
}
|
||||
|
||||
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-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "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-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-g;genre-h" })
|
||||
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) { normtag.Set(tags.Tags, normtag.Genre, "genre-c;genre-d") })
|
||||
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) { normtag.Set(tags.Tags, normtag.Genre, "genre-g;genre-h") })
|
||||
m.ScanAndClean()
|
||||
|
||||
isGenre("genre-a") // genre exists
|
||||
@@ -302,7 +303,7 @@ func TestGenres(t *testing.T) {
|
||||
isAlbumGenre("artist-0/", "album-0", "genre-a") // 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()
|
||||
|
||||
isTrackGenre("artist-0/", "album-0", "track-0.flac", "genre-aa") // updated track genre exists
|
||||
@@ -366,10 +367,10 @@ func TestNewAlbumForExistingArtist(t *testing.T) {
|
||||
for tr := range 3 {
|
||||
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) {
|
||||
tags.RawArtist = "artist-2"
|
||||
tags.RawAlbumArtist = "artist-2"
|
||||
tags.RawAlbum = "new-album"
|
||||
tags.RawTitle = fmt.Sprintf("title-%d", tr)
|
||||
normtag.Set(tags.Tags, normtag.Artist, "artist-2")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "artist-2")
|
||||
normtag.Set(tags.Tags, normtag.Album, "new-album")
|
||||
normtag.Set(tags.Tags, normtag.Title, fmt.Sprintf("title-%d", tr))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -390,19 +391,19 @@ func TestMultiFolderWithSharedArtist(t *testing.T) {
|
||||
|
||||
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) {
|
||||
tags.RawArtist = artistName
|
||||
tags.RawAlbumArtist = artistName
|
||||
tags.RawAlbum = "album-a"
|
||||
tags.RawTitle = "track-1"
|
||||
normtag.Set(tags.Tags, normtag.Artist, artistName)
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, artistName)
|
||||
normtag.Set(tags.Tags, normtag.Album, "album-a")
|
||||
normtag.Set(tags.Tags, normtag.Title, "track-1")
|
||||
})
|
||||
m.ScanAndClean()
|
||||
|
||||
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) {
|
||||
tags.RawArtist = artistName
|
||||
tags.RawAlbumArtist = artistName
|
||||
tags.RawAlbum = "album-a"
|
||||
tags.RawTitle = "track-1"
|
||||
normtag.Set(tags.Tags, normtag.Artist, artistName)
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, artistName)
|
||||
normtag.Set(tags.Tags, normtag.Album, "album-a")
|
||||
normtag.Set(tags.Tags, normtag.Title, "track-1")
|
||||
})
|
||||
m.ScanAndClean()
|
||||
|
||||
@@ -462,10 +463,10 @@ func TestSymlinkedSubdiscs(t *testing.T) {
|
||||
p := fmt.Sprintf("%s/%s/%s/%s/%s", prefix, artist, album, disc, track)
|
||||
m.AddTrack(p)
|
||||
m.SetTags(p, func(tags *mockfs.TagInfo) {
|
||||
tags.RawArtist = artist
|
||||
tags.RawAlbumArtist = artist
|
||||
tags.RawAlbum = album
|
||||
tags.RawTitle = track
|
||||
normtag.Set(tags.Tags, normtag.Artist, artist)
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, artist)
|
||||
normtag.Set(tags.Tags, normtag.Album, album)
|
||||
normtag.Set(tags.Tags, normtag.Title, track)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -557,9 +558,9 @@ func TestCompilationAlbumWithoutAlbumArtist(t *testing.T) {
|
||||
m.AddTrack(p)
|
||||
m.SetTags(p, func(tags *mockfs.TagInfo) {
|
||||
// don't set an album artist
|
||||
tags.RawTitle = fmt.Sprintf("track %d", i)
|
||||
tags.RawArtist = fmt.Sprintf("artist %d", i)
|
||||
tags.RawAlbum = pathArtist
|
||||
normtag.Set(tags.Tags, normtag.Title, fmt.Sprintf("track %d", i))
|
||||
normtag.Set(tags.Tags, normtag.Artist, fmt.Sprintf("artist %d", i))
|
||||
normtag.Set(tags.Tags, normtag.Album, pathArtist)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -627,10 +628,10 @@ func TestNoOrphanedGenres(t *testing.T) {
|
||||
m := mockfs.New(t)
|
||||
|
||||
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-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "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-1.flac", func(tags *mockfs.TagInfo) { tags.RawGenre = "genre-g;genre-h" })
|
||||
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) { normtag.Set(tags.Tags, normtag.Genre, "genre-c;genre-d") })
|
||||
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) { normtag.Set(tags.Tags, normtag.Genre, "genre-g;genre-h") })
|
||||
m.ScanAndClean()
|
||||
|
||||
m.RemoveAll("artist-0")
|
||||
@@ -649,7 +650,7 @@ func TestNoOrphanedGenresButOnlyDeleteTracks(t *testing.T) {
|
||||
m := mockfs.New(t)
|
||||
|
||||
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()
|
||||
|
||||
trackPaths, err := filepath.Glob(filepath.Join(m.TmpDir(), "*", "*", "*.flac"))
|
||||
@@ -684,16 +685,16 @@ func TestMultiArtistSupport(t *testing.T) {
|
||||
|
||||
m.AddItemsGlob("artist-0/album-[012]/track-0.*")
|
||||
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Mutator"
|
||||
tags.RawAlbumArtists = []string{"Alan Vega", "Liz Lamere"}
|
||||
normtag.Set(tags.Tags, normtag.Album, "Mutator")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Liz Lamere")
|
||||
})
|
||||
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Dead Man"
|
||||
tags.RawAlbumArtists = []string{"Alan Vega", "Mercury Rev"}
|
||||
normtag.Set(tags.Tags, normtag.Album, "Dead Man")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Mercury Rev")
|
||||
})
|
||||
m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Yerself Is Steam"
|
||||
tags.RawAlbumArtist = "Mercury Rev"
|
||||
normtag.Set(tags.Tags, normtag.Album, "Yerself Is Steam")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "Mercury Rev")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
@@ -732,8 +733,8 @@ func TestMultiArtistSupport(t *testing.T) {
|
||||
|
||||
m.RemoveAll("artist-0/album-2")
|
||||
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Dead Man"
|
||||
tags.RawAlbumArtists = []string{"Alan Vega"}
|
||||
normtag.Set(tags.Tags, normtag.Album, "Dead Man")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
@@ -758,16 +759,16 @@ func TestMultiArtistPreload(t *testing.T) {
|
||||
|
||||
m.AddItemsGlob("artist-0/album-[012]/track-0.*")
|
||||
m.SetTags("artist-0/album-0/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Mutator"
|
||||
tags.RawAlbumArtists = []string{"Alan Vega", "Liz Lamere"}
|
||||
normtag.Set(tags.Tags, normtag.Album, "Mutator")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Liz Lamere")
|
||||
})
|
||||
m.SetTags("artist-0/album-1/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Dead Man"
|
||||
tags.RawAlbumArtists = []string{"Alan Vega", "Mercury Rev"}
|
||||
normtag.Set(tags.Tags, normtag.Album, "Dead Man")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtists, "Alan Vega", "Mercury Rev")
|
||||
})
|
||||
m.SetTags("artist-0/album-2/track-0.flac", func(tags *mockfs.TagInfo) {
|
||||
tags.RawAlbum = "Yerself Is Steam"
|
||||
tags.RawAlbumArtist = "Mercury Rev"
|
||||
normtag.Set(tags.Tags, normtag.Album, "Yerself Is Steam")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "Mercury Rev")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
|
||||
+34
-29
@@ -26,6 +26,7 @@ import (
|
||||
"go.senan.xyz/gonic/scrobble"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||
"go.senan.xyz/gonic/tags"
|
||||
"go.senan.xyz/gonic/transcode"
|
||||
)
|
||||
|
||||
@@ -54,41 +55,45 @@ type ProxyPathResolver func(in string) string
|
||||
type Controller struct {
|
||||
*http.ServeMux
|
||||
|
||||
dbc *db.DB
|
||||
scanner *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
|
||||
dbc *db.DB
|
||||
scanner *scanner.Scanner
|
||||
musicPaths []MusicPath
|
||||
podcastsPath string
|
||||
cacheAudioPath string
|
||||
cacheCoverPath string
|
||||
jukebox *jukebox.Jukebox
|
||||
playlistStore *playlist.Store
|
||||
scrobblers []scrobble.Scrobbler
|
||||
podcasts *podcast.Podcasts
|
||||
transcoder transcode.Transcoder
|
||||
lastFMClient *lastfm.Client
|
||||
artistInfoCache *artistinfocache.ArtistInfoCache
|
||||
albumInfoCache *albuminfocache.AlbumInfoCache
|
||||
tagReader tags.Reader
|
||||
|
||||
resolveProxyPath ProxyPathResolver
|
||||
}
|
||||
|
||||
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, ldapConfig ldap.Config) (*Controller, error) {
|
||||
func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPath string, cacheAudioPath string, cacheCoverPath string, jukebox *jukebox.Jukebox, playlistStore *playlist.Store, scrobblers []scrobble.Scrobbler, podcasts *podcast.Podcasts, transcoder transcode.Transcoder, lastFMClient *lastfm.Client, artistInfoCache *artistinfocache.ArtistInfoCache, albumInfoCache *albuminfocache.AlbumInfoCache, tagReader tags.Reader, resolveProxyPath ProxyPathResolver, ldapConfig ldap.Config) (*Controller, error) {
|
||||
c := Controller{
|
||||
ServeMux: http.NewServeMux(),
|
||||
|
||||
dbc: dbc,
|
||||
scanner: scannr,
|
||||
musicPaths: musicPaths,
|
||||
podcastsPath: podcastsPath,
|
||||
cacheAudioPath: cacheAudioPath,
|
||||
cacheCoverPath: cacheCoverPath,
|
||||
jukebox: jukebox,
|
||||
playlistStore: playlistStore,
|
||||
scrobblers: scrobblers,
|
||||
podcasts: podcasts,
|
||||
transcoder: transcoder,
|
||||
lastFMClient: lastFMClient,
|
||||
artistInfoCache: artistInfoCache,
|
||||
albumInfoCache: albumInfoCache,
|
||||
dbc: dbc,
|
||||
scanner: scannr,
|
||||
musicPaths: musicPaths,
|
||||
podcastsPath: podcastsPath,
|
||||
cacheAudioPath: cacheAudioPath,
|
||||
cacheCoverPath: cacheCoverPath,
|
||||
jukebox: jukebox,
|
||||
playlistStore: playlistStore,
|
||||
scrobblers: scrobblers,
|
||||
podcasts: podcasts,
|
||||
transcoder: transcoder,
|
||||
lastFMClient: lastFMClient,
|
||||
artistInfoCache: artistInfoCache,
|
||||
albumInfoCache: albumInfoCache,
|
||||
tagReader: tagReader,
|
||||
|
||||
resolveProxyPath: resolveProxyPath,
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
jd "github.com/josephburnett/jd/lib"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -142,9 +143,9 @@ func makec(tb testing.TB, roots []string, audio bool) *Controller {
|
||||
if !audio {
|
||||
continue
|
||||
}
|
||||
m.SetRealAudio(filepath.Join(root, "artist-0/album-0/track-0.flac"), 10, audioPath10s)
|
||||
m.SetRealAudio(filepath.Join(root, "artist-0/album-0/track-1.flac"), 10, 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-0.flac"), 10*time.Second, 0, audioPath10s)
|
||||
m.SetAudio(filepath.Join(root, "artist-0/album-0/track-1.flac"), 10*time.Second, 0, audioPath10s)
|
||||
m.SetAudio(filepath.Join(root, "artist-0/album-0/track-2.flac"), 10*time.Second, 0, audioPath10s)
|
||||
}
|
||||
|
||||
m.ScanAndClean()
|
||||
|
||||
@@ -198,6 +198,7 @@ func (c *Controller) ServeGetAlbumListTwo(r *http.Request) *spec.Response {
|
||||
Offset(params.GetOrInt("offset", 0)).
|
||||
Limit(params.GetOrInt("size", 10)).
|
||||
Preload("Artists").
|
||||
Preload("Genres").
|
||||
Preload("AlbumStar", "user_id=?", user.ID).
|
||||
Preload("AlbumRating", "user_id=?", user.ID).
|
||||
Preload("Play", "user_id=?", user.ID).
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -512,30 +513,37 @@ func (c *Controller) ServeGetLyrics(r *http.Request) *spec.Response {
|
||||
|
||||
sub := spec.NewResponse()
|
||||
|
||||
if track.TagLyrics != "" {
|
||||
sub.Lyrics = &spec.Lyrics{
|
||||
Value: track.TagLyrics,
|
||||
Artist: track.TagTrackArtist,
|
||||
Title: track.TagTitle,
|
||||
}
|
||||
return sub
|
||||
}
|
||||
|
||||
_, text, err := lyricsFile(track)
|
||||
if os.IsNotExist(err) {
|
||||
return sub
|
||||
}
|
||||
if err != nil {
|
||||
return spec.NewError(0, "lyricsFile: %v", err)
|
||||
}
|
||||
|
||||
contents := strings.Join(text, "\n")
|
||||
|
||||
sub.Lyrics = &spec.Lyrics{
|
||||
Value: contents,
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -562,81 +570,165 @@ func (c *Controller) ServeGetLyricsBySongID(r *http.Request) *spec.Response {
|
||||
}
|
||||
|
||||
sub := spec.NewResponse()
|
||||
sub.LyricsList = &spec.LyricsList{
|
||||
StructuredLyrics: []*spec.StructuredLyrics{},
|
||||
}
|
||||
|
||||
if track.TagLyrics != "" {
|
||||
times, lrc, err := lrc.ParseString(track.TagLyrics)
|
||||
if err != nil {
|
||||
return spec.NewError(0, "lyricsFile: %v", err)
|
||||
}
|
||||
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: time.Milliseconds(),
|
||||
Start: &start,
|
||||
Value: strings.TrimSpace(lrc[i]),
|
||||
}
|
||||
}
|
||||
|
||||
structured := spec.StructuredLyrics{
|
||||
Lang: "xxx",
|
||||
Synced: true,
|
||||
Lines: lines,
|
||||
DisplayArtist: track.TagTrackArtist,
|
||||
DisplayTitle: track.TagTitle,
|
||||
Offset: 0,
|
||||
}
|
||||
r.Synced = true
|
||||
r.Lines = lines
|
||||
|
||||
sub.LyricsList = &spec.LyricsList{
|
||||
StructuredLyrics: []spec.StructuredLyrics{structured},
|
||||
}
|
||||
return sub
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
times, lrc, err := lyricsFile(track)
|
||||
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 {
|
||||
if os.IsNotExist(err) {
|
||||
sub.LyricsList = &spec.LyricsList{
|
||||
StructuredLyrics: []spec.StructuredLyrics{},
|
||||
}
|
||||
return sub
|
||||
}
|
||||
return spec.NewError(0, "lyricsFile: %v", err)
|
||||
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: time.Milliseconds(),
|
||||
Start: &start,
|
||||
Value: strings.TrimSpace(lrc[i]),
|
||||
}
|
||||
}
|
||||
|
||||
structured := spec.StructuredLyrics{
|
||||
r := spec.StructuredLyrics{
|
||||
Lang: "xxx",
|
||||
Synced: true,
|
||||
Lines: lines,
|
||||
DisplayArtist: track.TagTrackArtist,
|
||||
DisplayTitle: track.TagTitle,
|
||||
Offset: 0,
|
||||
}
|
||||
|
||||
sub.LyricsList = &spec.LyricsList{
|
||||
StructuredLyrics: []spec.StructuredLyrics{structured},
|
||||
}
|
||||
return sub
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func lyricsFile(file db.Track) ([]lrc.Duration, []lrc.Text, error) {
|
||||
filePath := file.AbsPath()
|
||||
func lyricsFromFileUnsynced(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"))
|
||||
text, err := os.ReadFile(filepath.Join(fileDir, fileName+".txt"))
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return []lrc.Duration{}, []lrc.Text{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lrc.Parse(lrcContent)
|
||||
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 {
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specidpaths"
|
||||
"go.senan.xyz/gonic/tags"
|
||||
"go.senan.xyz/gonic/transcode"
|
||||
)
|
||||
|
||||
@@ -49,7 +50,7 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
|
||||
_, err = os.Stat(cachePath)
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
reader, err := coverFor(c.dbc, c.artistInfoCache, id)
|
||||
reader, err := coverFor(c.dbc, c.artistInfoCache, c.tagReader, id)
|
||||
if err != nil {
|
||||
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
|
||||
}
|
||||
@@ -76,7 +77,7 @@ var (
|
||||
)
|
||||
|
||||
// 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, tagReader tags.Reader, id specid.ID) (io.ReadCloser, error) {
|
||||
switch id.Type {
|
||||
case specid.Album:
|
||||
return coverForAlbum(dbc, id.Value)
|
||||
@@ -85,7 +86,9 @@ func coverFor(dbc *db.DB, artistInfoCache *artistinfocache.ArtistInfoCache, id s
|
||||
case specid.Podcast:
|
||||
return coverForPodcast(dbc, id.Value)
|
||||
case specid.PodcastEpisode:
|
||||
return coverGetPathPodcastEpisode(dbc, id.Value)
|
||||
return coverForPodcastEpisode(dbc, id.Value)
|
||||
case specid.Track:
|
||||
return coverForTrack(dbc, tagReader, id.Value)
|
||||
default:
|
||||
return nil, errCoverNotFound
|
||||
}
|
||||
@@ -135,7 +138,7 @@ func coverForPodcast(dbc *db.DB, id int) (*os.File, error) {
|
||||
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
|
||||
err := dbc.
|
||||
Preload("Podcast").
|
||||
@@ -150,14 +153,38 @@ func coverGetPathPodcastEpisode(dbc *db.DB, id int) (*os.File, error) {
|
||||
return os.Open(filepath.Join(pe.Podcast.RootDir, pe.Podcast.Image))
|
||||
}
|
||||
|
||||
func coverForTrack(dbc *db.DB, tagReader tags.Reader, id int) (io.ReadCloser, error) {
|
||||
var tr db.Track
|
||||
err := dbc.
|
||||
Preload("Album").
|
||||
First(&tr, id).
|
||||
Error
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("select track: %w", err)
|
||||
}
|
||||
|
||||
absPath := tr.AbsPath()
|
||||
|
||||
cover, err := tagReader.ReadCover(absPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read cover: %w", err)
|
||||
}
|
||||
if len(cover) == 0 {
|
||||
return nil, errCoverEmpty
|
||||
}
|
||||
|
||||
return io.NopCloser(bytes.NewReader(cover)), nil
|
||||
}
|
||||
|
||||
func coverScaleAndSave(reader io.Reader, cachePath string, size int) error {
|
||||
src, err := imaging.Decode(reader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resizing: %w", err)
|
||||
}
|
||||
width := min(size,
|
||||
// don't upscale images
|
||||
src.Bounds().Dx())
|
||||
|
||||
// don't upscale images
|
||||
width := min(size, src.Bounds().Dx())
|
||||
|
||||
if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil {
|
||||
return fmt.Errorf("caching %q: %w", cachePath, err)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ func NewAlbumByFolder(f *db.Album) *Album {
|
||||
}
|
||||
if f.Cover != "" {
|
||||
a.CoverID = f.SID()
|
||||
} else if f.EmbeddedCoverTrackID != nil {
|
||||
a.CoverID = f.EmbeddedCoverTrackSID()
|
||||
}
|
||||
return a
|
||||
}
|
||||
@@ -52,7 +54,10 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
|
||||
}
|
||||
if f.Cover != "" {
|
||||
trCh.CoverID = f.SID()
|
||||
} else if f.EmbeddedCoverTrackID != nil {
|
||||
trCh.CoverID = f.EmbeddedCoverTrackSID()
|
||||
}
|
||||
|
||||
return trCh
|
||||
}
|
||||
|
||||
@@ -84,9 +89,16 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
|
||||
if trCh.Title == "" {
|
||||
trCh.Title = t.Filename
|
||||
}
|
||||
if parent.Cover != "" {
|
||||
|
||||
switch {
|
||||
case t.HasEmbeddedCover:
|
||||
trCh.CoverID = t.SID()
|
||||
case parent.Cover != "":
|
||||
trCh.CoverID = parent.SID()
|
||||
case parent.EmbeddedCoverTrackID != nil:
|
||||
trCh.CoverID = parent.EmbeddedCoverTrackSID()
|
||||
}
|
||||
|
||||
if t.Album != nil {
|
||||
trCh.Album = t.Album.RightPath
|
||||
trCh.AlbumID = t.Album.SID()
|
||||
@@ -163,6 +175,8 @@ func NewArtistByFolder(f *db.Album) *Artist {
|
||||
}
|
||||
if f.Cover != "" {
|
||||
a.CoverID = f.SID()
|
||||
} else if f.EmbeddedCoverTrackID != nil {
|
||||
a.CoverID = f.EmbeddedCoverTrackSID()
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
|
||||
}
|
||||
if a.Cover != "" {
|
||||
ret.CoverID = a.SID()
|
||||
} else if a.EmbeddedCoverTrackID != nil {
|
||||
ret.CoverID = a.EmbeddedCoverTrackSID()
|
||||
}
|
||||
if a.AlbumStar != nil {
|
||||
ret.Starred = &a.AlbumStar.StarDate
|
||||
@@ -88,9 +90,16 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
|
||||
AverageRating: formatRating(t.AverageRating),
|
||||
TranscodeMeta: TranscodeMeta{},
|
||||
}
|
||||
if album.Cover != "" {
|
||||
|
||||
switch {
|
||||
case t.HasEmbeddedCover:
|
||||
ret.CoverID = t.SID()
|
||||
case album.Cover != "":
|
||||
ret.CoverID = album.SID()
|
||||
case album.EmbeddedCoverTrackID != nil:
|
||||
ret.CoverID = album.EmbeddedCoverTrackSID()
|
||||
}
|
||||
|
||||
if t.TrackStar != nil {
|
||||
ret.Starred = &t.TrackStar.StarDate
|
||||
}
|
||||
|
||||
@@ -477,12 +477,12 @@ type Lyrics struct {
|
||||
}
|
||||
|
||||
type Lyric struct {
|
||||
Start int64 `xml:"start,attr" json:"start"`
|
||||
Start *int64 `xml:"start,attr,omitempty" json:"start,omitempty"`
|
||||
Value string `xml:",chardata" json:"value"`
|
||||
}
|
||||
|
||||
type LyricsList struct {
|
||||
StructuredLyrics []StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
|
||||
StructuredLyrics []*StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
|
||||
}
|
||||
|
||||
type StructuredLyrics struct {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -39,6 +41,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -57,6 +61,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -75,6 +81,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -93,6 +101,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -111,6 +121,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -129,6 +141,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -147,6 +161,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -165,6 +181,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -39,6 +41,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -57,6 +61,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -75,6 +81,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -93,6 +101,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -111,6 +121,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -129,6 +141,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -147,6 +161,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -165,6 +181,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -39,6 +41,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -57,6 +61,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -75,6 +81,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -93,6 +101,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -111,6 +121,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -129,6 +141,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -147,6 +161,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -165,6 +181,8 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
|
||||
+113
-95
@@ -7,6 +7,26 @@
|
||||
"openSubsonic": true,
|
||||
"albumList2": {
|
||||
"album": [
|
||||
{
|
||||
"id": "al-5",
|
||||
"created": "2019-11-30T00:00:00Z",
|
||||
"artistId": "ar-1",
|
||||
"artist": "artist-0",
|
||||
"artists": [{ "id": "ar-1", "name": "artist-0" }],
|
||||
"displayArtist": "artist-0",
|
||||
"title": "album-2",
|
||||
"album": "album-2",
|
||||
"coverArt": "al-5",
|
||||
"name": "album-2",
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
},
|
||||
{
|
||||
"id": "al-3",
|
||||
"created": "2019-11-30T00:00:00Z",
|
||||
@@ -21,24 +41,8 @@
|
||||
"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,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
@@ -57,96 +61,28 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"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-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",
|
||||
"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"]
|
||||
@@ -165,6 +101,88 @@
|
||||
"songCount": 3,
|
||||
"duration": 300,
|
||||
"playCount": 0,
|
||||
"genre": "Unknown Genre",
|
||||
"genres": [{ "name": "Unknown Genre" }],
|
||||
"year": 2021,
|
||||
"isCompilation": false,
|
||||
"releaseTypes": ["Album"]
|
||||
},
|
||||
{
|
||||
"id": "al-12",
|
||||
"created": "2019-11-30T00:00:00Z",
|
||||
"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"]
|
||||
},
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
{
|
||||
"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"]
|
||||
},
|
||||
{
|
||||
"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"]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -1,115 +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
|
||||
Lyrics() string
|
||||
|
||||
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
|
||||
}
|
||||
+16
-95
@@ -3,16 +3,17 @@ package taglib
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/sentriz/audiotags"
|
||||
"go.senan.xyz/gonic/tags/tagcommon"
|
||||
"go.senan.xyz/gonic/tags"
|
||||
"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 {
|
||||
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv":
|
||||
return true
|
||||
@@ -20,100 +21,20 @@ func (TagLib) CanRead(absPath string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (TagLib) Read(absPath string) (tagcommon.Info, error) {
|
||||
f, err := audiotags.Open(absPath)
|
||||
func (Reader) Read(absPath string) (tags.Properties, tags.Tags, error) {
|
||||
tp, err := taglib.ReadProperties(absPath)
|
||||
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 {
|
||||
raw map[string][]string
|
||||
props *audiotags.AudioProperties
|
||||
}
|
||||
|
||||
// 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) Lyrics() string {
|
||||
return first(find(i.raw, "lyrics", "lyrics:description", "USLT:description", "LYRICS", "Lyrics", "©lyr"))
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
tag, err := taglib.ReadTags(absPath)
|
||||
if err != nil {
|
||||
return tags.Properties{}, nil, fmt.Errorf("read tags: %w", err)
|
||||
}
|
||||
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 {
|
||||
for _, k := range keys {
|
||||
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
|
||||
func (Reader) ReadCover(absPath string) ([]byte, error) {
|
||||
return taglib.ReadImage(absPath)
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
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 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 := normtag.Values(p, normtag.Artists); len(r) > 0 {
|
||||
return r
|
||||
}
|
||||
return []string{MustArtist(p)}
|
||||
}
|
||||
|
||||
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 := normtag.Values(p, normtag.AlbumArtists); len(r) > 0 {
|
||||
return r
|
||||
}
|
||||
return []string{MustAlbumArtist(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 := normtag.Values(p, normtag.Genres); len(r) > 0 {
|
||||
return r
|
||||
}
|
||||
return []string{MustGenre(p)}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.17.0
|
||||
0.18.0
|
||||
Reference in New Issue
Block a user