fix subscription episode range dedup

This commit is contained in:
ShukeBta
2026-06-26 15:20:48 +08:00
parent a7e7dcf764
commit f5e36c9a5c
2 changed files with 70 additions and 1 deletions
+12 -1
View File
@@ -10,6 +10,7 @@ import (
)
var torrentEpisodeToken = regexp.MustCompile(`(?i)e\d{1,3}`)
var downloadPackTitleToken = regexp.MustCompile(`(?i)(?:^|[\s._-])(?:complete|batch|pack|合集|全集|整季|全季)(?:[\s._-]|$)`)
func localAvailabilityTitleCandidates(title string) []string {
seen := map[string]struct{}{}
@@ -75,6 +76,9 @@ type downloadMediaIdentity struct {
func parseDownloadMediaIdentity(name string) downloadMediaIdentity {
title, year := CleanQuery(name)
if isSeriesPackTitle(name) {
title = downloadPackTitleToken.ReplaceAllString(title, " ")
}
titleKey := normalizeAvailabilityComparable(title)
if titleKey == "" {
titleKey = normalizeAvailabilityComparable(availabilityQuery(name, ""))
@@ -101,7 +105,7 @@ func downloadTitleCoversRequest(existing, requested string) bool {
if current.Year > 0 && want.Year > 0 && current.Year != want.Year {
return false
}
if current.Pack && len(current.Episodes) == 0 {
if downloadIdentityCoversWholeSeason(existing, current) {
return true
}
if len(current.Episodes) == 0 || len(want.Episodes) == 0 {
@@ -119,6 +123,13 @@ func downloadTitleCoversRequest(existing, requested string) bool {
return true
}
func downloadIdentityCoversWholeSeason(title string, identity downloadMediaIdentity) bool {
if !identity.Pack || len(identity.Episodes) > 0 {
return false
}
return seriesPackRE.MatchString(title)
}
func downloadMediaIdentityKey(name string) string {
name = strings.ToLower(strings.TrimSpace(name))
if name == "" {