mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-05 21:06:38 +08:00
fix media organize and subscription workflows
This commit is contained in:
@@ -14,7 +14,7 @@ func matchesSubscriptionRules(sub *model.Subscription, title string) bool {
|
||||
if sub == nil {
|
||||
return true
|
||||
}
|
||||
if shouldApplyDefaultCompatibilityExcludes(sub.ExcludeWords) && containsAnyExcludeToken(titleFold, defaultCompatibilityExcludeWords) {
|
||||
if compatibilityExcludes := defaultCompatibilityExcludesForSubscription(sub); compatibilityExcludes != "" && containsAnyExcludeToken(titleFold, compatibilityExcludes) {
|
||||
return false
|
||||
}
|
||||
if sub.ExcludeWords != "" && containsAnyExcludeToken(titleFold, sub.ExcludeWords) {
|
||||
@@ -35,13 +35,42 @@ func matchesSubscriptionRules(sub *model.Subscription, title string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func shouldApplyDefaultCompatibilityExcludes(excludeWords string) bool {
|
||||
normalized := normalizeExcludeWords(excludeWords)
|
||||
return normalized == "" || normalized == normalizeExcludeWords(legacyFrontendExcludeWords)
|
||||
func defaultCompatibilityExcludesForSubscription(sub *model.Subscription) string {
|
||||
if sub == nil {
|
||||
return defaultCompatibilityExcludeWords
|
||||
}
|
||||
requested := strings.ToLower(strings.Join([]string{sub.Effects, sub.Quality}, ","))
|
||||
if strings.TrimSpace(requested) == "" {
|
||||
return defaultCompatibilityExcludeWords
|
||||
}
|
||||
tokens := excludeWordTokens(defaultCompatibilityExcludeWords)
|
||||
out := make([]string, 0, len(tokens))
|
||||
for _, token := range tokens {
|
||||
if token == "" || compatibilityTokenRequested(requested, token) {
|
||||
continue
|
||||
}
|
||||
out = append(out, token)
|
||||
}
|
||||
return strings.Join(out, ",")
|
||||
}
|
||||
|
||||
func normalizeExcludeWords(csv string) string {
|
||||
return strings.Join(excludeWordTokens(csv), ",")
|
||||
func compatibilityTokenRequested(requested, token string) bool {
|
||||
switch token {
|
||||
case "dovi", "dv", "dolby vision", "杜比视界":
|
||||
return containsAnyEffect(requested, "dolby-vision") || containsAnyToken(requested, "dovi,dv,dolby vision,杜比视界")
|
||||
case "dolby", "杜比":
|
||||
return containsAnyEffect(requested, "dolby-vision") || containsAnyToken(requested, "dolby,dolby vision,杜比,杜比视界,atmos,dolby atmos,杜比全景声")
|
||||
case "atmos":
|
||||
return containsAnyToken(requested, "atmos,dolby atmos,杜比全景声")
|
||||
case "h265", "h.265", "h-265", "h_265", "h 265", "hevc", "x265":
|
||||
return containsAnyToken(requested, "h265,h.265,h-265,h_265,h 265,hevc,x265")
|
||||
case "10bit", "10-bit", "10 bit", "hi10p":
|
||||
return containsAnyToken(requested, "10bit,10-bit,10 bit,hi10p")
|
||||
case "truehd", "ddp", "dd+", "eac3":
|
||||
return containsAnyToken(requested, "truehd,ddp,dd+,eac3")
|
||||
default:
|
||||
return containsAnyToken(requested, token)
|
||||
}
|
||||
}
|
||||
|
||||
func isSubscriptionSeriesType(mediaType string) bool {
|
||||
@@ -52,3 +81,24 @@ func isSubscriptionSeriesType(mediaType string) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func subscriptionAllowsWash(sub *model.Subscription) bool {
|
||||
if sub == nil || !sub.WashEnabled {
|
||||
return false
|
||||
}
|
||||
return subscriptionHasExplicitUpgradeCriteria(sub)
|
||||
}
|
||||
|
||||
func subscriptionHasExplicitUpgradeCriteria(sub *model.Subscription) bool {
|
||||
if sub == nil {
|
||||
return false
|
||||
}
|
||||
if value := strings.TrimSpace(strings.ToLower(sub.Resolution)); value != "" && value != "best" {
|
||||
return true
|
||||
}
|
||||
if value := strings.TrimSpace(strings.ToLower(sub.Quality)); value != "" && value != "best" {
|
||||
return true
|
||||
}
|
||||
return strings.TrimSpace(sub.Effects) != "" ||
|
||||
strings.TrimSpace(sub.ReleaseGroups) != ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user