summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wikiarticle.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/wikiarticle.go b/src/wikiarticle.go
index cef9f02..c1ce486 100644
--- a/src/wikiarticle.go
+++ b/src/wikiarticle.go
@@ -234,32 +234,34 @@ func extractPeople(article map[string]interface{}) []wikiPerson {
people = append(people, extractPersonFromField(fp, 3)...)
}
}
-
// Actors from Cast section
for _, sec := range getSections(article) {
s, ok := sec.(map[string]interface{})
if !ok || s["name"] != "Cast" {
continue
}
- for _, part := range s["has_parts"].([]interface{}) {
- p, ok := part.(map[string]interface{})
- if !ok || p["type"] != "list" {
- continue
- }
- for _, item := range p["has_parts"].([]interface{}) {
- item, ok := item.(map[string]interface{})
- if !ok {
+ if hp, ok := s["has_parts"].([]interface{}); ok {
+ for _, part := range hp {
+ p, ok := part.(map[string]interface{})
+ if !ok || p["type"] != "list" {
continue
}
- if link, ok := getFirstPersonLink(item); ok {
- people = append(people, wikiPerson{Name: link, Profession: 1})
+ if items, ok := p["has_parts"].([]interface{}); ok {
+ for _, item := range items {
+ item, ok := item.(map[string]interface{})
+ if !ok {
+ continue
+ }
+ if link, ok := getFirstPersonLink(item); ok {
+ people = append(people, wikiPerson{Name: link, Profession: 1})
+ }
+ }
}
+ break // only first list in Cast section
}
- break // only first list in Cast section
}
break // only Cast section
}
-
return people
}
@@ -281,7 +283,10 @@ func getInfoboxParts(article map[string]interface{}) []interface{} {
if !ok {
return nil
}
- return section["has_parts"].([]interface{})
+ if hp, ok := section["has_parts"].([]interface{}); ok {
+ return hp
+ }
+ return nil
}
// getSections returns sections from the article.