Save when its complete

This commit is contained in:
Ben Sarmiento
2024-02-17 02:23:38 +01:00
parent 95882ace3f
commit 586466ce80
2 changed files with 17 additions and 13 deletions

View File

@@ -220,7 +220,13 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
return false return false
} }
if filter.HasEpisodes { if filter.HasEpisodes {
regex := regexp.MustCompile(`(?i)s\d{2,3}.?e\d{2,3}`) regexes := []*regexp.Regexp{
regexp.MustCompile(`(?i)s\d\d\d?.?e\d\d\d?`),
regexp.MustCompile(`(?i)seasons?\s?\d+`),
regexp.MustCompile(`(?i)episodes?\s?\d+`),
regexp.MustCompile(`(?i)[a-fA-F0-9]{8}`),
}
for _, regex := range regexes {
if regex.MatchString(torrentName) { if regex.MatchString(torrentName) {
return true return true
} }
@@ -229,8 +235,9 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torren
return true return true
} }
} }
}
//remove resolution from filenames //remove resolution from filenames
regex = regexp.MustCompile(`(?i)((720|1080|2160|480|360|240|144)[pi]|\d{3,4}x\d{3,4})`) regex := regexp.MustCompile(`(?i)((720|1080|2160|480|360|240|144)[pi]|\d{3,4}x\d{3,4})`)
for i, filename := range fileNames { for i, filename := range fileNames {
fileNames[i] = regex.ReplaceAllString(filename, "") fileNames[i] = regex.ReplaceAllString(filename, "")
} }

View File

@@ -220,16 +220,13 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
} }
torrent.DownloadedIDs = mapset.NewSet[string]() torrent.DownloadedIDs = mapset.NewSet[string]()
torrent.InProgressIDs = mapset.NewSet[string]() torrent.InProgressIDs = mapset.NewSet[string]()
if info.Progress == 100 { if rdTorrent.Progress == 100 {
torrent.DownloadedIDs.Add(info.ID) torrent.DownloadedIDs.Add(info.ID)
} else {
torrent.InProgressIDs.Add(info.ID)
}
// save to cache if it's not in progress anymore // save to cache if it's not in progress anymore
if info.Progress == 100 {
infoCache.Set(rdTorrent.ID, &torrent) infoCache.Set(rdTorrent.ID, &torrent)
t.saveTorrentChangesToDisk(&torrent, nil) t.saveTorrentChangesToDisk(&torrent, nil)
} else {
torrent.InProgressIDs.Add(info.ID)
} }
return &torrent return &torrent