Skip to content

Commit 89ec868

Browse files
committed
Merge branch 'main' into unstable
2 parents 9b79a6d + cead146 commit 89ec868

3 files changed

Lines changed: 44 additions & 9 deletions

File tree

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ module github.com/Unpackerr/unpackerr
22

33
go 1.26.0
44

5-
// we need to use our own iso9660 package until we fix the issue with the original package.
6-
replace github.com/kdomanski/iso9660 => github.com/Unpackerr/iso9660 v0.0.1
7-
85
require (
96
code.cloudfoundry.org/bytefmt v0.65.0
107
github.com/BurntSushi/toml v1.6.0
@@ -24,11 +21,12 @@ require (
2421
golift.io/rotatorr v0.0.0-20260217050959-f6ac6fc7b38e
2522
golift.io/starr v1.3.1-0.20260304004613-cdd72e927793
2623
golift.io/version v0.0.2
27-
golift.io/xtractr v0.3.1-0.20260303223111-379595ddbc52
24+
golift.io/xtractr v0.3.1-0.20260304025452-40959934f4a6
2825
gopkg.in/yaml.v3 v3.0.1
2926
)
3027

3128
require (
29+
github.com/Unpackerr/iso9660 v0.0.3 // indirect
3230
github.com/andybalholm/brotli v1.2.0 // indirect
3331
github.com/beorn7/perks v1.0.1 // indirect
3432
github.com/bodgit/plumbing v1.3.0 // indirect
@@ -49,7 +47,6 @@ require (
4947
github.com/gopherjs/gopherjs v1.20.1 // indirect
5048
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
5149
github.com/icza/bitio v1.1.0 // indirect
52-
github.com/kdomanski/iso9660 v0.4.0 // indirect
5350
github.com/klauspost/compress v1.18.4 // indirect
5451
github.com/lestrrat-go/strftime v1.1.1 // indirect
5552
github.com/mewkiz/flac v1.0.13 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk
44
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
55
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
66
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
7-
github.com/Unpackerr/iso9660 v0.0.1 h1:T1sigj6u9eBuoVeeJyMRdSHi83czj5EDU7vCQUhDv7g=
8-
github.com/Unpackerr/iso9660 v0.0.1/go.mod h1:OxUSupHsO9ceI8lBLPJKWBTphLemjrCQY8LPXM7qSzU=
7+
github.com/Unpackerr/iso9660 v0.0.3 h1:WXXFIcmDLhnsKhXjPg2moUmHxhoUmIX7FLxrtqHJ7yQ=
8+
github.com/Unpackerr/iso9660 v0.0.3/go.mod h1:4Py6ZWQ+sUVo4BmmzZaFgOLcS3to5BMvH39TlOYNxhA=
99
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
1010
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
1111
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
@@ -254,8 +254,8 @@ golift.io/udf v0.0.1 h1:kEcJVzqqR+IEWGMuPjuVPT9DzXRDukEgsizKAKn1LF8=
254254
golift.io/udf v0.0.1/go.mod h1:ndK7AlWOh+u+nW9tNsQR95dfHsfASG5Y3dMyzVqmPjw=
255255
golift.io/version v0.0.2 h1:i0gXRuSDHKs4O0sVDUg4+vNIuOxYoXhaxspftu2FRTE=
256256
golift.io/version v0.0.2/go.mod h1:76aHNz8/Pm7CbuxIsDi97jABL5Zui3f2uZxDm4vB6hU=
257-
golift.io/xtractr v0.3.1-0.20260303223111-379595ddbc52 h1:/CGl24IA/b32/faMU+cxJCJ5vq65boxH/BAV3dqV8Yo=
258-
golift.io/xtractr v0.3.1-0.20260303223111-379595ddbc52/go.mod h1:bDBgCgojMc0HncBUMD29MYIaupCq9enUbeAYeB8AuNY=
257+
golift.io/xtractr v0.3.1-0.20260304025452-40959934f4a6 h1:225AQDhFs6xcDfHolAgDEMDCvW4OHcn9DfFUq2/YGs8=
258+
golift.io/xtractr v0.3.1-0.20260304025452-40959934f4a6/go.mod h1:eBMTpgtnCZYbEDDMyqEERs+z9bGUdOIJf+7Qy1qJBOo=
259259
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
260260
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
261261
gopkg.in/Knetic/govaluate.v3 v3.0.0/go.mod h1:csKLBORsPbafmSCGTEh3U7Ozmsuq8ZSIlKk1bcqph0E=

pkg/unpackerr/lidarr.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package unpackerr
22

33
import (
44
"errors"
5+
"path/filepath"
56
"strings"
67
"time"
78

@@ -161,6 +162,31 @@ func extractionHasFlacFiles(files []string) bool {
161162
return false
162163
}
163164

165+
// filterManualImportToSplitTracks returns only outputs whose path is in the extract's NewFiles
166+
// (the split track files). This excludes the original FLAC file we split from, which Lidarr
167+
// would otherwise try and fail to import.
168+
func filterManualImportToSplitTracks(outputs []*lidarr.ManualImportOutput, item *Extract) []*lidarr.ManualImportOutput {
169+
if item == nil || item.Resp == nil || len(item.Resp.NewFiles) == 0 {
170+
return outputs
171+
}
172+
173+
splitPaths := make(map[string]struct{}, len(item.Resp.NewFiles))
174+
for _, p := range item.Resp.NewFiles {
175+
splitPaths[filepath.Clean(p)] = struct{}{}
176+
}
177+
178+
filtered := outputs[:0]
179+
for _, out := range outputs {
180+
if out != nil && out.Path != "" {
181+
if _, ok := splitPaths[filepath.Clean(out.Path)]; ok {
182+
filtered = append(filtered, out)
183+
}
184+
}
185+
}
186+
187+
return filtered
188+
}
189+
164190
// importSplitFlacTracks runs in a goroutine after a Lidarr FLAC+CUE split extraction completes.
165191
// It asks Lidarr for the manual import list for the extract folder and sends the ManualImport command
166192
// so Lidarr imports the split track files.
@@ -192,12 +218,24 @@ func (u *Unpackerr) importSplitFlacTracks(item *Extract, server *LidarrConfig) {
192218
return
193219
}
194220

221+
// Exclude the original FLAC we split from; only import the split track files (item.Resp.NewFiles).
222+
// Lidarr returns every file in the folder including the source file, which will never import.
223+
outputs = filterManualImportToSplitTracks(outputs, item)
224+
225+
if len(outputs) == 0 {
226+
u.Printf("[Lidarr] No split track files to import (folder: %s); original FLAC excluded", item.Path)
227+
return
228+
}
229+
195230
cmd := lidarr.ManualImportCommandFromOutputs(outputs, true)
196231
if cmd == nil {
197232
u.Printf("[Lidarr] No importable files for manual import: %s", item.Path)
198233
return
199234
}
200235

236+
u.Debugf("[Lidarr] Sending manual import command: replaceExisting=%v, importMode=%q, files=%d: %v",
237+
cmd.ReplaceExistingFiles, cmd.ImportMode, len(cmd.Files), cmd.Files)
238+
201239
_, err = server.SendManualImportCommand(cmd)
202240
if err != nil {
203241
u.Errorf("[Lidarr] Manual import command failed for %s: %v", item.Path, err)

0 commit comments

Comments
 (0)