refactor: extract parseAirType from parseMeta
This commit is contained in:
@@ -239,15 +239,8 @@ func parseMeta(meta string) (episodeText string, localTime string, airType AirTy
|
|||||||
}
|
}
|
||||||
|
|
||||||
localTime = strings.TrimSpace(parts[timeIdx] + " " + parts[timeIdx+1])
|
localTime = strings.TrimSpace(parts[timeIdx] + " " + parts[timeIdx+1])
|
||||||
typeRaw := strings.TrimSpace(parts[timeIdx+2])
|
airType, ok := parseAirType(parts[timeIdx+2])
|
||||||
switch strings.ToUpper(typeRaw) {
|
if !ok {
|
||||||
case "JPN":
|
|
||||||
airType = AirTypeJPN
|
|
||||||
case "SUB":
|
|
||||||
airType = AirTypeSUB
|
|
||||||
case "DUB":
|
|
||||||
airType = AirTypeDUB
|
|
||||||
default:
|
|
||||||
return "", "", ""
|
return "", "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +248,19 @@ func parseMeta(meta string) (episodeText string, localTime string, airType AirTy
|
|||||||
return episodeText, localTime, airType
|
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 {
|
func preferredReleaseEntries(entries []Entry) []Entry {
|
||||||
type keyedEntry struct {
|
type keyedEntry struct {
|
||||||
index int
|
index int
|
||||||
|
|||||||
Reference in New Issue
Block a user