Merge branch 'master' into ldap_auth

This commit is contained in:
2025-09-21 06:37:41 +02:00
68 changed files with 1411 additions and 644 deletions

No files matched your search

+4 -5
View File
@@ -31,13 +31,12 @@ jobs:
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite libtag1-dev ffmpeg mpv zlib1g-dev
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: v1.54
args: --timeout=5m
install-mode: "goinstall"
install-mode: goinstall
version: v2.4.0
- name: Test
run: go test ./...
build-release:
+4 -5
View File
@@ -17,13 +17,12 @@ jobs:
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite libtag1-dev ffmpeg mpv zlib1g-dev
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: v1.54
args: --timeout=5m
install-mode: "goinstall"
install-mode: goinstall
version: v2.4.0
- name: Test
run: go test ./...
release-please:
+4 -5
View File
@@ -18,12 +18,11 @@ jobs:
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y -qq build-essential git sqlite libtag1-dev ffmpeg mpv zlib1g-dev
sudo apt install -y -qq build-essential git sqlite3 libtag1-dev ffmpeg mpv zlib1g-dev
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: v1.54
args: --timeout=5m
install-mode: "goinstall"
install-mode: goinstall
version: v2.4.0
- name: Test
run: go test ./...
+50 -33
View File
@@ -1,10 +1,6 @@
run:
skip-dirs:
- server/assets
skip-dirs-use-default: true
version: "2"
linters:
disable-all: true
default: none
enable:
- asasalint
- asciicheck
@@ -19,8 +15,6 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exportloopref
- forbidigo
- ginkgolinter
- gocheckcompilerdirectives
@@ -29,13 +23,10 @@ linters:
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
@@ -56,34 +47,60 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- testableexamples
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- wastedassign
- whitespace
- zerologlint
issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gochecknoglobals
- text: "weak cryptographic primitive"
linters:
- gosec
- text: "weak random number generator"
linters:
- gosec
- text: "at least one file in a package should have a package comment"
linters:
- stylecheck
- text: "should rewrite switch"
linters:
- gocritic
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- errcheck
- gochecknoglobals
path: _test\.go
- linters:
- gosec
text: weak cryptographic primitive
- linters:
- gosec
text: weak random number generator
- linters:
- gosec
text: integer overflow conversion
- linters:
- staticcheck
text: at least one file in a package should have a package comment
- linters:
- gocritic
text: should rewrite switch
paths:
- server/assets
- third_party$
- builtin$
- examples$
settings:
staticcheck:
checks:
- all
- "-QF1001"
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- server/assets
- third_party$
- builtin$
- examples$
+40
View File
@@ -1,5 +1,45 @@
# Changelog
## [0.17.0](https://www.github.com/sentriz/gonic/compare/v0.16.4...v0.17.0) (2025-08-21)
### Features
* **db:** add a covering index on tracks (album_id, length) ([018343d](https://www.github.com/sentriz/gonic/commit/018343dc32fd89685ca3eb80ceb3116615a6cbec)), closes [#508](https://www.github.com/sentriz/gonic/issues/508)
* **lastfm:** paginate loved tracks ([5c7d065](https://www.github.com/sentriz/gonic/commit/5c7d065fd7513f66604d78409859c4028ca9ad70))
* **playlist:** assume playlists in the root dir without a user dir belong to admin ([#499](https://www.github.com/sentriz/gonic/issues/499)) ([f5893ea](https://www.github.com/sentriz/gonic/commit/f5893ea5ea4d47a82212b47e85a15d9defdc5eff))
* **podcast:** download most recent episode when switching to download recent mode ([c222ecb](https://www.github.com/sentriz/gonic/commit/c222ecb45cec5282e0ef892db21eb32632a0145d)), closes [#557](https://www.github.com/sentriz/gonic/issues/557)
* **podcast:** use podcast author if episode author is not defined ([#574](https://www.github.com/sentriz/gonic/issues/574)) ([19b707c](https://www.github.com/sentriz/gonic/commit/19b707c5d4081242825704eed764c257e6161865))
* **scanner:** cleanup bookmarks on scan ([#583](https://www.github.com/sentriz/gonic/issues/583)) ([b8dfe14](https://www.github.com/sentriz/gonic/commit/b8dfe1449e1f9ee93193b32b1e9d3e233e23706d))
* **scanner:** support full scan cleanups in watcher ([#496](https://www.github.com/sentriz/gonic/issues/496)) ([93ce039](https://www.github.com/sentriz/gonic/commit/93ce039963821dbfa0acec6ee9c92134ff479fcc))
* **scanner:** use wrtag/coverparse for cover selection ([453639e](https://www.github.com/sentriz/gonic/commit/453639ee34da28dc47f64865d490445968c23ce8)), closes [#338](https://www.github.com/sentriz/gonic/issues/338) [#516](https://www.github.com/sentriz/gonic/issues/516)
* **subsonic:** allow search albums with MBID ([7b19101](https://www.github.com/sentriz/gonic/commit/7b19101a34702bdeaeacf57dbc3db9226f0169f3))
* **subsonic:** allow search with MBID ([#579](https://www.github.com/sentriz/gonic/issues/579)) ([2d4111d](https://www.github.com/sentriz/gonic/commit/2d4111dfc5226e99fe9fee23e415806960ea7a5c))
* **subsonic:** bump image cache expiration ([bbe16b7](https://www.github.com/sentriz/gonic/commit/bbe16b7555f1d7300f829171f73c8308ae506fd3))
* **subsonic:** expose album `isCompilation` and `releaseTypes` ([29b7549](https://www.github.com/sentriz/gonic/commit/29b754973db9106bf1061a7aadb2b9b93b1fbf17))
* **subsonic:** expose replaygain tags ([0e45f5e](https://www.github.com/sentriz/gonic/commit/0e45f5e84cd650211351179edf3eed89a54c6c75))
* **subsonic:** fallback to filename when title is missing tags ([58d54c2](https://www.github.com/sentriz/gonic/commit/58d54c287cb6711959707b50207ea700df25d1cf)), closes [#541](https://www.github.com/sentriz/gonic/issues/541)
* **subsonic:** support more podcast metadata and podcast bookmarks ([#569](https://www.github.com/sentriz/gonic/issues/569)) ([63a420d](https://www.github.com/sentriz/gonic/commit/63a420d2d32b006a92b3aa5d97bc39ad49fc8155))
* **transcode:** add cache pruning and config options ([bcb613c](https://www.github.com/sentriz/gonic/commit/bcb613c79c6a822adeafc802f19b7626bfb64009))
### Bug Fixes
* **admin:** better handing of resolve proxy path escaping ([7b21e82](https://www.github.com/sentriz/gonic/commit/7b21e82aaf511d36300fd9cf2dae32a1196a4f77)), closes [#493](https://www.github.com/sentriz/gonic/issues/493)
* **adminui:** resolve reverse proxy paths for fonts ([718686a](https://www.github.com/sentriz/gonic/commit/718686a93a4341c5b5ccb113a0ed7ae95c0524b4)), closes [#543](https://www.github.com/sentriz/gonic/issues/543)
* **ci:** bump golangci-lint ([640d872](https://www.github.com/sentriz/gonic/commit/640d872f4c66d21b760590ae9413cc5b63b53cb6))
* **ci:** ignore gosec integer overflow conversion ([120fd79](https://www.github.com/sentriz/gonic/commit/120fd7959a8e360fdccc6bd1a47e8cc7ebdbb0d4))
* **ci:** update .golangci.yml exclude config ([e5f7ef3](https://www.github.com/sentriz/gonic/commit/e5f7ef3c86d6a52709336f2dd2d428203e7d9472))
* **ci:** use new sqlite package name ([1c23771](https://www.github.com/sentriz/gonic/commit/1c2377189da75c78831955953f25dd09b3cb7bb2))
* **dockerfile:** install abuild key ([#526](https://www.github.com/sentriz/gonic/issues/526)) ([fb36dbf](https://www.github.com/sentriz/gonic/commit/fb36dbf71991424879be85950ab508bcdf653902))
* **playlist:** fix non-admin users not being able to create playlists ([#524](https://www.github.com/sentriz/gonic/issues/524)) ([ac798ac](https://www.github.com/sentriz/gonic/commit/ac798ac2d2cdf936b653577d9acd4b7d1e22ecaf))
* **podcast:** gracefully handle no podcast cover URL ([#547](https://www.github.com/sentriz/gonic/issues/547)) ([aef5f92](https://www.github.com/sentriz/gonic/commit/aef5f920d24c57bc5b652891409926ff98458aa0))
* **subsonic:** gracefully handle missing playqueue items ([3fc9d5d](https://www.github.com/sentriz/gonic/commit/3fc9d5dcb5af0db8286d7be7c895726cf9b437cc))
* **subsonic:** order some browse-by-tag responses ([39df00e](https://www.github.com/sentriz/gonic/commit/39df00ef8f683a846efd0da7480c3db6d928d2c4)), closes [#512](https://www.github.com/sentriz/gonic/issues/512)
* **subsonic:** populate ArtistID and AlbumID for playlists ([#567](https://www.github.com/sentriz/gonic/issues/567)) ([c6d8751](https://www.github.com/sentriz/gonic/commit/c6d87515c6702c3ca22fef6ba1420ffc00eeaa77))
* **subsonic:** skip bookmarks for missing items instead of failing ([#580](https://www.github.com/sentriz/gonic/issues/580)) ([e3dc188](https://www.github.com/sentriz/gonic/commit/e3dc1887730cb019a91e74ad8a133a31839dbf56))
* **taglib:** support lower case filenames again ([8a0fa05](https://www.github.com/sentriz/gonic/commit/8a0fa05c7cdcb98066c263fea72af0715864bea5)), closes [#491](https://www.github.com/sentriz/gonic/issues/491)
### [0.16.4](https://www.github.com/sentriz/gonic/compare/v0.16.3...v0.16.4) (2024-03-20)
+11 -22
View File
@@ -1,24 +1,13 @@
FROM alpine:3.19 AS builder-taglib
WORKDIR /tmp
COPY alpine/taglib/APKBUILD .
RUN apk update && \
apk add --no-cache abuild && \
abuild-keygen -a -n && \
REPODEST=/pkgs abuild -F -r
FROM golang:1.21-alpine AS builder
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
# TODO: delete this block when taglib v2 is on alpine packages
COPY --from=builder-taglib /pkgs/*/*.apk /pkgs/
RUN apk add --no-cache --allow-untrusted /pkgs/*
WORKDIR /src
COPY go.mod .
COPY go.sum .
@@ -26,8 +15,8 @@ RUN go mod download
COPY . .
RUN GOOS=linux go build -o gonic cmd/gonic/gonic.go
FROM alpine:3.19
LABEL org.opencontainers.image.source https://github.com/sentriz/gonic
FROM alpine:3.22
LABEL org.opencontainers.image.source=https://github.com/sentriz/gonic
RUN apk add -U --no-cache \
ffmpeg \
mpv \
@@ -46,12 +35,12 @@ COPY --from=builder \
/bin/
VOLUME ["/cache", "/data", "/music", "/podcasts"]
EXPOSE 80
ENV TZ ""
ENV GONIC_DB_PATH /data/gonic.db
ENV GONIC_LISTEN_ADDR :80
ENV GONIC_MUSIC_PATH /music
ENV GONIC_PODCAST_PATH /podcasts
ENV GONIC_CACHE_PATH /cache
ENV GONIC_PLAYLISTS_PATH /playlists
ENV TZ=
ENV GONIC_DB_PATH=/data/gonic.db
ENV GONIC_LISTEN_ADDR=:80
ENV GONIC_MUSIC_PATH=/music
ENV GONIC_PODCAST_PATH=/podcasts
ENV GONIC_CACHE_PATH=/cache
ENV GONIC_PLAYLISTS_PATH=/playlists
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["gonic"]
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine AS builder
FROM golang:1.24-alpine3.22 AS builder
RUN apk add -U --no-cache \
build-base \
ca-certificates \
+8 -8
View File
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:experimental
FROM golang:1.21-alpine AS builder
FROM golang:1.24-alpine3.22 AS builder
RUN apk add -U --no-cache \
build-base \
ca-certificates \
@@ -14,7 +14,7 @@ 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.18
FROM alpine:3.22
RUN apk add -U --no-cache \
ffmpeg \
mpv \
@@ -30,10 +30,10 @@ COPY --from=builder \
/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
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"]
+6 -2
View File
@@ -24,7 +24,7 @@
- support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
- newer salt and token auth
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [termsonic](https://git.sixfoisneuf.fr/termsonic/), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
## installation
@@ -71,6 +71,8 @@ password can then be changed from the web interface
| `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+)
@@ -83,10 +85,12 @@ the available modes are:
| value | desc |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), or [betanin](https://github.com/sentriz/betanin/) can set set these |
| `multi` | gonic will explictly look for multi value fields in your audio metadata such as "genres" or "album_artists". software like [musicbrainz picard](https://picard.musicbrainz.org/), [beets](https://beets.io/) (v1.6.1+ / master), [wrtag](https://github.com/sentriz/wrtag/), or [betanin](https://github.com/sentriz/betanin/) can set set these |
| `delim <delim>` | gonic will look at your normal audio metadata fields like "genre" or "album_artist", but split them on a delimiter. for example you could set `-multi-value-genre "delim ;"` to split the single genre field on ";". note this mode is not recommended unless you use an uncommon delimiter such as ";" or "\|". using a delimiter like "&" will likely lead to many [false positives](https://musicbrainz.org/artist/ccd4879c-5e88-4385-b131-bf65296bf245) |
| `none` (default) | gonic will not attempt to do any multi value processing |
note: `,` is a special character in the environment variable parser. if you wish to use `,` for example for splitting genres, the `,` must be escaped with `\`. for example `"delim \,"`.
## screenshots
| | | | | |
-56
View File
@@ -1,56 +0,0 @@
# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=taglib2
pkgver=2.0.1
pkgrel=0
pkgdesc="Library for reading and editing metadata of several popular audio formats"
url="https://taglib.github.io/"
arch="all"
license="LGPL-2.1-only OR MPL-1.1"
makedepends="zlib-dev utfcpp cmake samurai"
checkdepends="cppunit-dev"
subpackages="
$pkgname-dev
libtag:_lib
libtag_c:_lib
"
source="https://taglib.github.io/releases/taglib-$pkgver.tar.gz"
builddir="$srcdir/taglib-$pkgver"
# secfixes:
# 1.11.1-r2:
# - CVE-2017-12678
# - CVE-2018-11439
build() {
CFLAGS="$CFLAGS -flto=auto" \
CXXFLAGS="$CXXFLAGS -flto=auto" \
cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DWITH_ZLIB=ON \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
-DVISIBILITY_HIDDEN=ON
CPLUS_INCLUDE_PATH="/usr/include/utf8cpp" \
cmake --build build
}
check() {
ctest --test-dir build --output-on-failure
}
package() {
DESTDIR="$pkgdir" cmake --install build
}
_lib() {
pkgdesc="$pkgdesc ($subpkgname lib)"
amove usr/lib/$subpkgname.so.*
}
sha512sums="
25ee89293a96d7f8dca6276f822bdaef01fd98503b78c20ffeac8e1d9821de7273a5127146aa798d304c6a995cb2b7229a205aff1cc261b5d4fa9e499dda0439 taglib-2.0.1.tar.gz
"
+19
View File
@@ -112,6 +112,9 @@ func main() {
deprecatedConfGenreSplit := flag.String("genre-split", "", "(deprecated, see multi-value settings)")
confTranscodeCacheSize := flag.Int("transcode-cache-size", 0, "size of the transcode cache in MB (0 = no limit) (optional)")
confTranscodeEjectInterval := flag.Int("transcode-eject-interval", 0, "interval (in minutes) to eject transcode cache (0 = never) (optional)")
flag.Parse()
flagconf.ParseEnv()
flagconf.ParseConfig(*confConfigPath)
@@ -220,6 +223,7 @@ func main() {
transcoder := transcode.NewCachingTranscoder(
transcode.NewFFmpegTranscoder(),
cacheDirAudio,
*confTranscodeCacheSize,
)
lastfmClientKeySecretFunc := func() (string, string, error) {
@@ -423,6 +427,21 @@ func main() {
return nil
})
errgrp.Go(func() error {
if *confTranscodeEjectInterval == 0 || *confTranscodeCacheSize == 0 {
return nil
}
defer logJob("transcode cache eject")()
ctxTick(ctx, time.Duration(*confTranscodeEjectInterval)*time.Minute, func() {
if err := transcoder.CacheEject(); err != nil {
log.Printf("error ejecting transcode cache: %v", err)
}
})
return nil
})
errgrp.Go(func() error {
if *confScanIntervalMins == 0 {
return nil
+4
View File
@@ -49,6 +49,10 @@ playlists-path <path to your m3u playlist dir>
# regenerated.
cache-path /var/cache/gonic
# Option to eject least recently used items from transcode cache.
#transcode-cache-size 5000 # in Mb (0 = no limit)
#transcode-eject-interval 1440 # in minutes (0 = never eject)
# Interval (in minutes) to check for new music. Default: don't scan
#scan-interval 0
#scan-at-start-enabled false
+10 -7
View File
@@ -67,7 +67,7 @@ func (db *DB) InsertBulkLeftMany(table string, head []string, left int, col []in
return nil
}
var rows []string
var values []interface{}
var values []any
for _, c := range col {
rows = append(rows, "(?, ?)")
values = append(values, left, c)
@@ -138,10 +138,7 @@ func (db *DB) TransactionChunked(data []int64, cb func(*DB, []int64) error) erro
const size = 999
return db.Transaction(func(tx *DB) error {
for i := 0; i < len(data); i += size {
end := i + size
if end > len(data) {
end = len(data)
}
end := min(i+size, len(data))
if err := cb(tx, data[i:end]); err != nil {
return err
}
@@ -235,6 +232,7 @@ type Track struct {
TagTrackNumber int `sql:"default: null"`
TagDiscNumber int `sql:"default: null"`
TagBrainzID string `sql:"default: null"`
TagLyrics string `sql:"default:null"`
ReplayGainTrackGain float32
ReplayGainTrackPeak float32
@@ -339,6 +337,8 @@ type Album struct {
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:"-"`
@@ -475,6 +475,7 @@ type Podcast struct {
Episodes []*PodcastEpisode
AutoDownload PodcastAutoDownload
RootDir string
Author string
}
func (p *Podcast) SID() *specid.ID {
@@ -508,6 +509,8 @@ type PodcastEpisode struct {
Status PodcastEpisodeStatus
Error string
Podcast *Podcast
Artist string
Album string
}
func (pe *PodcastEpisode) AudioLength() int { return pe.Length }
@@ -637,8 +640,8 @@ func Dump(ctx context.Context, db *gorm.DB, to string) error {
}
defer connDest.Close()
err = connDest.Raw(func(connDest interface{}) error {
return connSrc.Raw(func(connSrc interface{}) error {
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")
+48
View File
@@ -73,6 +73,14 @@ func (db *DB) Migrate(ctx MigrationContext) error {
construct(ctx, "202311082304", migrateTemporaryDisplayAlbumArtist),
construct(ctx, "202312110003", migrateAddExtraIndexes),
construct(ctx, "202405301140", migrateAddReplayGainFields),
construct(ctx, "202501152035", migrateTrackAddIndexOnAlbumID),
construct(ctx, "202501152036", migrateAlbumAddIndexOnParentID),
construct(ctx, "202502012036", migratePodcastEpisode),
construct(ctx, "202504132036", migratePodcast),
construct(ctx, "202505211202", migrateTrackAddIndexOnBrainzID),
construct(ctx, "202505262025", migrateAlbumAddIndexOnBrainzID),
construct(ctx, "202507062103", migrateAlbumCompilationReleaseType),
construct(ctx, "202508261102", migrateAddLyrics),
}
return gormigrate.
@@ -818,3 +826,43 @@ func migrateAddExtraIndexes(tx *gorm.DB, _ MigrationContext) error {
func migrateAddReplayGainFields(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
func migrateTrackAddIndexOnAlbumID(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_tracks_album_id ON "tracks" (album_id, length);
`).Error
}
func migrateAlbumAddIndexOnParentID(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_albums_parent_id ON "albums" (parent_id);
`).Error
}
func migratePodcastEpisode(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(
PodcastEpisode{},
).Error
}
func migrateTrackAddIndexOnBrainzID(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_tracks_brainz_id ON "tracks" (tag_brainz_id);
`).Error
}
func migrateAlbumAddIndexOnBrainzID(tx *gorm.DB, _ MigrationContext) error {
return tx.Exec(`
CREATE INDEX idx_albums_brainz_id ON "albums" (tag_brainz_id);
`).Error
}
func migrateAlbumCompilationReleaseType(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(
Album{},
).Error
}
func migrateAddLyrics(tx *gorm.DB, _ MigrationContext) error {
return tx.AutoMigrate(Track{}).Error
}
+1 -1
View File
@@ -2,7 +2,7 @@ package db
import "time"
type __OldPlaylist struct { //nolint: revive,stylecheck
type __OldPlaylist struct { //nolint: staticcheck
ID int `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
+23 -25
View File
@@ -1,71 +1,69 @@
module go.senan.xyz/gonic
go 1.21
go 1.25
require (
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/andybalholm/cascadia v1.3.2
github.com/dexterlb/mpvipc v0.0.0-20230829142118-145d6eabdc37
github.com/andybalholm/cascadia v1.3.3
github.com/dexterlb/mpvipc v0.0.0-20241005113212-7cdefca0e933
github.com/disintegration/imaging v1.6.2
github.com/djherbis/times v1.6.0
github.com/dustin/go-humanize v1.0.1
github.com/env25/mpdlrc v0.7.4
github.com/fatih/structs v1.1.0
github.com/fsnotify/fsnotify v1.7.0
github.com/fsnotify/fsnotify v1.9.0
github.com/go-ldap/ldap/v3 v3.4.6
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0
github.com/gorilla/securecookie v1.1.2
github.com/gorilla/sessions v1.3.0
github.com/gorilla/sessions v1.4.0
github.com/jinzhu/gorm v1.9.17-0.20211120011537-5c235b72a414
github.com/josephburnett/jd v1.8.1
github.com/mattn/go-sqlite3 v1.14.22
github.com/josephburnett/jd v1.9.2
github.com/mattn/go-sqlite3 v1.14.32
github.com/microcosm-cc/bluemonday v1.0.27
github.com/mitchellh/mapstructure v1.5.0
github.com/mmcdole/gofeed v1.3.0
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-20240713161505-a6bb82b19f54
github.com/sentriz/audiotags v0.0.0-20240918190302-048d6470aae6
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.11.1
go.senan.xyz/flagconf v0.1.9
golang.org/x/net v0.27.0
golang.org/x/sync v0.7.0
go.senan.xyz/wrtag v0.17.1
golang.org/x/net v0.43.0
golang.org/x/sync v0.16.0
gopkg.in/gormigrate.v1 v1.6.0
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056
)
require (
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/PuerkitoBio/goquery v1.9.2 // indirect
github.com/PuerkitoBio/goquery v1.10.3 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/jsonpointer v0.22.0 // indirect
github.com/go-openapi/swag/jsonname v0.24.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
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/olekukonko/tablewriter v0.0.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.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
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
+80 -55
View File
@@ -8,39 +8,43 @@ github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
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/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dexterlb/mpvipc v0.0.0-20230829142118-145d6eabdc37 h1:s+qNFsO3VsdsKroqapcogQxcQBHrRPDK1nVxGc+HBbg=
github.com/dexterlb/mpvipc v0.0.0-20230829142118-145d6eabdc37/go.mod h1:CXCwawNJCtFDip7gvbaQVgw0cGjldpyHDIp7oA5prOg=
github.com/dexterlb/mpvipc v0.0.0-20241005113212-7cdefca0e933 h1:r4hxcT6GBIA/j8Ox4OXI5MNgMKfR+9plcAWYi1OnmOg=
github.com/dexterlb/mpvipc v0.0.0-20241005113212-7cdefca0e933/go.mod h1:RkQWLNITKkXHLP7LXxZSgEq+uFWU25M5qW7qfEhL9Wc=
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/env25/mpdlrc v0.7.4 h1:A9If5JKVjgJldaIjJztqkXpUKXlsoRIwXqGK3qS38pY=
github.com/env25/mpdlrc v0.7.4/go.mod h1:Zyhq2WfcYeSJUCtx7mhbXwlh4Xt6mR7HDw0qQh7LvyY=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD50WnA=
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ=
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
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-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=
@@ -49,6 +53,7 @@ github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZ
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -60,12 +65,14 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/gorilla/sessions v1.3.0 h1:XYlkq7KcpOB2ZhHBPv5WpjMIxrQosiZanfoy1HLZFzg=
github.com/gorilla/sessions v1.3.0/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ=
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
@@ -82,10 +89,8 @@ github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI=
github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josephburnett/jd v1.8.1 h1:U4wae4kEvduCmf5mlXJ3uKnfHFmGhwttEFkQ6rsoDMk=
github.com/josephburnett/jd v1.8.1/go.mod h1:d9nEP87VBIx8SxhIVraVdEU/IwZ7JH6kHWjZMByRq2M=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5Y=
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -96,15 +101,12 @@ 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/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
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.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -122,47 +124,49 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
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/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4 h1:SvVjZyjXBOjqjCdMiC9ndyWb709aP5qU4Qbun40GCxA=
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4/go.mod h1:Mpa6Hci7lO3vybfdYlWXmH5gEq2vyOmYYjhrlwCTW3w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/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.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sentriz/audiotags v0.0.0-20240713161505-a6bb82b19f54 h1:JaJaWCUDLGUbU8AIO+YhQ+Nq4ByCCaApLuHi868uWQw=
github.com/sentriz/audiotags v0.0.0-20240713161505-a6bb82b19f54/go.mod h1:+pmkMFDEXJuu/u4h2OYJVfYF2qIhXJD7kqvWq6q5Zo0=
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/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/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.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.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.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/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=
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=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
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/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
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/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=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -172,14 +176,22 @@ golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
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/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=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
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/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=
@@ -189,13 +201,22 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
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/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=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
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/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=
@@ -203,14 +224,20 @@ 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=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
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/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.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
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/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=
@@ -225,5 +252,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056 h1:6YFJoB+0fUH6X3xU/G2tQqCYg+PkGtnZ5nMR5rpw72g=
jaytaylor.com/html2text v0.0.0-20230321000545-74c2419ad056/go.mod h1:OxvTsCwKosqQ1q7B+8FwXqg4rKZ/UG9dUW+g/VL2xH4=
+23 -5
View File
@@ -148,13 +148,31 @@ func (c *Client) UserGetLovedTracks(userName string) (LovedTracks, error) {
params.Add("method", "user.getLovedTracks")
params.Add("api_key", apiKey)
params.Add("user", userName)
params.Add("limit", "1000") // TODO: paginate
resp, err := c.makeRequest(http.MethodGet, params)
if err != nil {
return LovedTracks{}, fmt.Errorf("making user get loved tracks GET: %w", err)
var (
page = 1
limit = 1000
)
var loved LovedTracks
for {
params.Set("page", fmt.Sprint(page))
params.Set("limit", fmt.Sprint(limit))
resp, err := c.makeRequest(http.MethodGet, params)
if err != nil {
return LovedTracks{}, fmt.Errorf("making user get loved tracks GET: %w", err)
}
loved.Tracks = append(loved.Tracks, resp.LovedTracks.Tracks...)
if len(resp.LovedTracks.Tracks) < limit {
break
}
page++
}
return resp.LovedTracks, nil
return loved, nil
}
func (c *Client) GetSession(token string) (string, error) {
+8 -4
View File
@@ -116,12 +116,12 @@ func (m *MockFS) AddItemsWithCovers() { m.addItems("", "", tr
func (m *MockFS) AddItemsPrefixWithCovers(prefix string) { m.addItems(prefix, "", true) }
func (m *MockFS) addItems(prefix string, onlyGlob string, covers bool) {
p := func(format string, a ...interface{}) string {
p := func(format string, a ...any) string {
return filepath.Join(prefix, fmt.Sprintf(format, a...))
}
for ar := 0; ar < 3; ar++ {
for al := 0; al < 3; al++ {
for tr := 0; tr < 3; tr++ {
for ar := range 3 {
for al := range 3 {
for tr := range 3 {
path := p("artist-%d/album-%d/track-%d.flac", ar, al, tr)
if !match(onlyGlob, path) {
continue
@@ -362,6 +362,10 @@ 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 }
+4
View File
@@ -94,6 +94,10 @@ func (s *Store) Read(relPath string) (*Playlist, error) {
return nil, fmt.Errorf("stat m3u: %w", err)
}
if stat.IsDir() {
return nil, errors.New("path is a directory")
}
var playlist Playlist
playlist.UpdatedAt = stat.ModTime()
+45 -13
View File
@@ -1,6 +1,7 @@
package podcast
import (
"cmp"
"errors"
"fmt"
"io"
@@ -82,10 +83,14 @@ func (p *Podcasts) AddNewPodcast(rssURL string, feed *gofeed.Feed) (*db.Podcast,
}
podcast := db.Podcast{
Description: feed.Description,
ImageURL: feed.Image.URL,
ImageURL: "",
Title: feed.Title,
URL: rssURL,
RootDir: rootDir,
Author: feed.ITunesExt.Author,
}
if feed.Image != nil {
podcast.ImageURL = feed.Image.URL
}
if err := os.Mkdir(podcast.RootDir, 0o755); err != nil && !os.IsExist(err) {
return nil, err
@@ -115,6 +120,26 @@ func (p *Podcasts) SetAutoDownload(podcastID int, setting db.PodcastAutoDownload
if err := p.db.Save(&podcast).Error; err != nil {
return fmt.Errorf("save setting: %w", err)
}
// download most recent
if setting == db.PodcastAutoDownloadLatest {
err := p.db.
Model(db.PodcastEpisode{}).
Where("status=?", db.PodcastEpisodeStatusSkipped).
Where("id=?", p.db.
Select("id").
Model(db.PodcastEpisode{}).
Where("podcast_id=?", podcast.ID).
Order("publish_date DESC").
Limit(1).
SubQuery(),
).
Update("status", db.PodcastEpisodeStatusDownloading).
Error
if err != nil {
return fmt.Errorf("update podcast most recent episode: %w", err)
}
}
return nil
}
@@ -146,7 +171,7 @@ func (p *Podcasts) RefreshPodcast(podcast *db.Podcast, items []*gofeed.Item) err
var episodeErrs []error
for _, item := range items {
podcastEpisode, err := p.addEpisode(podcast.ID, item)
podcastEpisode, err := p.addEpisode(podcast, item)
if err != nil {
episodeErrs = append(episodeErrs, err)
continue
@@ -163,7 +188,7 @@ func (p *Podcasts) RefreshPodcast(podcast *db.Podcast, items []*gofeed.Item) err
return errors.Join(episodeErrs...)
}
func (p *Podcasts) addEpisode(podcastID int, item *gofeed.Item) (*db.PodcastEpisode, error) {
func (p *Podcasts) addEpisode(podcast *db.Podcast, item *gofeed.Item) (*db.PodcastEpisode, error) {
var duration int
// if it has the media extension use it
for _, content := range item.Extensions["media"]["content"] {
@@ -177,14 +202,13 @@ func (p *Podcasts) addEpisode(podcastID int, item *gofeed.Item) (*db.PodcastEpis
if duration == 0 && item.ITunesExt != nil {
duration = getSecondsFromString(item.ITunesExt.Duration)
}
if episode, ok := p.findEnclosureAudio(podcastID, duration, item); ok {
if episode, ok := p.findEnclosureAudio(podcast, duration, item); ok {
if err := p.db.Save(episode).Error; err != nil {
return nil, err
}
return episode, nil
}
if episode, ok := p.findMediaAudio(podcastID, duration, item); ok {
if episode, ok := p.findMediaAudio(podcast, duration, item); ok {
if err := p.db.Save(episode).Error; err != nil {
return nil, err
}
@@ -201,9 +225,9 @@ func (p *Podcasts) isAudio(rawItemURL string) (bool, error) {
return p.tagReader.CanRead(itemURL.Path), nil
}
func itemToEpisode(podcastID, size, duration int, audio string, item *gofeed.Item) *db.PodcastEpisode {
func itemToEpisode(podcast *db.Podcast, size, duration int, audio string, item *gofeed.Item) *db.PodcastEpisode {
return &db.PodcastEpisode{
PodcastID: podcastID,
PodcastID: podcast.ID,
Description: item.Description,
Title: item.Title,
Length: duration,
@@ -211,21 +235,23 @@ func itemToEpisode(podcastID, size, duration int, audio string, item *gofeed.Ite
PublishDate: item.PublishedParsed,
AudioURL: audio,
Status: db.PodcastEpisodeStatusSkipped,
Artist: cmp.Or(item.ITunesExt.Author, podcast.Author),
Album: podcast.Title,
}
}
func (p *Podcasts) findEnclosureAudio(podcastID, duration int, item *gofeed.Item) (*db.PodcastEpisode, bool) {
func (p *Podcasts) findEnclosureAudio(podcast *db.Podcast, duration int, item *gofeed.Item) (*db.PodcastEpisode, bool) {
for _, enc := range item.Enclosures {
if t, err := p.isAudio(enc.URL); !t || err != nil {
continue
}
size, _ := strconv.Atoi(enc.Length)
return itemToEpisode(podcastID, size, duration, enc.URL, item), true
return itemToEpisode(podcast, size, duration, enc.URL, item), true
}
return nil, false
}
func (p *Podcasts) findMediaAudio(podcastID, duration int, item *gofeed.Item) (*db.PodcastEpisode, bool) {
func (p *Podcasts) findMediaAudio(podcast *db.Podcast, duration int, item *gofeed.Item) (*db.PodcastEpisode, bool) {
extensions, ok := item.Extensions["media"]["content"]
if !ok {
return nil, false
@@ -234,7 +260,7 @@ func (p *Podcasts) findMediaAudio(podcastID, duration int, item *gofeed.Item) (*
if t, err := p.isAudio(ext.Attrs["url"]); !t || err != nil {
continue
}
return itemToEpisode(podcastID, 0, duration, ext.Attrs["url"], item), true
return itemToEpisode(podcast, 0, duration, ext.Attrs["url"], item), true
}
return nil, false
}
@@ -316,6 +342,10 @@ func getPodcastEpisodeFilename(podcast *db.Podcast, podcastEpisode *db.PodcastEp
}
func (p *Podcasts) downloadPodcastCover(podcast *db.Podcast) error {
if podcast.ImageURL == "" {
return nil
}
imageURL, err := url.Parse(podcast.ImageURL)
if err != nil {
return fmt.Errorf("parse image url: %w", err)
@@ -455,11 +485,13 @@ func (p *Podcasts) DownloadTick() error {
return nil
}
log.Printf("starting podcast episode download %q - %q", podcastEpisode.Podcast.Title, podcastEpisode.Title)
if err := p.doPodcastDownload(podcastEpisode.Podcast, &podcastEpisode); err != nil {
return fmt.Errorf("do download: %w", err)
}
log.Printf("downloaded podcast episode %q - %q", podcastEpisode.Podcast.Title, podcastEpisode.Title)
log.Printf("downloaded podcast episode")
return nil
}
+47 -26
View File
@@ -24,7 +24,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/wrtag/coverparse"
)
var (
@@ -105,6 +107,9 @@ func (s *Scanner) ScanAndClean(opts ScanOptions) (*State, error) {
if err := s.cleanGenres(st); err != nil {
return nil, fmt.Errorf("clean genres: %w", err)
}
if err := s.cleanBookmarks(st); err != nil {
return nil, fmt.Errorf("clean bookmarks: %w", err)
}
if err := s.db.SetSetting(db.LastScanTime, strconv.FormatInt(time.Now().Unix(), 10)); err != nil {
return nil, fmt.Errorf("set scan time: %w", err)
@@ -277,8 +282,8 @@ func (s *Scanner) scanDir(tx *db.DB, st *State, absPath string) error {
continue
}
if isCover(item.Name()) {
cover = item.Name()
if coverparse.IsCover(item.Name()) {
cover = coverparse.BestBetween(cover, item.Name())
continue
}
if s.tagReader.CanRead(absPath) {
@@ -419,6 +424,8 @@ func populateAlbum(tx *db.DB, album *db.Album, trags tagcommon.Info, modTime, cr
album.TagAlbumArtist = tagcommon.MustAlbumArtist(trags)
album.TagBrainzID = trags.AlbumBrainzID()
album.TagYear = trags.Year()
album.TagCompilation = trags.Compilation()
album.TagReleaseType = trags.ReleaseType()
album.ModifiedAt = modTime
if album.CreatedAt.After(createTime) {
@@ -461,6 +468,7 @@ func populateTrack(tx *db.DB, album *db.Album, track *db.Track, trags tagcommon.
track.FilenameUDec = decoded(basename)
track.Size = size
track.AlbumID = album.ID
track.TagLyrics = trags.Lyrics()
track.TagTitle = trags.Title()
track.TagTitleUDec = decoded(trags.Title())
@@ -671,24 +679,35 @@ func (s *Scanner) cleanGenres(st *State) error { //nolint:unparam
return nil
}
//nolint:gochecknoglobals
var coverNames = map[string]struct{}{}
func (s *Scanner) cleanBookmarks(st *State) error {
start := time.Now()
defer func() {
log.Printf("finished clean bookmarks in %s, %d removed", durSince(start), st.BookmarksRemoved())
}()
//nolint:gochecknoinits
func init() {
for _, name := range []string{"cover", "folder", "front", "albumart", "album", "artist"} {
for _, ext := range []string{"jpg", "jpeg", "png", "bmp", "gif"} {
coverNames[fmt.Sprintf("%s.%s", name, ext)] = struct{}{}
for i := 0; i < 3; i++ {
coverNames[fmt.Sprintf("%s.%d.%s", name, i, ext)] = struct{}{} // support beets extras
}
}
}
}
trackBookmarks := s.db.
Select("bookmarks.id").
Model(db.Bookmark{}).
Joins("LEFT JOIN tracks ON tracks.id=bookmarks.entry_id").
Where("tracks.id IS NULL AND bookmarks.entry_id_type=?", specid.Track).
SubQuery()
q := s.db.
Where("bookmarks.id IN ?", trackBookmarks).
Delete(db.Bookmark{})
st.bookmarksRemoved += int(q.RowsAffected)
func isCover(name string) bool {
_, ok := coverNames[strings.ToLower(name)]
return ok
podcastBookmarks := s.db.
Select("bookmarks.id").
Model(db.Bookmark{}).
Joins("LEFT JOIN podcast_episodes ON podcast_episodes.id=bookmarks.entry_id").
Where("podcast_episodes.id IS NULL AND bookmarks.entry_id_type=?", specid.PodcastEpisode).
SubQuery()
q = s.db.
Where("bookmarks.id IN ?", podcastBookmarks).
Delete(db.Bookmark{})
st.bookmarksRemoved += int(q.RowsAffected)
return nil
}
// decoded converts a string to it's latin equivalent.
@@ -713,20 +732,22 @@ type State struct {
seenAlbums map[int]struct{}
seenTracksNew int
tracksMissing []int64
albumsMissing []int64
artistsMissing int
genresMissing int
tracksMissing []int64
albumsMissing []int64
artistsMissing int
genresMissing int
bookmarksRemoved int
}
func (s *State) SeenTracks() int { return len(s.seenTracks) }
func (s *State) SeenAlbums() int { return len(s.seenAlbums) }
func (s *State) SeenTracksNew() int { return s.seenTracksNew }
func (s *State) TracksMissing() int { return len(s.tracksMissing) }
func (s *State) AlbumsMissing() int { return len(s.albumsMissing) }
func (s *State) ArtistsMissing() int { return s.artistsMissing }
func (s *State) GenresMissing() int { return s.genresMissing }
func (s *State) TracksMissing() int { return len(s.tracksMissing) }
func (s *State) AlbumsMissing() int { return len(s.albumsMissing) }
func (s *State) ArtistsMissing() int { return s.artistsMissing }
func (s *State) GenresMissing() int { return s.genresMissing }
func (s *State) BookmarksRemoved() int { return s.bookmarksRemoved }
type MultiValueMode uint8
+4 -5
View File
@@ -9,21 +9,20 @@ import (
func BenchmarkScanIncremental(b *testing.B) {
m := mockfs.New(b)
for i := 0; i < 5; i++ {
for i := range 5 {
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
}
m.ScanAndClean()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
m.ScanAndClean()
}
}
func BenchmarkScanFull(b *testing.B) {
for i := 0; i < b.N; i++ {
for b.Loop() {
m := mockfs.New(b)
for i := 0; i < 5; i++ {
for i := range 5 {
m.AddItemsPrefix(fmt.Sprintf("t-%d", i))
}
b.StartTimer()
+1 -1
View File
@@ -43,7 +43,7 @@ func FuzzScanner(f *testing.F) {
})
}
func fuzzStruct(taken int, data []byte, seed int64, dest interface{}) {
func fuzzStruct(taken int, data []byte, seed int64, dest any) {
if len(data) == 0 {
return
}
+3 -3
View File
@@ -363,7 +363,7 @@ func TestNewAlbumForExistingArtist(t *testing.T) {
assert.NoError(t, m.DB().Where("name=?", "artist-2").Find(&artist).Error) // find orig artist
assert.Greater(t, artist.ID, 0)
for tr := 0; tr < 3; tr++ {
for tr := range 3 {
m.AddTrack(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr))
m.SetTags(fmt.Sprintf("artist-2/new-album/track-%d.mp3", tr), func(tags *mockfs.TagInfo) {
tags.RawArtist = "artist-2"
@@ -552,7 +552,7 @@ func TestCompilationAlbumWithoutAlbumArtist(t *testing.T) {
const toAdd = 5
// add tracks to one folder with random artists and no album artist tag
for i := 0; i < toAdd; i++ {
for i := range toAdd {
p := fmt.Sprintf("%s/%s/track-%d.flac", pathArtist, pathAlbum, i)
m.AddTrack(p)
m.SetTags(p, func(tags *mockfs.TagInfo) {
@@ -605,7 +605,7 @@ func TestAlbumAndArtistSameNameWeirdness(t *testing.T) {
const name = "same"
add := func(path string, a ...interface{}) {
add := func(path string, a ...any) {
m.AddTrack(fmt.Sprintf(path, a...))
m.SetTags(fmt.Sprintf(path, a...), func(tags *mockfs.TagInfo) {})
}
+18
View File
@@ -39,6 +39,24 @@
<head>
<meta charset="utf-8">
<title>gonic</title>
<style>
@font-face {
font-family: "Inconsolata";
font-style: normal;
font-weight: 500;
src: local(""),
url("{{ path "/admin/static/inconsolata-v31-latin-500.woff2" }}") format("woff2"),
url("{{ path "/admin/static/inconsolata-v31-latin-500.woff" }}") format("woff");
}
@font-face {
font-family: "Inconsolata";
font-style: normal;
font-weight: 600;
src: local(""),
url("{{ path "/admin/static/inconsolata-v31-latin-600.woff2" }}") format("woff2"),
url("{{ path "/admin/static/inconsolata-v31-latin-600.woff" }}") format("woff");
}
</style>
<link rel="stylesheet" href="{{ path "/admin/static/style.css" | noCache }}">
<link rel="shortcut icon" href="{{ path "/admin/static/favicon.ico" }}" type="image/x-icon">
<link rel="icon" href="{{ path "/admin/static/favicon.ico" }}" type="image/x-icon">
File diff suppressed because one or more lines are too long
-18
View File
@@ -12,24 +12,6 @@ a {
text-decoration: none;
}
@font-face {
font-family: "Inconsolata";
font-style: normal;
font-weight: 500;
src: local(""),
url("/admin/static/inconsolata-v31-latin-500.woff2") format("woff2"),
url("/admin/static/inconsolata-v31-latin-500.woff") format("woff");
}
@font-face {
font-family: "Inconsolata";
font-style: normal;
font-weight: 600;
src: local(""),
url("/admin/static/inconsolata-v31-latin-600.woff2") format("woff2"),
url("/admin/static/inconsolata-v31-latin-600.woff") format("woff");
}
@tailwind components;
@tailwind utilities;
+1 -1
View File
@@ -274,7 +274,7 @@ func respRaw(h http.HandlerFunc) http.Handler {
type templateData struct {
// common
Flashes []interface{}
Flashes []any
User *db.User
Version string
+1
View File
@@ -128,6 +128,7 @@ func New(dbc *db.DB, scannr *scanner.Scanner, musicPaths []MusicPath, podcastsPa
c.Handle("/getSimilarSongs", chain(resp(c.ServeGetSimilarSongs)))
c.Handle("/getSimilarSongs2", chain(resp(c.ServeGetSimilarSongsTwo)))
c.Handle("/getLyrics", chain(resp(c.ServeGetLyrics)))
c.Handle("/getLyricsBySongId", chain(resp(c.ServeGetLyricsBySongID)))
// raw
c.Handle("/getCoverArt", chainRaw(respRaw(c.ServeGetCoverArt)))
+2 -3
View File
@@ -39,8 +39,8 @@ const (
)
const (
audioPath5s = "testdata/audio/5s.flac" //nolint:deadcode,varcheck
audioPath10s = "testdata/audio/10s.flac" //nolint:deadcode,varcheck
audioPath5s = "testdata/audio/5s.flac"
audioPath10s = "testdata/audio/10s.flac"
)
type queryCase struct {
@@ -87,7 +87,6 @@ func makeHTTPMockWithAdmin(query url.Values) (*httptest.ResponseRecorder, *http.
func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) {
t.Helper()
for _, qc := range cases {
qc := qc
t.Run(qc.expectPath, func(t *testing.T) {
t.Helper()
t.Parallel()
+19 -1
View File
@@ -45,9 +45,27 @@ func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response {
Find(&track, "id=?", bookmark.EntryID).
Error
if err != nil {
return spec.NewError(10, "finding entry: %v", err)
/*
* We get here if we have a bookmark for a Track that no longer exists, this should be an
* error because tracks can disappear if the files are moved etc. Just skip the not found
* entry and move on.
*/
continue
}
respBookmark.Entry = spec.NewTrackByTags(&track, track.Album)
case specid.PodcastEpisode:
var podcastEpisode db.PodcastEpisode
err := c.dbc.
Preload("Podcast").
Find(&podcastEpisode, "id=?", bookmark.EntryID).
Error
if err != nil {
/* Same as with the missing track above. */
continue
}
respBookmark.Entry = spec.NewTCPodcastEpisode(&podcastEpisode)
default:
continue
}
sub.Bookmarks.List = append(sub.Bookmarks.List, respBookmark)
+30 -11
View File
@@ -1,10 +1,10 @@
package ctrlsubsonic
import (
"fmt"
"net/http"
"strings"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
"go.senan.xyz/gonic/db"
@@ -80,11 +80,13 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
Where("parent_id=?", id.Value).
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Order("tag_year").
Order("albums.right_path COLLATE NOCASE").
Find(&childFolders)
for _, ch := range childFolders {
childrenObj = append(childrenObj, spec.NewTCAlbumByFolder(ch))
}
// start looking for child childTracks in the current dir
var childTracks []*db.Track
c.dbc.
@@ -94,6 +96,7 @@ func (c *Controller) ServeGetMusicDirectory(r *http.Request) *spec.Response {
Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Order("tracks.tag_disc_number, tracks.tag_track_number").
Order("filename").
Find(&childTracks)
@@ -198,13 +201,17 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
user := r.Context().Value(CtxUser).(*db.User)
query, err := params.Get("query")
var queries []string
if err != nil {
return spec.NewError(10, "please provide a `query` parameter")
}
for _, s := range strings.Fields(query) {
queries = append(queries, fmt.Sprintf("%%%s%%", strings.Trim(s, `*"'`)))
}
var isUUID = uuid.Validate(query) == nil
var isAll = query == `""`
var fuzzy = query
fuzzy = strings.Join(strings.Fields(fuzzy), "%")
fuzzy = strings.ToLower(fuzzy)
fuzzy = "%" + fuzzy + "%"
results := &spec.SearchResultTwo{}
@@ -219,8 +226,12 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
var artists []*db.Album
q := c.dbc.Where(`parent_id IN ?`, rootQ.SubQuery())
for _, s := range queries {
q = q.Where(`right_path LIKE ? OR right_path_u_dec LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(0)
case isAll:
default:
q = q.Where(`right_path LIKE ? OR right_path_u_dec LIKE ?`, fuzzy, fuzzy)
}
q = q.
Preload("AlbumStar", "user_id=?", user.ID).
@@ -238,8 +249,12 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
var albums []*db.Album
q = c.dbc.
Joins("JOIN album_artists ON album_artists.album_id=albums.id")
for _, s := range queries {
q = q.Where(`right_path LIKE ? OR right_path_u_dec LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(`tag_brainz_id = ?`, query)
case isAll:
default:
q = q.Where(`right_path LIKE ? OR right_path_u_dec LIKE ?`, fuzzy, fuzzy)
}
q = q.
Preload("AlbumStar", "user_id=?", user.ID).
@@ -259,8 +274,12 @@ func (c *Controller) ServeSearchTwo(r *http.Request) *spec.Response {
// search tracks
var tracks []*db.Track
q = c.dbc.Preload("Album")
for _, s := range queries {
q = q.Where(`filename LIKE ? OR filename LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(`tag_brainz_id = ?`, query)
case isAll:
default:
q = q.Where(`filename LIKE ?`, fuzzy)
}
q = q.
Preload("Artists").
+27 -12
View File
@@ -2,7 +2,6 @@ package ctrlsubsonic
import (
"errors"
"fmt"
"log"
"math"
"net/http"
@@ -217,13 +216,17 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
user := r.Context().Value(CtxUser).(*db.User)
query, err := params.Get("query")
var queries []string
if err != nil {
return spec.NewError(10, "please provide a `query` parameter")
}
for _, s := range strings.Fields(query) {
queries = append(queries, fmt.Sprintf("%%%s%%", strings.Trim(s, `*"'`)))
}
var isUUID = uuid.Validate(query) == nil
var isAll = query == `""`
var fuzzy = query
fuzzy = strings.Join(strings.Fields(fuzzy), "%")
fuzzy = strings.ToLower(fuzzy)
fuzzy = "%" + fuzzy + "%"
results := &spec.SearchResultThree{}
@@ -232,8 +235,12 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
q := c.dbc.
Select("*, count(albums.id) album_count").
Group("artists.id")
for _, s := range queries {
q = q.Where(`name LIKE ? OR name_u_dec LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(0)
case isAll:
default:
q = q.Where(`name LIKE ? OR name_u_dec LIKE ?`, fuzzy, fuzzy)
}
q = q.
Joins("JOIN album_artists ON album_artists.artist_id=artists.id").
@@ -261,8 +268,12 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("AlbumStar", "user_id=?", user.ID).
Preload("AlbumRating", "user_id=?", user.ID).
Preload("Play", "user_id=?", user.ID)
for _, s := range queries {
q = q.Where(`tag_title LIKE ? OR tag_title_u_dec LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(`tag_brainz_id = ?`, query)
case isAll:
default:
q = q.Where(`tag_title LIKE ? OR tag_title_u_dec LIKE ?`, fuzzy, fuzzy)
}
q = q.
Offset(params.GetOrInt("albumOffset", 0)).
@@ -286,8 +297,12 @@ func (c *Controller) ServeSearchThree(r *http.Request) *spec.Response {
Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID)
for _, s := range queries {
q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ?`, s, s)
switch {
case isUUID:
q = q.Where(`tracks.tag_brainz_id = ?`, query)
case isAll:
default:
q = q.Where(`tracks.tag_title LIKE ? OR tracks.tag_title_u_dec LIKE ?`, fuzzy, fuzzy)
}
q = q.Offset(params.GetOrInt("songOffset", 0)).
Limit(params.GetOrInt("songCount", 20))
@@ -418,7 +433,7 @@ func (c *Controller) ServeGetAlbumInfoTwo(r *http.Request) *spec.Response {
sub.AlbumInfo.MusicBrainzID = info.MusicBrainzID
sub.AlbumInfo.LastFMURL = info.LastFMURL
if _, err := uuid.Parse(album.TagBrainzID); err == nil {
if err := uuid.Validate(album.TagBrainzID); err == nil {
sub.AlbumInfo.MusicBrainzID = album.TagBrainzID // prefer db musicbrainz ID over lastfm's
}
+186 -21
View File
@@ -8,10 +8,12 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"sync"
"time"
"unicode"
"github.com/env25/mpdlrc/lrc"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
@@ -41,6 +43,7 @@ func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Respo
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{
{Name: "transcodeOffset", Versions: []int{1}},
{Name: "formPost", Versions: []int{1}},
{Name: "songLyrics", Versions: []int{1}},
}
return sub
}
@@ -75,10 +78,10 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
scrobbleTrack.AlbumArtist = track.Album.TagAlbumArtist
scrobbleTrack.TrackNumber = uint(track.TagTrackNumber)
scrobbleTrack.Duration = time.Second * time.Duration(track.Length)
if _, err := uuid.Parse(track.TagBrainzID); err == nil {
if err := uuid.Validate(track.TagBrainzID); err == nil {
scrobbleTrack.MusicBrainzID = track.TagBrainzID
}
if _, err := uuid.Parse(track.Album.TagBrainzID); err == nil {
if err := uuid.Validate(track.Album.TagBrainzID); err == nil {
scrobbleTrack.MusicBrainzReleaseID = track.Album.TagBrainzID
}
@@ -206,30 +209,44 @@ func (c *Controller) ServeGetPlayQueue(r *http.Request) *spec.Response {
sub.PlayQueue.ChangedBy = queue.ChangedBy
trackIDs := queue.GetItems()
sub.PlayQueue.List = make([]*spec.TrackChild, len(trackIDs))
sub.PlayQueue.List = make([]*spec.TrackChild, 0, len(trackIDs))
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))
for i, id := range trackIDs {
for _, id := range trackIDs {
switch id.Type {
case specid.Track:
track := db.Track{}
c.dbc.
var track db.Track
err := c.dbc.
Where("id=?", id.Value).
Preload("Album").
Preload("Artists").
Preload("TrackStar", "user_id=?", user.ID).
Preload("TrackRating", "user_id=?", user.ID).
Find(&track)
sub.PlayQueue.List[i] = spec.NewTCTrackByFolder(&track, track.Album)
sub.PlayQueue.List[i].TranscodeMeta = transcodeMeta
Find(&track).
Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(0, "error finding track")
}
if track.ID != 0 {
tc := spec.NewTCTrackByFolder(&track, track.Album)
tc.TranscodeMeta = transcodeMeta
sub.PlayQueue.List = append(sub.PlayQueue.List, tc)
}
case specid.PodcastEpisode:
pe := db.PodcastEpisode{}
c.dbc.
var pe db.PodcastEpisode
err := c.dbc.
Where("id=?", id.Value).
Find(&pe)
sub.PlayQueue.List[i] = spec.NewTCPodcastEpisode(&pe)
sub.PlayQueue.List[i].TranscodeMeta = transcodeMeta
Find(&pe).
Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(0, "error finding podcast episode")
}
if pe.ID != 0 {
tc := spec.NewTCPodcastEpisode(&pe)
tc.TranscodeMeta = transcodeMeta
sub.PlayQueue.List = append(sub.PlayQueue.List, tc)
}
}
}
return sub
@@ -335,7 +352,7 @@ func (c *Controller) ServeGetRandomSongs(r *http.Request) *spec.Response {
return sub
}
var errNotATrack = errors.New("not a track")
var errUnknownPlaylistEntry = errors.New("unknown playlist entry")
func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:gocyclo
if c.jukebox == nil {
@@ -377,11 +394,16 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
if err != nil {
return nil, fmt.Errorf("fetch track: %w", err)
}
track, ok := file.(*db.Track)
if !ok {
return nil, fmt.Errorf("%q: %w", path, errNotATrack)
switch f := file.(type) {
case *db.Track:
ret = append(ret, spec.NewTrackByTags(f, f.Album))
case *db.InternetRadioStation:
ret = append(ret, spec.NewTCInternetRadioStation(f))
case *db.PodcastEpisode:
ret = append(ret, spec.NewTCPodcastEpisode(f))
default:
return nil, fmt.Errorf("%q: %w", path, errUnknownPlaylistEntry)
}
ret = append(ret, spec.NewTrackByTags(track, track.Album))
}
return ret, nil
}
@@ -468,12 +490,155 @@ func (c *Controller) ServeJukebox(r *http.Request) *spec.Response { // nolint:go
return sub
}
func (c *Controller) ServeGetLyrics(_ *http.Request) *spec.Response {
func (c *Controller) ServeGetLyrics(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
artist, _ := params.Get("artist")
title, _ := params.Get("title")
var track db.Track
err := c.dbc.
Preload("Album").
Joins("JOIN track_artists ON track_artists.track_id = tracks.id").
Joins("JOIN artists ON artists.id = track_artists.artist_id").
Where("tracks.tag_title LIKE ? AND artists.name LIKE ?", title, artist).
First(&track).
Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "couldn't find a track with that id")
}
if err != nil {
return spec.NewError(0, "lyrics: %v", err)
}
sub := spec.NewResponse()
sub.Lyrics = &spec.Lyrics{}
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,
}
return sub
}
func (c *Controller) ServeGetLyricsBySongID(r *http.Request) *spec.Response {
params := r.Context().Value(CtxParams).(params.Params)
id, err := params.GetID("id")
if err != nil {
return spec.NewError(10, "provide an `id` parameter")
}
var track db.Track
q := c.dbc.
Preload("Album").
Preload("Album.Artists").
Preload("Artists").
Where("id=?", id.Value).
First(&track)
if err := q.Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(70, "couldn't find a track with that id")
} else {
return spec.NewError(0, "lyrics: %v", err)
}
}
sub := spec.NewResponse()
if track.TagLyrics != "" {
times, lrc, err := lrc.ParseString(track.TagLyrics)
if err != nil {
return spec.NewError(0, "lyricsFile: %v", err)
}
lines := make([]spec.Lyric, len(times))
for i, time := range times {
lines[i] = spec.Lyric{
Start: time.Milliseconds(),
Value: strings.TrimSpace(lrc[i]),
}
}
structured := 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
}
times, lrc, err := lyricsFile(track)
if err != nil {
if os.IsNotExist(err) {
sub.LyricsList = &spec.LyricsList{
StructuredLyrics: []spec.StructuredLyrics{},
}
return sub
}
return spec.NewError(0, "lyricsFile: %v", err)
}
lines := make([]spec.Lyric, len(times))
for i, time := range times {
lines[i] = spec.Lyric{
Start: time.Milliseconds(),
Value: strings.TrimSpace(lrc[i]),
}
}
structured := 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
}
func lyricsFile(file db.Track) ([]lrc.Duration, []lrc.Text, error) {
filePath := file.AbsPath()
fileDir := filepath.Dir(filePath)
fileName := strings.TrimSuffix(filepath.Base(filePath), filepath.Ext(filePath))
lrcContent, err := os.ReadFile(filepath.Join(fileDir, fileName+".lrc"))
if err != nil {
return []lrc.Duration{}, []lrc.Text{}, err
}
return lrc.Parse(lrcContent)
}
func scrobbleStatsUpdateTrack(dbc *db.DB, track *db.Track, userID int, playTime time.Time) error {
var play db.Play
if err := dbc.Where("album_id=? AND user_id=?", track.AlbumID, userID).First(&play).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
+4 -2
View File
@@ -75,8 +75,10 @@ func (c *Controller) ServeCreateOrUpdatePlaylist(r *http.Request) *spec.Response
playlistPath := playlistIDDecode(playlistID)
var playlist playlistp.Playlist
if pl, _ := c.playlistStore.Read(playlistPath); pl != nil {
playlist = *pl
if playlistPath != "" {
if pl, err := c.playlistStore.Read(playlistPath); err != nil && pl != nil {
playlist = *pl
}
}
if playlist.UserID != 0 && playlist.UserID != user.ID {
+6 -8
View File
@@ -155,11 +155,9 @@ func coverScaleAndSave(reader io.Reader, cachePath string, size int) error {
if err != nil {
return fmt.Errorf("resizing: %w", err)
}
width := size
if width > src.Bounds().Dx() {
width := min(size,
// don't upscale images
width = src.Bounds().Dx()
}
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)
}
@@ -194,7 +192,7 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
}
client, _ := params.Get("c")
pref, err := streamGetTransodePreference(c.dbc, user.ID, client)
pref, err := streamGetTranscodePreference(c.dbc, user.ID, client)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return spec.NewError(0, "couldn't find transcode preference: %v", err)
}
@@ -224,7 +222,7 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
profile = transcode.WithSeek(profile, time.Second*time.Duration(timeOffset))
}
log.Printf("trancoding to %q with at bitrate %d", profile.MIME(), profile.BitRate())
log.Printf("transcoding to %q with at bitrate %d", profile.MIME(), profile.BitRate())
w.Header().Set("Content-Type", profile.MIME())
if err := c.transcoder.Transcode(r.Context(), profile, file.AbsPath(), w); err != nil && !errors.Is(err, transcode.ErrFFmpegKilled) {
@@ -252,7 +250,7 @@ func (c *Controller) ServeGetAvatar(w http.ResponseWriter, r *http.Request) *spe
return nil
}
func streamGetTransodePreference(dbc *db.DB, userID int, client string) (*db.TranscodePreference, error) {
func streamGetTranscodePreference(dbc *db.DB, userID int, client string) (*db.TranscodePreference, error) {
var pref db.TranscodePreference
err := dbc.
Where("user_id=?", userID).
@@ -270,7 +268,7 @@ func streamGetTransodePreference(dbc *db.DB, userID int, client string) (*db.Tra
}
func streamGetTranscodeMeta(dbc *db.DB, userID int, client string) spec.TranscodeMeta {
pref, _ := streamGetTransodePreference(dbc, userID, client)
pref, _ := streamGetTranscodePreference(dbc, userID, client)
if pref == nil {
return spec.TranscodeMeta{}
}
+3 -4
View File
@@ -27,6 +27,7 @@ package params
import (
"errors"
"maps"
"net/http"
"net/url"
"strconv"
@@ -44,9 +45,7 @@ func New(r *http.Request) Params {
params := r.URL.Query()
// also if there's any in the post body, use those too
if err := r.ParseForm(); err == nil {
for k, v := range r.Form {
params[k] = v
}
maps.Copy(params, r.Form)
}
return Params(params)
}
@@ -389,7 +388,7 @@ func parseTime(in string) (time.Time, error) {
return time.Unix(0, ns), nil
}
func parse(values []string, i interface{}) error {
func parse(values []string, i any) error {
if len(values) == 0 {
return ErrNoValues
}
@@ -1,6 +1,7 @@
package spec
import (
"cmp"
"path/filepath"
"go.senan.xyz/gonic/db"
@@ -19,6 +20,7 @@ func NewAlbumByFolder(f *db.Album) *Album {
Duration: f.Duration,
Created: f.CreatedAt,
AverageRating: formatRating(f.AverageRating),
ReleaseTypes: []string{},
}
if f.AlbumStar != nil {
a.Starred = &f.AlbumStar.StarDate
@@ -40,6 +42,7 @@ func NewTCAlbumByFolder(f *db.Album) *TrackChild {
ParentID: f.ParentSID(),
CreatedAt: f.CreatedAt,
AverageRating: formatRating(f.AverageRating),
Year: f.TagYear,
}
if f.AlbumStar != nil {
trCh.Starred = &f.AlbumStar.StarDate
@@ -60,7 +63,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
Suffix: formatExt(t.Ext()),
Size: t.Size,
Artist: t.TagTrackArtist,
Title: t.TagTitle,
Title: cmp.Or(t.TagTitle, t.Filename),
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
Path: filepath.Join(
@@ -86,6 +89,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
}
if t.Album != nil {
trCh.Album = t.Album.RightPath
trCh.AlbumID = t.Album.SID()
}
if t.TrackStar != nil {
trCh.Starred = &t.TrackStar.StarDate
@@ -100,6 +104,9 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild {
trCh.Genres = append(trCh.Genres, &GenreRef{Name: g.Name})
}
for _, a := range t.Artists {
if a.Name == t.TagTrackArtist {
trCh.ArtistID = a.SID()
}
trCh.Artists = append(trCh.Artists, &ArtistRef{ID: a.SID(), Name: a.Name})
}
if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 {
@@ -126,6 +133,9 @@ func NewTCPodcastEpisode(pe *db.PodcastEpisode) *TrackChild {
IsDir: false,
Type: "podcastepisode",
CreatedAt: pe.CreatedAt,
Album: pe.Album,
Artist: pe.Artist,
CoverID: pe.SID(),
}
if pe.Podcast != nil {
trCh.ParentID = pe.Podcast.SID()
@@ -135,7 +145,7 @@ func NewTCPodcastEpisode(pe *db.PodcastEpisode) *TrackChild {
}
func NewArtistByFolder(f *db.Album) *Artist {
// the db is structued around "browse by tags", and where
// the db is structured around "browse by tags", and where
// an album is also a folder. so we're constructing an artist
// from an "album" where
// maybe TODO: rename the Album model to Folder
@@ -1,6 +1,7 @@
package spec
import (
"cmp"
"path/filepath"
"sort"
@@ -22,6 +23,8 @@ func NewAlbumByTags(a *db.Album, artists []*db.Artist) *Album {
Year: a.TagYear,
Tracks: []*TrackChild{},
AverageRating: formatRating(a.AverageRating),
IsCompilation: a.TagCompilation,
ReleaseTypes: formatReleaseTypes(a.TagReleaseType),
}
if a.Cover != "" {
ret.CoverID = a.SID()
@@ -76,7 +79,7 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild {
Path: filepath.Join(album.LeftPath, album.RightPath, t.Filename),
Size: t.Size,
Suffix: formatExt(t.Ext()),
Title: t.TagTitle,
Title: cmp.Or(t.TagTitle, t.Filename),
TrackNumber: t.TagTrackNumber,
DiscNumber: t.TagDiscNumber,
Type: "music",
@@ -10,3 +10,13 @@ func NewInternetRadioStation(irs *db.InternetRadioStation) *InternetRadioStation
HomepageURL: irs.HomepageURL,
}
}
func NewTCInternetRadioStation(irs *db.InternetRadioStation) *TrackChild {
return &TrackChild{
ID: irs.SID(),
Title: irs.Name,
IsDir: false,
IsVideo: false,
Type: "internetradio",
}
}
@@ -42,6 +42,8 @@ func NewPodcastEpisode(pe *db.PodcastEpisode) *PodcastEpisode {
BitRate: pe.Bitrate,
IsDir: false,
Size: pe.Size,
Album: pe.Album,
Artist: pe.Artist,
}
if pe.Podcast != nil {
r.Path = pe.AbsPath()
+71 -23
View File
@@ -2,13 +2,15 @@ package spec
import (
"fmt"
"html"
"regexp"
"strings"
"time"
"unicode"
"github.com/microcosm-cc/bluemonday"
"go.senan.xyz/gonic"
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
"jaytaylor.com/html2text"
)
// https://web.archive.org/web/20220707025402/https://www.subsonic.org/pages/api.jsp
@@ -69,6 +71,7 @@ type Response struct {
SimilarSongsTwo *SimilarSongsTwo `xml:"similarSongs2" json:"similarSongs2,omitempty"`
InternetRadioStations *InternetRadioStations `xml:"internetRadioStations" json:"internetRadioStations,omitempty"`
Lyrics *Lyrics `xml:"lyrics" json:"lyrics,omitempty"`
LyricsList *LyricsList `xml:"lyricsList" json:"lyricsList,omitempty"`
}
func NewResponse() *Response {
@@ -99,7 +102,7 @@ type Error struct {
Message string `xml:"message,attr" json:"message"`
}
func NewError(code int, message string, a ...interface{}) *Response {
func NewError(code int, message string, a ...any) *Response {
r := NewResponse()
r.Status = "failed"
r.Error = &Error{
@@ -125,7 +128,7 @@ type GenreRef struct {
// https://opensubsonic.netlify.app/docs/responses/albumid3/
type Album struct {
ID *specid.ID `xml:"id,attr,omitempty" json:"id"`
Created time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
Created time.Time `xml:"created,attr,omitempty" json:"created"`
// legacy or single tag mode
ArtistID *specid.ID `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
@@ -150,6 +153,9 @@ type Album struct {
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
IsCompilation bool `xml:"isCompilation" json:"isCompilation"`
ReleaseTypes []string `xml:"releaseTypes" json:"releaseTypes"`
// star / rating
Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
@@ -195,7 +201,7 @@ type TrackChild struct {
Bitrate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
CoverID *specid.ID `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
CreatedAt time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
CreatedAt time.Time `xml:"created,attr,omitempty" json:"created"`
Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
Genres []*GenreRef `xml:"genres,omitempty" json:"genres,omitempty"`
@@ -394,24 +400,26 @@ type PodcastChannel struct {
}
type PodcastEpisode struct {
ID *specid.ID `xml:"id,attr" json:"id"`
StreamID *specid.ID `xml:"streamId,attr" json:"streamId"`
ChannelID *specid.ID `xml:"channelId,attr" json:"channelId"`
Title string `xml:"title,attr" json:"title"`
Description string `xml:"description,attr" json:"description"`
PublishDate time.Time `xml:"publishDate,attr" json:"publishDate"`
Status string `xml:"status,attr" json:"status"`
Parent string `xml:"parent,attr" json:"parent"`
IsDir bool `xml:"isDir,attr" json:"isDir"`
Year int `xml:"year,attr" json:"year"`
Genre string `xml:"genre,attr" json:"genre"`
CoverArt *specid.ID `xml:"coverArt,attr" json:"coverArt"`
Size int `xml:"size,attr" json:"size"`
ContentType string `xml:"contentType,attr" json:"contentType"`
Suffix string `xml:"suffix,attr" json:"suffix"`
Duration int `xml:"duration,attr" json:"duration"`
BitRate int `xml:"bitRate,attr" json:"bitrate"`
Path string `xml:"path,attr" json:"path"`
ID *specid.ID `xml:"id,attr" json:"id"`
StreamID *specid.ID `xml:"streamId,attr" json:"streamId"`
ChannelID *specid.ID `xml:"channelId,attr" json:"channelId"`
Title string `xml:"title,attr" json:"title"`
Description string `xml:"description,attr" json:"description"`
PublishDate time.Time `xml:"publishDate,attr" json:"publishDate"`
Status string `xml:"status,attr" json:"status"`
Parent string `xml:"parent,attr" json:"parent"`
IsDir bool `xml:"isDir,attr" json:"isDir"`
Year int `xml:"year,attr" json:"year"`
Genre string `xml:"genre,attr" json:"genre"`
CoverArt *specid.ID `xml:"coverArt,attr" json:"coverArt"`
Size int `xml:"size,attr" json:"size"`
ContentType string `xml:"contentType,attr" json:"contentType"`
Suffix string `xml:"suffix,attr" json:"suffix"`
Duration int `xml:"duration,attr" json:"duration"`
BitRate int `xml:"bitRate,attr" json:"bitrate"`
Path string `xml:"path,attr" json:"path"`
Album string `xml:"album,attr" json:"album"`
Artist string `xml:"artist,attr" json:"artist"`
}
type Bookmarks struct {
@@ -468,6 +476,24 @@ type Lyrics struct {
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
}
type Lyric struct {
Start int64 `xml:"start,attr" json:"start"`
Value string `xml:",chardata" json:"value"`
}
type LyricsList struct {
StructuredLyrics []StructuredLyrics `xml:"structuredLyrics" json:"structuredLyrics"`
}
type StructuredLyrics struct {
Lang string `xml:"lang,attr" json:"lang"` // ISO 639 (or und, xxx if unknown)
Synced bool `xml:"synced,attr" json:"synced"`
Lines []Lyric `xml:"line" json:"line"`
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
DisplayTitle string `xml:"displayTitle,attr,omitempty" json:"displayTitle,omitempty"`
Offset int `xml:"offset,attr,omitempty" json:"offset,omitempty"`
}
type OpenSubsonicExtension struct {
Name string `xml:"name,attr" json:"name"`
Versions []int `xml:"versions" json:"versions"`
@@ -486,12 +512,34 @@ func formatExt(ext string) string {
return strings.TrimPrefix(ext, ".")
}
func formatReleaseTypes(types string) []string {
parts := strings.Split(types, ",")
if len(parts) == 0 {
return []string{}
}
for i, part := range parts {
part = strings.TrimSpace(part)
if len(part) == 0 {
continue
}
part = string(unicode.ToUpper([]rune(part)[0])) + string([]rune(part)[1:])
if part == "Ep" {
part = "EP"
}
parts[i] = part
}
return parts
}
var doublePuncExpr = regexp.MustCompile(`\.\s+\.\s+`)
var licenceExpr = regexp.MustCompile(`(?i)\buser-contributed text.*`)
var readMoreExpr = regexp.MustCompile(`(?i)\bread more on.*`)
var bluemondayPolicy = bluemonday.StrictPolicy() //nolint:gochecknoglobals
func CleanExternalText(text string) string {
text, _ = html2text.FromString(text, html2text.Options{TextOnly: true})
text = bluemondayPolicy.Sanitize(text)
text = html.UnescapeString(text)
text = licenceExpr.ReplaceAllString(text, "")
text = readMoreExpr.ReplaceAllString(text, "")
text = doublePuncExpr.ReplaceAllString(text, ". ")
-1
View File
@@ -24,7 +24,6 @@ func TestParseID(t *testing.T) {
}
for _, tcase := range tcases {
tcase := tcase // pin
t.Run(tcase.param, func(t *testing.T) {
t.Parallel()
@@ -21,7 +21,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-4",
@@ -37,7 +39,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-5",
@@ -53,7 +57,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-7",
@@ -69,7 +75,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-9",
@@ -101,7 +111,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-11",
@@ -117,7 +129,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-12",
@@ -133,7 +147,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
}
]
}
+27 -9
View File
@@ -21,7 +21,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-7",
@@ -37,7 +39,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-11",
@@ -53,7 +57,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-4",
@@ -69,7 +75,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-12",
@@ -101,7 +111,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-5",
@@ -117,7 +129,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-9",
@@ -133,7 +147,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
}
]
}
+27 -9
View File
@@ -21,7 +21,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-4",
@@ -37,7 +39,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-5",
@@ -53,7 +57,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-7",
@@ -69,7 +75,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-9",
@@ -101,7 +111,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-11",
@@ -117,7 +129,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-12",
@@ -133,7 +147,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
}
]
}
+102 -84
View File
@@ -7,6 +7,24 @@
"openSubsonic": true,
"albumList": {
"album": [
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
@@ -21,7 +39,9 @@
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-7",
@@ -37,71 +57,9 @@
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-12",
@@ -117,7 +75,81 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-9",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-1",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-6",
"isDir": true,
"coverArt": "al-9",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-1",
"album": "album-1",
"parent": "al-2",
"isDir": true,
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-3",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-0",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-2",
"isDir": true,
"coverArt": "al-3",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-13",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-2",
"album": "album-2",
"parent": "al-10",
"isDir": true,
"coverArt": "al-13",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
},
{
"id": "al-8",
@@ -133,23 +165,9 @@
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artist": "artist-2",
"artists": null,
"displayArtist": "",
"title": "album-0",
"album": "album-0",
"parent": "al-10",
"isDir": true,
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": []
}
]
}
@@ -21,7 +21,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
@@ -37,7 +39,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
@@ -53,7 +57,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
@@ -69,7 +75,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -101,7 +111,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
@@ -117,7 +129,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
@@ -133,7 +147,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
@@ -21,7 +21,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
@@ -37,7 +39,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
@@ -53,7 +57,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
@@ -69,7 +75,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
@@ -101,7 +111,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
@@ -117,7 +129,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -133,7 +147,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+27 -9
View File
@@ -21,7 +21,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
@@ -37,7 +39,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
@@ -53,7 +57,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
@@ -69,7 +75,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -85,7 +93,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -101,7 +111,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
@@ -117,7 +129,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
@@ -133,7 +147,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -149,7 +165,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+102 -84
View File
@@ -21,39 +21,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"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
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -69,55 +39,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
},
{
"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
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -133,7 +57,9 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -149,7 +75,99 @@
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-2",
"album": "album-2",
"coverArt": "al-5",
"name": "album-2",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-1",
"album": "album-1",
"coverArt": "al-12",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-2",
"artist": "artist-1",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "artist-1",
"title": "album-0",
"album": "album-0",
"coverArt": "al-7",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-1",
"artist": "artist-0",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "artist-0",
"title": "album-1",
"album": "album-1",
"coverArt": "al-4",
"name": "album-1",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
"created": "2019-11-30T00:00:00Z",
"artistId": "ar-3",
"artist": "artist-2",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "artist-2",
"title": "album-0",
"album": "album-0",
"coverArt": "al-11",
"name": "album-0",
"songCount": 3,
"duration": 300,
"playCount": 0,
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+3 -1
View File
@@ -107,7 +107,9 @@
"musicBrainzId": "",
"replayGain": null
}
]
],
"isCompilation": false,
"releaseTypes": ["Album"]
}
}
}
+3 -1
View File
@@ -16,7 +16,9 @@
"name": "",
"songCount": 0,
"duration": 0,
"playCount": 0
"playCount": 0,
"isCompilation": false,
"releaseTypes": [""]
}
}
}
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
@@ -44,7 +46,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
@@ -62,7 +66,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
@@ -44,7 +46,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -62,7 +66,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+9 -3
View File
@@ -26,7 +26,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -44,7 +46,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -62,7 +66,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
@@ -13,7 +13,9 @@
{
"id": "tr-1",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -39,7 +41,9 @@
{
"id": "tr-2",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -65,7 +69,9 @@
{
"id": "tr-3",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -23,6 +23,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-0",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -39,6 +40,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-1",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -55,6 +57,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-2",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
}
+27 -9
View File
@@ -23,7 +23,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-4",
@@ -41,7 +43,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-5",
@@ -59,7 +63,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-7",
@@ -77,7 +83,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-8",
@@ -95,7 +103,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-9",
@@ -113,7 +123,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-11",
@@ -131,7 +143,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-12",
@@ -149,7 +163,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
},
{
"id": "al-13",
@@ -167,7 +183,9 @@
"playCount": 0,
"genre": "Unknown Genre",
"genres": [{ "name": "Unknown Genre" }],
"year": 2021
"year": 2021,
"isCompilation": false,
"releaseTypes": ["Album"]
}
]
}
+9
View File
@@ -20,6 +20,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-0",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -36,6 +37,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-1",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -52,6 +54,7 @@
"isVideo": false,
"parent": "al-2",
"title": "album-2",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -68,6 +71,7 @@
"isVideo": false,
"parent": "al-6",
"title": "album-0",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -84,6 +88,7 @@
"isVideo": false,
"parent": "al-6",
"title": "album-1",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -100,6 +105,7 @@
"isVideo": false,
"parent": "al-6",
"title": "album-2",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -116,6 +122,7 @@
"isVideo": false,
"parent": "al-10",
"title": "album-0",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -132,6 +139,7 @@
"isVideo": false,
"parent": "al-10",
"title": "album-1",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
},
@@ -148,6 +156,7 @@
"isVideo": false,
"parent": "al-10",
"title": "album-2",
"year": 2021,
"musicBrainzId": "",
"replayGain": null
}
+40
View File
@@ -10,7 +10,9 @@
{
"id": "tr-1",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -36,7 +38,9 @@
{
"id": "tr-2",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -62,7 +66,9 @@
{
"id": "tr-3",
"album": "album-0",
"albumId": "al-3",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -88,7 +94,9 @@
{
"id": "tr-4",
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -114,7 +122,9 @@
{
"id": "tr-5",
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -140,7 +150,9 @@
{
"id": "tr-6",
"album": "album-1",
"albumId": "al-4",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -166,7 +178,9 @@
{
"id": "tr-7",
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -192,7 +206,9 @@
{
"id": "tr-8",
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -218,7 +234,9 @@
{
"id": "tr-9",
"album": "album-2",
"albumId": "al-5",
"artist": "artist-0",
"artistId": "ar-1",
"artists": [{ "id": "ar-1", "name": "artist-0" }],
"displayArtist": "",
"albumArtists": null,
@@ -244,7 +262,9 @@
{
"id": "tr-10",
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -270,7 +290,9 @@
{
"id": "tr-11",
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -296,7 +318,9 @@
{
"id": "tr-12",
"album": "album-0",
"albumId": "al-7",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -322,7 +346,9 @@
{
"id": "tr-13",
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -348,7 +374,9 @@
{
"id": "tr-14",
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -374,7 +402,9 @@
{
"id": "tr-15",
"album": "album-1",
"albumId": "al-8",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -400,7 +430,9 @@
{
"id": "tr-16",
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -426,7 +458,9 @@
{
"id": "tr-17",
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -452,7 +486,9 @@
{
"id": "tr-18",
"album": "album-2",
"albumId": "al-9",
"artist": "artist-1",
"artistId": "ar-2",
"artists": [{ "id": "ar-2", "name": "artist-1" }],
"displayArtist": "",
"albumArtists": null,
@@ -478,7 +514,9 @@
{
"id": "tr-19",
"album": "album-0",
"albumId": "al-11",
"artist": "artist-2",
"artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "",
"albumArtists": null,
@@ -504,7 +542,9 @@
{
"id": "tr-20",
"album": "album-0",
"albumId": "al-11",
"artist": "artist-2",
"artistId": "ar-3",
"artists": [{ "id": "ar-3", "name": "artist-2" }],
"displayArtist": "",
"albumArtists": null,
+4
View File
@@ -25,6 +25,10 @@ type Info interface {
TrackNumber() int
DiscNumber() int
Year() int
Lyrics() string
Compilation() bool
ReleaseType() string
ReplayGainTrackGain() float32
ReplayGainTrackPeak() float32
+12
View File
@@ -51,6 +51,12 @@ 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"))) }
@@ -93,6 +99,12 @@ 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")
+4 -7
View File
@@ -113,18 +113,15 @@ func TestCachingParallelism(t *testing.T) {
callback: func() { realTranscodeCount.Add(1) },
}
cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir())
cacheTranscoder := transcode.NewCachingTranscoder(transcoder, t.TempDir(), 1024)
var wg sync.WaitGroup
for i := 0; i < 5; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for range 5 {
wg.Go(func() {
var buf bytes.Buffer
require.NoError(t, cacheTranscoder.Transcode(context.Background(), transcode.PCM16le, "testdata/5s.flac", &buf))
require.Equal(t, 5*bytesPerSec, buf.Len())
}()
})
}
wg.Wait()
+60 -2
View File
@@ -5,9 +5,12 @@ import (
"crypto/md5"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"sort"
"sync"
"time"
)
const perm = 0o644
@@ -15,16 +18,21 @@ const perm = 0o644
type CachingTranscoder struct {
cachePath string
transcoder Transcoder
limitMB int
locks keyedMutex
cleanLock sync.RWMutex
}
var _ Transcoder = (*CachingTranscoder)(nil)
func NewCachingTranscoder(t Transcoder, cachePath string) *CachingTranscoder {
return &CachingTranscoder{transcoder: t, cachePath: cachePath}
func NewCachingTranscoder(t Transcoder, cachePath string, limitMB int) *CachingTranscoder {
return &CachingTranscoder{transcoder: t, cachePath: cachePath, limitMB: limitMB}
}
func (t *CachingTranscoder) Transcode(ctx context.Context, profile Profile, in string, out io.Writer) error {
t.cleanLock.RLock()
defer t.cleanLock.RUnlock()
// don't try cache partial transcodes
if profile.Seek() > 0 {
return t.transcoder.Transcode(ctx, profile, in, out)
@@ -52,6 +60,7 @@ func (t *CachingTranscoder) Transcode(ctx context.Context, profile Profile, in s
if i, err := cf.Stat(); err == nil && i.Size() > 0 {
_, _ = io.Copy(out, cf)
_ = os.Chtimes(path, time.Now(), time.Now()) // Touch for LRU cache purposes
return nil
}
@@ -64,6 +73,55 @@ func (t *CachingTranscoder) Transcode(ctx context.Context, profile Profile, in s
return nil
}
func (t *CachingTranscoder) CacheEject() error {
t.cleanLock.Lock()
defer t.cleanLock.Unlock()
// Delete LRU cache files that exceed size limit. Use last modified time.
type file struct {
path string
info os.FileInfo
}
var files []file
var total int64 = 0
err := filepath.WalkDir(t.cachePath, func(path string, de fs.DirEntry, err error) error {
if err != nil {
return err
}
if !de.IsDir() {
info, err := de.Info()
if err != nil {
return fmt.Errorf("walk cache path for eject: %w", err)
}
files = append(files, file{path, info})
total += info.Size()
}
return nil
})
if err != nil {
return fmt.Errorf("walk cache path for eject: %w", err)
}
sort.Slice(files, func(i, j int) bool {
return files[i].info.ModTime().Before(files[j].info.ModTime())
})
for total > int64(t.limitMB)*1024*1024 {
curFile := files[0]
files = files[1:]
total -= curFile.info.Size()
err = os.Remove(curFile.path)
if err != nil {
return fmt.Errorf("remove cache file: %w", err)
}
}
return nil
}
func cacheKey(cmd string, args []string) string {
// the cache is invalid whenever transcode command (which includes the
// absolute filepath, bit rate args, replay gain args, etc.) changes
+1 -1
View File
@@ -1,4 +1,4 @@
//nolint:gochecknoglobals,golint,stylecheck
//nolint:gochecknoglobals
package gonic
import (
+1 -1
View File
@@ -1 +1 @@
0.16.4
0.17.0