mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 13:56:37 +08:00
优化动漫刮削
This commit is contained in:
@@ -8,6 +8,27 @@ import (
|
||||
)
|
||||
|
||||
func (s *ScraperService) lookupAutomaticTMDb(ctx context.Context, kind, query string, year int) *Match {
|
||||
if match := s.lookupAutomaticTMDbPrimary(ctx, kind, query, year); match != nil {
|
||||
return match
|
||||
}
|
||||
fallbackKind := ""
|
||||
normalized := normalizeOrganizeMediaType(kind)
|
||||
if normalized == "anime" {
|
||||
if isTVMetadataKind(kind) {
|
||||
fallbackKind = "movie"
|
||||
} else {
|
||||
fallbackKind = "tv"
|
||||
}
|
||||
}
|
||||
if fallbackKind != "" {
|
||||
if fbMatch := s.lookupAutomaticTMDbPrimary(ctx, fallbackKind, query, year); fbMatch != nil {
|
||||
return fbMatch
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ScraperService) lookupAutomaticTMDbPrimary(ctx context.Context, kind, query string, year int) *Match {
|
||||
var (
|
||||
candidates []*Match
|
||||
err error
|
||||
@@ -175,8 +196,10 @@ func metadataMatchCompatibleWithType(expectedType string, match *Match) bool {
|
||||
return true
|
||||
}
|
||||
switch expectedType {
|
||||
case "tv", "anime", "variety":
|
||||
case "tv", "variety":
|
||||
return matchType == "tv" || matchType == "anime" || matchType == "variety"
|
||||
case "anime":
|
||||
return matchType == "anime" || matchType == "tv" || matchType == "movie" || matchType == "variety"
|
||||
case "movie", "adult":
|
||||
return matchType == "movie" || matchType == "adult"
|
||||
default:
|
||||
@@ -184,6 +207,16 @@ func metadataMatchCompatibleWithType(expectedType string, match *Match) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func metadataMatchCompatibleWithTheatrical(expectedType string, isTheatrical bool, match *Match) bool {
|
||||
if isTheatrical &&
|
||||
normalizeOrganizeMediaType(expectedType) == "movie" &&
|
||||
match != nil &&
|
||||
normalizeOrganizeMediaType(match.MediaType) == "anime" {
|
||||
return true
|
||||
}
|
||||
return metadataMatchCompatibleWithType(expectedType, match)
|
||||
}
|
||||
|
||||
func queryNeedsEnglishTMDbFallback(query string) bool {
|
||||
for _, r := range query {
|
||||
if (r >= 'a' && r <= 'z') || (r >= 'A' && r <= 'Z') {
|
||||
|
||||
Reference in New Issue
Block a user