@@ -97,7 +97,7 @@ func (s Service) processSonarr(ctx context.Context, cfg *domain.ArrConfig, logge
97
97
98
98
logger .Debug ().Msgf ("found %d shows to process" , len (shows ))
99
99
100
- var titles [] string
100
+ titleSet := make ( map [ string ] struct {})
101
101
var monitoredTitles int
102
102
103
103
for _ , show := range shows {
@@ -129,17 +129,28 @@ func (s Service) processSonarr(ctx context.Context, cfg *domain.ArrConfig, logge
129
129
//titles = append(titles, rls.MustNormalize(s.Title))
130
130
//titles = append(titles, rls.MustClean(s.Title))
131
131
132
- titles = append (titles , processTitle (s .Title , cfg .MatchRelease )... )
132
+ titles := processTitle (s .Title , cfg .MatchRelease )
133
+ for _ , title := range titles {
134
+ titleSet [title ] = struct {}{}
135
+ }
133
136
134
137
if ! cfg .ExcludeAlternateTitles {
135
138
for _ , title := range s .AlternateTitles {
136
- titles = append (titles , processTitle (title .Title , cfg .MatchRelease )... )
139
+ altTitles := processTitle (title .Title , cfg .MatchRelease )
140
+ for _ , altTitle := range altTitles {
141
+ titleSet [altTitle ] = struct {}{}
142
+ }
137
143
}
138
144
}
139
145
}
140
146
141
- sort .Strings (titles )
142
- logger .Debug ().Msgf ("from a total of %d shows we found %d monitored and created %d release titles" , len (shows ), monitoredTitles , len (titles ))
147
+ uniqueTitles := make ([]string , 0 , len (titleSet ))
148
+ for title := range titleSet {
149
+ uniqueTitles = append (uniqueTitles , title )
150
+ }
151
+
152
+ sort .Strings (uniqueTitles )
153
+ logger .Debug ().Msgf ("from a total of %d shows we found %d monitored and created %d release titles" , len (shows ), monitoredTitles , len (uniqueTitles ))
143
154
144
- return titles , nil
155
+ return uniqueTitles , nil
145
156
}
0 commit comments