mirror of
https://github.com/JackDallas/Premiumizearr.git
synced 2026-01-04 11:53:29 +01:00
Compare commits
1 Commits
5bd56bddb3
...
v1.2.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ec08b5f4a |
@@ -5,7 +5,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/jackdallas/premiumizearr/internal/utils"
|
||||
"github.com/jackdallas/premiumizearr/pkg/premiumizeme"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golift.io/starr"
|
||||
@@ -84,14 +83,12 @@ func (arr *RadarrArr) HistoryContains(name string) (int64, bool) {
|
||||
log.Errorf("Radarr [%s]: Failed to get history: %+v", arr.Name, err)
|
||||
return -1, false
|
||||
}
|
||||
log.Trace("Radarr [%s]: Got History, now Locking History", arr.Name)
|
||||
log.Tracef("Radarr [%s]: Got History, now Locking History", arr.Name)
|
||||
arr.HistoryMutex.Lock()
|
||||
defer arr.HistoryMutex.Unlock()
|
||||
|
||||
name = utils.StripDownloadTypesExtention(name)
|
||||
// name = strings.ReplaceAll(name, ".", " ")
|
||||
for _, item := range his.Records {
|
||||
if utils.StripDownloadTypesExtention(item.SourceTitle) == name || item.SourceTitle == name {
|
||||
if CompareFileNamesFuzzy(item.SourceTitle, name) {
|
||||
return item.ID, true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/jackdallas/premiumizearr/internal/utils"
|
||||
"github.com/jackdallas/premiumizearr/pkg/premiumizeme"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"golift.io/starr"
|
||||
@@ -82,17 +81,16 @@ func (arr *SonarrArr) HistoryContains(name string) (int64, bool) {
|
||||
if err != nil {
|
||||
return 0, false
|
||||
}
|
||||
log.Trace("Sonarr [%s]: Got History, now Locking History")
|
||||
log.Tracef("Sonarr [%s]: Got History, now Locking History", arr.Name)
|
||||
arr.HistoryMutex.Lock()
|
||||
defer arr.HistoryMutex.Unlock()
|
||||
|
||||
name = utils.StripDownloadTypesExtention(name)
|
||||
for _, item := range his.Records {
|
||||
if utils.StripDownloadTypesExtention(item.SourceTitle) == name || item.SourceTitle == name {
|
||||
if CompareFileNamesFuzzy(item.SourceTitle, name) {
|
||||
return item.ID, true
|
||||
}
|
||||
}
|
||||
log.Tracef("Sonarr [%s]: %s Not in History", name)
|
||||
log.Tracef("Sonarr [%s]: %s Not in History", arr.Name, name)
|
||||
|
||||
return -1, false
|
||||
}
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
package arr
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/jackdallas/premiumizearr/internal/utils"
|
||||
"github.com/jackdallas/premiumizearr/pkg/premiumizeme"
|
||||
"golift.io/starr/radarr"
|
||||
"golift.io/starr/sonarr"
|
||||
)
|
||||
|
||||
func CompareFileNamesFuzzy(a, b string) bool {
|
||||
//strip file extension
|
||||
a = utils.StripDownloadTypesExtention(a)
|
||||
b = utils.StripDownloadTypesExtention(b)
|
||||
//Replace spaces with periods
|
||||
a = strings.ReplaceAll(a, " ", ".")
|
||||
b = strings.ReplaceAll(b, " ", ".")
|
||||
|
||||
return a == b
|
||||
}
|
||||
|
||||
type IArr interface {
|
||||
HistoryContains(string) (int64, bool)
|
||||
MarkHistoryItemAsFailed(int64) error
|
||||
|
||||
Reference in New Issue
Block a user