Updated MAL sync

This commit is contained in:
Eduard Urbach 2018-11-01 08:31:11 +09:00
parent 9d57aaf12a
commit 007e2e90ec

View File

@ -25,7 +25,7 @@ func parseCharacterDescription(input string) (output string, attributes []*arn.C
var lastAttribute *arn.CharacterAttribute var lastAttribute *arn.CharacterAttribute
for _, line := range lines { for _, line := range lines {
line = strings.Replace(line, " (\n)", "", -1) // line = strings.Replace(line, " (\n)", "", -1)
// Remove all kinds of starting and ending parantheses. // Remove all kinds of starting and ending parantheses.
if strings.HasPrefix(line, "(") { if strings.HasPrefix(line, "(") {
@ -33,27 +33,27 @@ func parseCharacterDescription(input string) (output string, attributes []*arn.C
line = strings.TrimSuffix(line, ")") line = strings.TrimSuffix(line, ")")
} }
line = strings.TrimSuffix(line, " (") if !strings.Contains(line, ":") {
line = strings.TrimPrefix(line, ")") // Remove list indicators
line = strings.TrimPrefix(line, "- ")
line = strings.TrimPrefix(line, "* ")
parts := strings.Split(line, ":")
if len(parts) < 2 {
// Add to previous attribute // Add to previous attribute
if lastAttribute != nil { if lastAttribute != nil {
lastAttribute.Value += ", " + line if lastAttribute.Value != "" {
lastAttribute.Value += ", "
}
lastAttribute.Value += line
} }
continue continue
} }
parts := strings.Split(line, ":")
name := strings.TrimSpace(parts[0]) name := strings.TrimSpace(parts[0])
value := strings.TrimSpace(parts[1]) value := strings.TrimSpace(parts[1])
if value == "" || value == `"` {
continue
}
lastAttribute = &arn.CharacterAttribute{ lastAttribute = &arn.CharacterAttribute{
Name: name, Name: name,
Value: value, Value: value,