refactor: extract parseAirType from parseMeta

This commit is contained in:
2026-06-11 12:09:57 +02:00
parent c70adbd0ec
commit 03ccd54c85

View File

@@ -239,15 +239,8 @@ func parseMeta(meta string) (episodeText string, localTime string, airType AirTy
}
localTime = strings.TrimSpace(parts[timeIdx] + " " + parts[timeIdx+1])
typeRaw := strings.TrimSpace(parts[timeIdx+2])
switch strings.ToUpper(typeRaw) {
case "JPN":
airType = AirTypeJPN
case "SUB":
airType = AirTypeSUB
case "DUB":
airType = AirTypeDUB
default:
airType, ok := parseAirType(parts[timeIdx+2])
if !ok {
return "", "", ""
}
@@ -255,6 +248,19 @@ func parseMeta(meta string) (episodeText string, localTime string, airType AirTy
return episodeText, localTime, airType
}
func parseAirType(raw string) (AirType, bool) {
switch strings.ToUpper(strings.TrimSpace(raw)) {
case "JPN":
return AirTypeJPN, true
case "SUB":
return AirTypeSUB, true
case "DUB":
return AirTypeDUB, true
default:
return "", false
}
}
func preferredReleaseEntries(entries []Entry) []Entry {
type keyedEntry struct {
index int