-
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathcrossseed_test.go
More file actions
5611 lines (5170 loc) · 191 KB
/
crossseed_test.go
File metadata and controls
5611 lines (5170 loc) · 191 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2025-2026, s0up and the autobrr contributors.
// SPDX-License-Identifier: GPL-2.0-or-later
package crossseed
import (
"bytes"
"context"
"encoding/base64"
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/anacrolix/torrent/bencode"
"github.com/anacrolix/torrent/metainfo"
qbt "github.com/autobrr/go-qbittorrent"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/autobrr/qui/internal/models"
internalqb "github.com/autobrr/qui/internal/qbittorrent"
"github.com/autobrr/qui/internal/services/jackett"
"github.com/autobrr/qui/internal/services/notifications"
"github.com/autobrr/qui/pkg/releases"
"github.com/autobrr/qui/pkg/stringutils"
)
// Helper function to create a test torrent file
func createTestTorrent(t *testing.T, name string, files []string, pieceLength int64) []byte {
t.Helper()
tempDir := t.TempDir()
// Create actual files
for _, f := range files {
path := filepath.Join(tempDir, name, f)
dir := filepath.Dir(path)
require.NoError(t, os.MkdirAll(dir, 0755))
content := fmt.Appendf(nil, "test content for %s", f)
require.NoError(t, os.WriteFile(path, content, 0644))
}
mi := metainfo.MetaInfo{
AnnounceList: [][]string{{"http://tracker.example.com:8080/announce"}},
}
info := metainfo.Info{
Name: name,
PieceLength: pieceLength,
}
if len(files) == 1 {
// Single file torrent - build from the file directly
path := filepath.Join(tempDir, name, files[0])
require.NoError(t, info.BuildFromFilePath(path))
// Override name to match what we want
info.Name = name
} else {
// Multi-file torrent - build from directory
path := filepath.Join(tempDir, name)
err := info.BuildFromFilePath(path)
require.NoError(t, err)
info.Name = name
}
infoBytes, err := bencode.Marshal(info)
require.NoError(t, err)
mi.InfoBytes = infoBytes
var buf bytes.Buffer
require.NoError(t, mi.Write(&buf))
return buf.Bytes()
}
// TestDecodeTorrentData tests base64 decoding with various formats
func TestDecodeTorrentData(t *testing.T) {
s := &Service{}
testData := []byte("test torrent data")
tests := []struct {
name string
input string
wantErr bool
wantData []byte
}{
{
name: "standard base64",
input: base64.StdEncoding.EncodeToString(testData),
wantErr: false,
wantData: testData,
},
{
name: "standard base64 with whitespace",
input: " " + base64.StdEncoding.EncodeToString(testData) + "\n\t",
wantErr: false,
wantData: testData,
},
{
name: "url-safe base64",
input: base64.URLEncoding.EncodeToString(testData),
wantErr: false,
wantData: testData,
},
{
name: "raw standard base64",
input: base64.RawStdEncoding.EncodeToString(testData),
wantErr: false,
wantData: testData,
},
{
name: "raw url-safe base64",
input: base64.RawURLEncoding.EncodeToString(testData),
wantErr: false,
wantData: testData,
},
{
name: "invalid base64",
input: "not-valid-base64!!!",
wantErr: true,
},
{
name: "empty string returns empty",
input: "",
wantErr: false,
wantData: []byte{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := s.decodeTorrentData(tt.input)
if tt.wantErr {
assert.Error(t, err)
return
}
require.NoError(t, err)
assert.Equal(t, tt.wantData, got)
})
}
}
// TestParseTorrentName tests torrent parsing and info hash calculation
func TestParseTorrentName(t *testing.T) {
tests := []struct {
name string
torrentName string
files []string
wantName string
wantHashLen int
}{
{
name: "single file torrent",
torrentName: "Movie.2020.1080p.BluRay.x264-GROUP",
files: []string{"Movie.2020.1080p.BluRay.x264-GROUP.mkv"},
wantName: "Movie.2020.1080p.BluRay.x264-GROUP",
wantHashLen: 40, // SHA1 hex string
},
{
name: "multi-file torrent",
torrentName: "Show.S01E05.1080p.WEB-DL",
files: []string{
"Show.S01E05.1080p.WEB-DL.mkv",
"Show.S01E05.1080p.WEB-DL.srt",
},
wantName: "Show.S01E05.1080p.WEB-DL",
wantHashLen: 40,
},
{
name: "season pack torrent",
torrentName: "Show.S01.1080p.BluRay.x264-GROUP",
files: []string{
"Show.S01E01.mkv",
"Show.S01E02.mkv",
"Show.S01E03.mkv",
},
wantName: "Show.S01.1080p.BluRay.x264-GROUP",
wantHashLen: 40,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
torrentData := createTestTorrent(t, tt.torrentName, tt.files, 256*1024)
name, hash, err := ParseTorrentName(torrentData)
require.NoError(t, err)
assert.Equal(t, tt.wantName, name)
assert.Len(t, hash, tt.wantHashLen)
assert.NotEmpty(t, hash)
})
}
}
// TestParseTorrentName_Errors tests error cases in torrent parsing
func TestParseTorrentName_Errors(t *testing.T) {
tests := []struct {
name string
data []byte
wantErr string
}{
{
name: "invalid torrent data",
data: []byte("not a valid torrent"),
wantErr: "failed to parse torrent metainfo",
},
{
name: "empty data",
data: []byte{},
wantErr: "failed to parse torrent metainfo",
},
{
name: "corrupted bencode",
data: []byte("d8:announce"),
wantErr: "failed to parse torrent metainfo",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, _, err := ParseTorrentName(tt.data)
require.Error(t, err)
assert.Contains(t, err.Error(), tt.wantErr)
})
}
}
// TestDetermineSavePath tests path determination logic
func TestDetermineSavePath(t *testing.T) {
cache := NewReleaseCache()
s := &Service{releaseCache: cache}
tests := []struct {
name string
newTorrentName string
matchedTorrentName string
matchedContentPath string
baseSavePath string
contentLayout string
matchType string
sourceFiles qbt.TorrentFiles
candidateFiles qbt.TorrentFiles
wantPath string
description string
}{
{
name: "season pack from individual episode",
newTorrentName: "Show.S01.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Show.S01E05.1080p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Show/Season 01", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-GROUP/ep1.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01E05.1080p.WEB-DL.x264-OTHER/ep.mkv"}},
wantPath: "/data/media/Show/Season 01/Show.S01E05.1080p.WEB-DL.x264-OTHER",
description: "Different roots - use SavePath + candidateRoot (existing files are there)",
},
{
name: "individual episode from season pack",
newTorrentName: "Show.S01E05.1080p.WEB-DL.x264-OTHER",
matchedTorrentName: "Show.S01.1080p.BluRay.x264-GROUP",
baseSavePath: "/data/media/Show/Season 01", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E05.1080p.WEB-DL.x264-OTHER/ep.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-GROUP/ep1.mkv"}},
wantPath: "/data/media/Show/Season 01/Show.S01.1080p.BluRay.x264-GROUP",
description: "Different roots - use SavePath + candidateRoot (existing files are there)",
},
{
name: "same content type - both episodes",
newTorrentName: "Show.S01E05.720p.HDTV.x264-GROUP",
matchedTorrentName: "Show.S01E05.1080p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Show/Season 01", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E05.720p.HDTV.x264-GROUP/ep.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01E05.1080p.WEB-DL.x264-OTHER/ep.mkv"}},
wantPath: "/data/media/Show/Season 01/Show.S01E05.1080p.WEB-DL.x264-OTHER",
description: "Different roots - use SavePath + candidateRoot (existing files are there)",
},
{
name: "same content type - both season packs with same root",
newTorrentName: "Show.S01.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Show.S01.1080p.BluRay.x264-GROUP",
baseSavePath: "/data/media/Show", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-GROUP/ep1.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-GROUP/ep1.mkv"}},
wantPath: "/data/media/Show",
description: "Same root folders, use SavePath (parent)",
},
{
name: "movies with year",
newTorrentName: "Movie.2020.720p.BluRay.x264-GROUP",
matchedTorrentName: "Movie.2020.1080p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Movies/Movie (2020)", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.2020.720p.BluRay.x264-GROUP/movie.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie.2020.1080p.WEB-DL.x264-OTHER/movie.mkv"}},
wantPath: "/data/media/Movies/Movie (2020)/Movie.2020.1080p.WEB-DL.x264-OTHER",
description: "Different roots - use SavePath + candidateRoot (existing files are there)",
},
{
name: "no series info",
newTorrentName: "Documentary.1080p.HDTV.x264-GROUP",
matchedTorrentName: "Documentary.720p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Documentaries", contentLayout: "Original",
matchType: "size",
sourceFiles: qbt.TorrentFiles{{Name: "Documentary.1080p.HDTV.x264-GROUP/doc.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Documentary.720p.WEB-DL.x264-OTHER/doc.mkv"}},
wantPath: "/data/media/Documentaries/Documentary.720p.WEB-DL.x264-OTHER",
description: "Different roots - use SavePath + candidateRoot (existing files are there)",
},
{
name: "partial-in-pack movie in collection",
newTorrentName: "Pulse.2001.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Horror.Collection.2020",
matchedContentPath: "/data/media/Movies/Horror.Collection.2020",
baseSavePath: "/data/media/Movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Pulse.2001.1080p.BluRay.x264-GROUP/movie.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Horror.Collection.2020/Pulse.2001.mkv"}},
wantPath: "/data/media/Movies/Horror.Collection.2020",
description: "Partial-in-pack uses ContentPath, not SavePath",
},
{
name: "partial-in-pack episode in season pack (folder source)",
newTorrentName: "Show.S01E05.1080p.WEB-DL.x264-GROUP",
matchedTorrentName: "Show.S01.1080p.BluRay.x264-OTHER",
matchedContentPath: "/data/media/Shows/Show.S01.1080p.BluRay.x264-OTHER",
baseSavePath: "/data/media/Shows", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E05.1080p.WEB-DL.x264-GROUP/ep.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-OTHER/ep1.mkv"}},
wantPath: "/data/media/Shows/Show.S01.1080p.BluRay.x264-OTHER",
description: "Partial-in-pack episode uses season pack's ContentPath",
},
{
name: "partial-in-pack single-file episode into season pack folder",
newTorrentName: "Show.S01E05.1080p.WEB-DL.x264-GROUP",
matchedTorrentName: "Show.S01.1080p.BluRay.x264-OTHER",
matchedContentPath: "/data/media/Shows/Show.S01.1080p.BluRay.x264-OTHER",
baseSavePath: "/data/media/Shows", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "ep.mkv"}}, // Single file, no folder
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01.1080p.BluRay.x264-OTHER/ep1.mkv"}},
wantPath: "/data/media/Shows/Show.S01.1080p.BluRay.x264-OTHER",
description: "Single-file TV episode uses season pack's ContentPath, not SavePath+Subfolder",
},
{
name: "partial-in-pack with empty ContentPath uses candidateRoot",
newTorrentName: "Movie.2020.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Collection.2020",
matchedContentPath: "",
baseSavePath: "/data/media/Movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.2020.1080p.BluRay.x264-GROUP/movie.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Collection.2020/movie.mkv"}},
wantPath: "/data/media/Movies/Collection.2020",
description: "Partial-in-pack with empty ContentPath uses SavePath + candidateRoot",
},
{
name: "different root folders uses ContentPath",
newTorrentName: "SceneRelease.2020.BluRay.1080p-GRP",
matchedTorrentName: "Movie (2020) [1080p]",
matchedContentPath: "/data/media/Movies/Movie (2020) [1080p]",
baseSavePath: "/data/media/Movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "SceneRelease.2020.BluRay.1080p-GRP/movie.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie (2020) [1080p]/movie.mkv"}},
wantPath: "/data/media/Movies/Movie (2020) [1080p]",
description: "Different root folders should use ContentPath",
},
{
name: "single file torrents (no root) use SavePath",
newTorrentName: "Movie.2020.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Movie.2020.1080p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "movie.mkv"}},
candidateFiles: qbt.TorrentFiles{{Name: "movie.mkv"}},
wantPath: "/data/media/Movies",
description: "Single file torrents with no root folder use SavePath",
},
// ============================================================
// MOVIES - Comprehensive folder structure scenarios
// ============================================================
// M1: We seed folder, match on loose file (partial-in-pack)
// Seeding: The.Movie.2020-GRP/The.Movie.2020-GRP.mkv
// Match: The.Movie.2020-GRP.mkv (no folder)
{
name: "M1: movie folder seeded, match loose file",
newTorrentName: "The.Movie.2020-GRP.mkv",
matchedTorrentName: "The.Movie.2020-GRP",
matchedContentPath: "/movies/The.Movie.2020-GRP",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP/The.Movie.2020-GRP.mkv", Size: 5 << 30}},
wantPath: "/movies",
description: "Loose file uses SavePath, Subfolder layout creates folder",
},
// M2: We seed loose file, match on folder
// Seeding: movie.mkv (no folder, in /movies/)
// Match: The.Movie.2020-GRP/movie.mkv
{
name: "M2: movie loose file seeded, match folder",
newTorrentName: "The.Movie.2020-GRP",
matchedTorrentName: "The.Movie.2020-GRP",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP/movie.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "movie.mkv", Size: 5 << 30}},
wantPath: "/movies",
description: "Folder torrent points to SavePath, NoSubfolder strips root",
},
// M3: Same root folder names
// Seeding: The.Movie.2020-GRP/movie.mkv
// Match: The.Movie.2020-GRP/movie.mkv (same structure, different tracker)
{
name: "M3: movie same root folders",
newTorrentName: "The.Movie.2020-GRP",
matchedTorrentName: "The.Movie.2020-GRP",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP/movie.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP/movie.mkv", Size: 5 << 30}},
wantPath: "/movies",
description: "Same roots use SavePath with Original layout",
},
// M4: Different root folders (spaces vs dots naming)
// Seeding: Movie (2020) [1080p]/movie.mkv
// Match: The.Movie.2020.1080p-GRP/movie.mkv
{
name: "M4: movie spaces vs dots naming",
newTorrentName: "The.Movie.2020.1080p-GRP",
matchedTorrentName: "Movie (2020) [1080p]",
matchedContentPath: "/movies/Movie (2020) [1080p]",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020.1080p-GRP/movie.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie (2020) [1080p]/movie.mkv", Size: 5 << 30}},
wantPath: "/movies/Movie (2020) [1080p]",
description: "Different roots use candidate folder path",
},
// M5: Both loose files (no folders)
{
name: "M5: both movies loose files",
newTorrentName: "The.Movie.2020-GRP.mkv",
matchedTorrentName: "The.Movie.2020-GRP.mkv",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP.mkv", Size: 5 << 30}},
wantPath: "/movies",
description: "Both loose files use SavePath directly",
},
// M6: Both loose files with partial-in-pack match (ContentPath is file path)
// Bug scenario: ContentPath = /movies/Movie.mkv but we need SavePath = /movies
{
name: "M6: partial-in-pack single file to single file",
newTorrentName: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT",
matchedTorrentName: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv",
matchedContentPath: "/mnt/storage/torrents/movies/Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv",
baseSavePath: "/mnt/storage/torrents/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv", Size: 7 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv", Size: 7 << 30}},
wantPath: "/mnt/storage/torrents/movies",
description: "Single file partial-in-pack uses SavePath, not ContentPath (which is a file path)",
},
// M7: Folder-based source torrent matched against single file candidate
// Real scenario: indexer returns folder torrent, we have single .mkv file
{
name: "M7: partial-in-pack folder source to single file",
newTorrentName: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT",
matchedTorrentName: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv",
matchedContentPath: "/mnt/storage/torrents/movies/Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv",
baseSavePath: "/mnt/storage/torrents/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{
Name: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT/Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv",
Size: 7 << 30,
}},
candidateFiles: qbt.TorrentFiles{{Name: "Dracula.A.Love.Tale.2025.1080p.WEB.H264-SLOT.mkv", Size: 7 << 30}},
wantPath: "/mnt/storage/torrents/movies",
description: "Folder source to single file candidate uses SavePath",
},
// M8: Folder source → folder candidate (both have folders)
// Both torrents have folder structure - should use ContentPath (folder)
{
name: "M8: partial-in-pack folder source to folder candidate",
newTorrentName: "Movie.2020.1080p.WEB-GRP",
matchedTorrentName: "Movie.2020.1080p.BluRay-OTHER",
matchedContentPath: "/movies/Movie.2020.1080p.BluRay-OTHER",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{
Name: "Movie.2020.1080p.WEB-GRP/Movie.2020.1080p.WEB-GRP.mkv",
Size: 8 << 30,
}},
candidateFiles: qbt.TorrentFiles{{
Name: "Movie.2020.1080p.BluRay-OTHER/Movie.2020.1080p.BluRay-OTHER.mkv",
Size: 8 << 30,
}},
wantPath: "/movies/Movie.2020.1080p.BluRay-OTHER",
description: "Both have folders - uses ContentPath (folder path)",
},
// M9: Single file movie with extras folder matched against single file
// Source has extras subfolder, candidate is single file
{
name: "M9: movie with extras folder to single file",
newTorrentName: "Movie.2020.1080p.BluRay-GRP",
matchedTorrentName: "Movie.2020.1080p.WEB.mkv",
matchedContentPath: "/movies/Movie.2020.1080p.WEB.mkv",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{
{Name: "Movie.2020.1080p.BluRay-GRP/Movie.2020.1080p.BluRay-GRP.mkv", Size: 8 << 30},
{Name: "Movie.2020.1080p.BluRay-GRP/Extras/Behind.The.Scenes.mkv", Size: 1 << 30},
},
candidateFiles: qbt.TorrentFiles{{Name: "Movie.2020.1080p.WEB.mkv", Size: 8 << 30}},
wantPath: "/movies",
description: "Multi-file source with extras to single file uses SavePath",
},
// ============================================================
// TV SHOWS - Episode and Season Pack scenarios
// ============================================================
// Additional TV partial-in-pack single file candidate tests:
// T7: Season pack folder source → single loose episode file candidate
// Indexer has season pack, we have a single episode file
{
name: "T7: season pack source to single episode file",
newTorrentName: "The.Show.S01.1080p.BluRay-GRP",
matchedTorrentName: "The.Show.S01E01.1080p.WEB.mkv",
matchedContentPath: "/tv/The.Show.S01E01.1080p.WEB.mkv",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p.BluRay-GRP/The.Show.S01E01.1080p.BluRay-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.BluRay-GRP/The.Show.S01E02.1080p.BluRay-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.BluRay-GRP/The.Show.S01E03.1080p.BluRay-GRP.mkv", Size: 2 << 30},
},
candidateFiles: qbt.TorrentFiles{{Name: "The.Show.S01E01.1080p.WEB.mkv", Size: 2 << 30}},
wantPath: "/tv",
description: "Season pack source to single episode file uses SavePath",
},
// T8: Episode folder source → single episode file candidate
// Indexer has episode with folder, we have single episode file
{
name: "T8: episode folder source to single episode file",
newTorrentName: "The.Show.S01E05.1080p.BluRay-GRP",
matchedTorrentName: "The.Show.S01E05.1080p.WEB.mkv",
matchedContentPath: "/tv/The.Show.S01E05.1080p.WEB.mkv",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{
Name: "The.Show.S01E05.1080p.BluRay-GRP/The.Show.S01E05.1080p.BluRay-GRP.mkv",
Size: 2 << 30,
}},
candidateFiles: qbt.TorrentFiles{{Name: "The.Show.S01E05.1080p.WEB.mkv", Size: 2 << 30}},
wantPath: "/tv",
description: "Episode folder source to single episode file uses SavePath",
},
// T9: Single episode file source → single episode file candidate
// Both are single episode files without folders
{
name: "T9: single episode file to single episode file",
newTorrentName: "The.Show.S01E05.1080p.BluRay.mkv",
matchedTorrentName: "The.Show.S01E05.1080p.WEB.mkv",
matchedContentPath: "/tv/The.Show.S01E05.1080p.WEB.mkv",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "The.Show.S01E05.1080p.BluRay.mkv", Size: 2 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "The.Show.S01E05.1080p.WEB.mkv", Size: 2 << 30}},
wantPath: "/tv",
description: "Both single episode files - uses SavePath",
},
// T10: Episode with subs folder source → single episode file candidate
// Source has episode + subs in folder, candidate is single file
{
name: "T10: episode with subs to single episode file",
newTorrentName: "The.Show.S01E05.1080p.BluRay-GRP",
matchedTorrentName: "The.Show.S01E05.1080p.WEB.mkv",
matchedContentPath: "/tv/The.Show.S01E05.1080p.WEB.mkv",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{
{Name: "The.Show.S01E05.1080p.BluRay-GRP/The.Show.S01E05.1080p.BluRay-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01E05.1080p.BluRay-GRP/Subs/English.srt", Size: 100 << 10},
},
candidateFiles: qbt.TorrentFiles{{Name: "The.Show.S01E05.1080p.WEB.mkv", Size: 2 << 30}},
wantPath: "/tv",
description: "Episode with subs folder to single file uses SavePath",
},
// T1: Season pack seeded, match single episode (no folder)
// Seeding: Show.S01-GRP/E01.mkv, E02.mkv, ...
// Match: Show.S01E01-GRP.mkv (no folder)
{
name: "T1: season pack seeded, match loose episode",
newTorrentName: "The.Show.S01E01.1080p-GRP.mkv",
matchedTorrentName: "The.Show.S01.1080p-GRP",
matchedContentPath: "/tv/The.Show.S01.1080p-GRP",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "The.Show.S01E01.1080p-GRP.mkv", Size: 2 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E01.1080p-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E02.1080p-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E03.1080p-GRP.mkv", Size: 2 << 30},
},
wantPath: "/tv/The.Show.S01.1080p-GRP",
description: "TV episode into season pack uses ContentPath, NoSubfolder layout",
},
// T2: Single episode seeded (no folder), match season pack
// Seeding: Show.S01E01-GRP.mkv (loose file)
// Match: Show.S01-GRP/E01.mkv, E02.mkv, ...
{
name: "T2: loose episode seeded, match season pack",
newTorrentName: "The.Show.S01.1080p-GRP",
matchedTorrentName: "The.Show.S01E01.1080p-GRP",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-contains",
sourceFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E01.1080p-GRP.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E02.1080p-GRP.mkv", Size: 2 << 30},
},
candidateFiles: qbt.TorrentFiles{{Name: "The.Show.S01E01.1080p-GRP.mkv", Size: 2 << 30}},
wantPath: "/tv",
description: "Season pack uses SavePath, episode file exists there",
},
// T3: Season pack seeded, match single episode (with folder)
// Seeding: Show.S01-GRP/E01.mkv, E02.mkv, ...
// Match: Show.S01E01-GRP/E01.mkv (has folder)
{
name: "T3: season pack seeded, match episode with folder",
newTorrentName: "The.Show.S01E01.1080p-OTHER",
matchedTorrentName: "The.Show.S01.1080p-GRP",
matchedContentPath: "/tv/The.Show.S01.1080p-GRP",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "The.Show.S01E01.1080p-OTHER/ep.mkv", Size: 2 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E01.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p-GRP/The.Show.S01E02.mkv", Size: 2 << 30},
},
wantPath: "/tv/The.Show.S01.1080p-GRP",
description: "Episode with folder placed inside season pack folder",
},
// T4: Season pack to season pack (same root)
// Seeding: Show.S01.BluRay-GRP/...
// Match: Show.S01.BluRay-GRP/... (same name, different tracker)
{
name: "T4: season pack same root",
newTorrentName: "The.Show.S01.1080p.BluRay-GRP",
matchedTorrentName: "The.Show.S01.1080p.BluRay-GRP",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p.BluRay-GRP/ep1.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.BluRay-GRP/ep2.mkv", Size: 2 << 30},
},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p.BluRay-GRP/ep1.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.BluRay-GRP/ep2.mkv", Size: 2 << 30},
},
wantPath: "/tv",
description: "Same root folders use SavePath with Original layout",
},
// T5: Season pack to season pack (different root)
// Seeding: Show.S01.BluRay-GRP1/...
// Match: Show.S01.WEB-GRP2/...
{
name: "T5: season pack different roots",
newTorrentName: "The.Show.S01.1080p.WEB-GRP",
matchedTorrentName: "The.Show.S01.1080p.BluRay-GRP",
matchedContentPath: "/tv/The.Show.S01.1080p.BluRay-GRP",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p.WEB-GRP/ep1.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.WEB-GRP/ep2.mkv", Size: 2 << 30},
},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Show.S01.1080p.BluRay-GRP/ep1.mkv", Size: 2 << 30},
{Name: "The.Show.S01.1080p.BluRay-GRP/ep2.mkv", Size: 2 << 30},
},
wantPath: "/tv/The.Show.S01.1080p.BluRay-GRP",
description: "Different roots use candidate folder path",
},
// T6: Episode with spaces naming vs dots
{
name: "T6: episode spaces vs dots",
newTorrentName: "The.Show.S01E01.1080p-GRP",
matchedTorrentName: "The Show S01E01 [1080p]",
matchedContentPath: "/tv/The Show S01E01 [1080p]",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Show.S01E01.1080p-GRP/ep.mkv", Size: 2 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "The Show S01E01 [1080p]/ep.mkv", Size: 2 << 30}},
wantPath: "/tv/The Show S01E01 [1080p]",
description: "Different naming conventions use candidate folder",
},
// ============================================================
// COLLECTIONS - Movie and TV collections
// ============================================================
// C1: Collection seeded, match single movie (no folder)
// Seeding: Horror.Collection/Pulse.mkv, Ring.mkv
// Match: Pulse.2001-GRP.mkv (no folder)
{
name: "C1: collection seeded, match loose movie",
newTorrentName: "Pulse.2001.1080p-GRP.mkv",
matchedTorrentName: "Horror.Collection.2020",
matchedContentPath: "/movies/Horror.Collection.2020",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Pulse.2001.1080p-GRP.mkv", Size: 4 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "Horror.Collection.2020/Pulse.2001.mkv", Size: 4 << 30},
{Name: "Horror.Collection.2020/Ring.2002.mkv", Size: 4 << 30},
{Name: "Horror.Collection.2020/Grudge.2004.mkv", Size: 4 << 30},
},
wantPath: "/movies",
description: "Loose movie uses SavePath, Subfolder layout creates folder",
},
// C2: Single movie seeded (with folder), match collection
// Seeding: Pulse.2001-GRP/Pulse.mkv
// Match: Horror.Collection/Pulse.mkv, Ring.mkv, ...
// Note: Different roots, so we point to candidate's folder. File renaming aligns names.
{
name: "C2: movie with folder seeded, match collection",
newTorrentName: "Horror.Collection.2020",
matchedTorrentName: "Pulse.2001.1080p-GRP",
matchedContentPath: "/movies/Pulse.2001.1080p-GRP",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-contains",
sourceFiles: qbt.TorrentFiles{
{Name: "Horror.Collection.2020/Pulse.2001.mkv", Size: 4 << 30},
{Name: "Horror.Collection.2020/Ring.2002.mkv", Size: 4 << 30},
},
candidateFiles: qbt.TorrentFiles{{Name: "Pulse.2001.1080p-GRP/Pulse.mkv", Size: 4 << 30}},
wantPath: "/movies",
description: "Collection points to existing movie folder, file renaming aligns",
},
// C3: Collection seeded, match single movie (with folder)
{
name: "C3: collection seeded, match movie with folder",
newTorrentName: "Pulse.2001.1080p-GRP",
matchedTorrentName: "Horror.Collection.2020",
matchedContentPath: "/movies/Horror.Collection.2020",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Pulse.2001.1080p-GRP/movie.mkv", Size: 4 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "Horror.Collection.2020/Pulse.2001.mkv", Size: 4 << 30},
{Name: "Horror.Collection.2020/Ring.2002.mkv", Size: 4 << 30},
},
wantPath: "/movies/Horror.Collection.2020",
description: "Movie with folder placed inside collection",
},
// ============================================================
// EDGE CASES
// ============================================================
// E1: Multi-file movie with extras, match single file
{
name: "E1: movie with extras, match main file only",
newTorrentName: "The.Movie.2020-GRP",
matchedTorrentName: "The.Movie.2020-OTHER",
matchedContentPath: "/movies/The.Movie.2020-OTHER",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.2020-GRP/movie.mkv", Size: 5 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Movie.2020-OTHER/movie.mkv", Size: 5 << 30},
{Name: "The.Movie.2020-OTHER/Sample/sample.mkv", Size: 50 << 20},
{Name: "The.Movie.2020-OTHER/Extras/behind_scenes.mkv", Size: 500 << 20},
},
wantPath: "/movies/The.Movie.2020-OTHER",
description: "Main movie file matches, extras ignored",
},
// E2: Nested folders in source
{
name: "E2: nested folder structure",
newTorrentName: "Movie.Pack.2020",
matchedTorrentName: "The.Movie.2020-GRP",
matchedContentPath: "/movies/The.Movie.2020-GRP",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{
{Name: "Movie.Pack.2020/The.Movie.2020/movie.mkv", Size: 5 << 30},
},
candidateFiles: qbt.TorrentFiles{
{Name: "The.Movie.2020-GRP/movie.mkv", Size: 5 << 30},
},
wantPath: "/movies/The.Movie.2020-GRP",
description: "Nested source structure matched to flat candidate",
},
// E3: Unicode/special characters in folder names
{
name: "E3: special characters in names",
newTorrentName: "Amélie.2001.1080p-GRP",
matchedTorrentName: "Amélie (2001) [1080p]",
matchedContentPath: "/movies/Amélie (2001) [1080p]",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Amélie.2001.1080p-GRP/movie.mkv", Size: 4 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Amélie (2001) [1080p]/movie.mkv", Size: 4 << 30}},
wantPath: "/movies/Amélie (2001) [1080p]",
description: "Unicode characters handled correctly",
},
// E4: Very long folder names
{
name: "E4: long folder names",
newTorrentName: "The.Movie.With.A.Very.Long.Title.That.Goes.On.And.On.2020.1080p.BluRay.x264.DTS-HD.MA.7.1-VERYLONGGROUP",
matchedTorrentName: "Movie Long Title (2020)",
matchedContentPath: "/movies/Movie Long Title (2020)",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "The.Movie.With.A.Very.Long.Title.That.Goes.On.And.On.2020.1080p.BluRay.x264.DTS-HD.MA.7.1-VERYLONGGROUP/movie.mkv", Size: 20 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie Long Title (2020)/movie.mkv", Size: 20 << 30}},
wantPath: "/movies/Movie Long Title (2020)",
description: "Long folder names handled correctly",
},
// E5: Prevent infinite recursion - matched torrent already in root-named folder
{
name: "E5: prevent infinite recursion when save path already ends with candidate root",
newTorrentName: "Show.S01E01.720p.HDTV.x264-GROUP",
matchedTorrentName: "Show.S01E01.1080p.WEB-DL.x264-OTHER",
matchedContentPath: "/data/media/Show/Season 01/Show.S01E01.1080p.WEB-DL.x264-OTHER",
baseSavePath: "/data/media/Show/Season 01/Show.S01E01.1080p.WEB-DL.x264-OTHER", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E01.720p.HDTV.x264-GROUP/ep.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01E01.1080p.WEB-DL.x264-OTHER/ep.mkv", Size: 1 << 30}},
wantPath: "/data/media/Show/Season 01/Show.S01E01.1080p.WEB-DL.x264-OTHER",
description: "Save path already ends with candidate root, don't append again",
},
// E6: Deep nesting prevention - multiple levels of cross-seeding
{
name: "E6: prevent deep nesting from chained cross-seeds",
newTorrentName: "Movie.2020.480p.WEB.x264-GROUP",
matchedTorrentName: "Movie.2020.1080p.BluRay.x264-OTHER",
matchedContentPath: "/movies/Movie.2020.1080p.BluRay.x264-OTHER/Movie.2020.720p.WEB.x264-SOME",
baseSavePath: "/movies/Movie.2020.1080p.BluRay.x264-OTHER/Movie.2020.720p.WEB.x264-SOME", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.2020.480p.WEB.x264-GROUP/movie.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie.2020.720p.WEB.x264-SOME/movie.mkv", Size: 1 << 30}},
wantPath: "/movies/Movie.2020.1080p.BluRay.x264-OTHER/Movie.2020.720p.WEB.x264-SOME",
description: "Even with deep nesting in save path, don't append candidate root again",
},
// E7: Partial-in-pack with pre-existing root folder
{
name: "E7: partial-in-pack single file into already-rooted folder",
newTorrentName: "Episode.S01E01.1080p-GROUP.mkv",
matchedTorrentName: "Season.S01.1080p.BluRay.x264-OTHER",
matchedContentPath: "/tv/Season.S01.1080p.BluRay.x264-OTHER",
baseSavePath: "/tv/Season.S01.1080p.BluRay.x264-OTHER", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Episode.S01E01.1080p-GROUP.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Season.S01.1080p.BluRay.x264-OTHER/ep1.mkv", Size: 1 << 30}},
wantPath: "/tv/Season.S01.1080p.BluRay.x264-OTHER",
description: "Single file into season pack folder that's already named after root",
},
// E8: Cross-seed chain - episode from season pack that's in episode folder
{
name: "E8: episode from season pack in episode-named folder",
newTorrentName: "Show.S01E02.720p.HDTV.x264-GROUP",
matchedTorrentName: "Show.S01.1080p.BluRay.x264-OTHER",
matchedContentPath: "/tv/Show.S01E01.1080p.WEB.x264-SOME",
baseSavePath: "/tv/Show.S01E01.1080p.WEB.x264-SOME", contentLayout: "Original",
matchType: "partial-contains",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E02.720p.HDTV.x264-GROUP/ep.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{
{Name: "Show.S01.1080p.BluRay.x264-OTHER/ep1.mkv", Size: 1 << 30},
{Name: "Show.S01.1080p.BluRay.x264-OTHER/ep2.mkv", Size: 1 << 30},
},
wantPath: "/tv/Show.S01E01.1080p.WEB.x264-SOME",
description: "Season pack in episode folder should not create new subfolder",
},
// E9: Complex nesting with collection
{
name: "E9: movie from collection in deeply nested path",
newTorrentName: "Movie.A.2020.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Horror.Collection.2020",
matchedContentPath: "/movies/Collections/Horror.2020/Horror.Collection.2020",
baseSavePath: "/movies/Collections/Horror.2020/Horror.Collection.2020", contentLayout: "Original",
matchType: "partial-in-pack",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.A.2020.1080p.BluRay.x264-GROUP/movie.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Horror.Collection.2020/Movie.A.mkv", Size: 1 << 30}},
wantPath: "/movies/Collections/Horror.2020/Horror.Collection.2020",
description: "Collection in nested path should not add another level",
},
// E10: Root folder with special characters already in path
{
name: "E10: special chars root already in complex path",
newTorrentName: "Show.S01E01.720p.HDTV.x264-GROUP",
matchedTorrentName: "Show.S01E01.[1080p].WEB.x264-OTHER",
matchedContentPath: "/tv/Shows/Season 01/Show.S01E01.[1080p].WEB.x264-OTHER",
baseSavePath: "/tv/Shows/Season 01/Show.S01E01.[1080p].WEB.x264-OTHER", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.S01E01.720p.HDTV.x264-GROUP/ep.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.S01E01.[1080p].WEB.x264-OTHER/ep.mkv", Size: 1 << 30}},
wantPath: "/tv/Shows/Season 01/Show.S01E01.[1080p].WEB.x264-OTHER",
description: "Special characters in root folder name already in path",
},
// E11: Empty save path (edge case)
{
name: "E11: empty save path fallback",
newTorrentName: "Movie.2020.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Movie.2020.720p.WEB.x264-OTHER",
matchedContentPath: "",
baseSavePath: "",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.2020.1080p.BluRay.x264-GROUP/movie.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie.2020.720p.WEB.x264-OTHER/movie.mkv", Size: 1 << 30}},
wantPath: "",
description: "Empty save path should be returned as-is",
},
// E12: Root folder with numbers and symbols
{
name: "E12: numeric and symbolic root folders",
newTorrentName: "Show.2025.S01.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Show.2025.S01.720p.WEB.x264-OTHER",
matchedContentPath: "/tv/Show (2025) - Season 1",
baseSavePath: "/tv", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Show.2025.S01.1080p.BluRay.x264-GROUP/ep1.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Show.2025.S01.720p.WEB.x264-OTHER/ep1.mkv", Size: 1 << 30}},
wantPath: "/tv/Show.2025.S01.720p.WEB.x264-OTHER",
description: "Numeric season folders with different naming conventions",
},
// E13: Very deep nested paths
{
name: "E13: extremely deep nested paths",
newTorrentName: "Movie.2020.1080p.BluRay.x264-GROUP",
matchedTorrentName: "Movie.2020.720p.WEB.x264-OTHER",
matchedContentPath: "/media/movies/action/2020/sci-fi/Movie.2020.720p.WEB.x264-OTHER",
baseSavePath: "/media/movies/action/2020/sci-fi", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "Movie.2020.1080p.BluRay.x264-GROUP/movie.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "Movie.2020.720p.WEB.x264-OTHER/movie.mkv", Size: 1 << 30}},
wantPath: "/media/movies/action/2020/sci-fi/Movie.2020.720p.WEB.x264-OTHER",
description: "Deeply nested directory structures",
},
// E14: Case sensitivity differences
{
name: "E14: case differences in root folders",
newTorrentName: "MOVIE.2020.1080P.BLU-RAY.X264-GROUP",
matchedTorrentName: "movie.2020.720p.web.x264-other",
matchedContentPath: "/movies/movie.2020.720p.web.x264-other",
baseSavePath: "/movies", contentLayout: "Original",
matchType: "exact",
sourceFiles: qbt.TorrentFiles{{Name: "MOVIE.2020.1080P.BLU-RAY.X264-GROUP/movie.mkv", Size: 1 << 30}},
candidateFiles: qbt.TorrentFiles{{Name: "movie.2020.720p.web.x264-other/movie.mkv", Size: 1 << 30}},