Commit b1f77c3661
Unsigned
Layout: unified · split
internal/curd.go +31 −3
| @@ -1203,6 +1203,11 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 1203 | 1203 | found = true |
| 1204 | 1204 | } else if bestMatch != nil { |
| 1205 | 1205 | Log(fmt.Sprintf("Highest match score was %d (needed 100 for Animepahe exact meta tag match). Not selecting automatically to prevent false positives.", highestScore)) |
| 1206 | if confirmProviderMatch(*bestMatch, "Animepahe metadata") { | |
| 1207 | anime.ProviderId = bestMatch.Key | |
| 1208 | Log(fmt.Sprintf("User confirmed Animepahe match. Setting ProviderId to: %s", anime.ProviderId)) | |
| 1209 | found = true | |
| 1210 | } | |
| 1206 | 1211 | } |
| 1207 | 1212 | } |
| 1208 | 1213 | |
| @@ -1211,9 +1216,11 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 1211 | 1216 | targetLabel := fmt.Sprintf("%v (%d episodes)", userQuery, selectedAnilistAnime.Media.Episodes) |
| 1212 | 1217 | for _, option := range animeList { |
| 1213 | 1218 | if fmt.Sprintf("%s (%d episodes)", option.Title, selectedAnilistAnime.Media.Episodes) == targetLabel { |
| 1214 | anime.ProviderId = option.Key | |
| 1215 | Log(fmt.Sprintf("Found exact text match! Setting ProviderId to: %s", anime.ProviderId)) | |
| 1216 | found = true | |
| 1219 | if confirmProviderMatch(option, "title and episode count") { | |
| 1220 | anime.ProviderId = option.Key | |
| 1221 | Log(fmt.Sprintf("User confirmed exact text match. Setting ProviderId to: %s", anime.ProviderId)) | |
| 1222 | found = true | |
| 1223 | } | |
| 1217 | 1224 | break |
| 1218 | 1225 | } |
| 1219 | 1226 | } |
| @@ -1468,6 +1475,27 @@ func WriteTokenToFile(token string, filePath string) error { | ||
| 1468 | 1475 | return nil |
| 1469 | 1476 | } |
| 1470 | 1477 | |
| 1478 | func confirmProviderMatch(option SelectionOption, reason string) bool { | |
| 1479 | label := option.Label | |
| 1480 | if label == "" { | |
| 1481 | label = option.Title | |
| 1482 | } | |
| 1483 | if label == "" { | |
| 1484 | label = option.Key | |
| 1485 | } | |
| 1486 | ||
| 1487 | CurdOut(fmt.Sprintf("Provider match found by %s: %s", reason, label)) | |
| 1488 | selected, err := DynamicSelect([]SelectionOption{ | |
| 1489 | {Key: "use", Label: "Use this match"}, | |
| 1490 | {Key: "manual", Label: "Select manually"}, | |
| 1491 | }) | |
| 1492 | if err != nil { | |
| 1493 | Log(fmt.Sprintf("Error confirming provider match: %v", err)) | |
| 1494 | return false | |
| 1495 | } | |
| 1496 | return selected.Key == "use" | |
| 1497 | } | |
| 1498 | ||
| 1471 | 1499 | func StartCurd(userCurdConfig *CurdConfig, anime *Anime) string { |
| 1472 | 1500 | if err := resolveRuntimeProviderID(userCurdConfig, anime); err != nil { |
| 1473 | 1501 | Log(fmt.Sprintf("Failed to resolve provider id: %v", err)) |