}
// Retrieves an Episode by its EID.
+//
+// If we know which AID owns this EID, then it's equivalent
+// to an Anime query. Otherwise, uses both the HTTP and UDP
+// APIs to retrieve it.
func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode {
keys := []cacheKey{"eid", eid}
ch := make(chan *Episode, 1)
if id, err := strconv.ParseInt(parts[1], 10, 32); err == nil {
ok = true
aid = AID(id)
+ } else {
+ break
}
} else if reply.Code() == 340 {
cache.MarkInvalid(keys...)
+ cache.Delete(keys...) // deleted EID?
+ break
} else {
break
}
e = ep
break
} else {
- // if this is somehow still a miss, then the EID<->AID map broke
- cache.Delete("aid", "by-eid", eid)
- ok = false
+ // check to see if we looked in the right AID
+ found := false
+ if a != nil {
+ for _, ep := range a.Episodes {
+ if eid == ep.EID {
+ found = true
+ break
+ }
+ }
+ }
+
+ // if found, then it's just that the anime is also stale (offline?)
+ if found {
+ break
+ } else {
+ // otherwise, the EID<->AID map broke
+ ok = false
+ cache.Delete("aid", "by-eid", eid)
+ }
}
}
intentMap.Notify(e, keys...)