]> git.lizzy.rs Git - go-anidb.git/blobdiff - anime.go
anidb: Add (*Anime).EpisodeByEID
[go-anidb.git] / anime.go
index fa43987dc5948c102242f2e607995692164b7ecd..5e5c4b7c997f6c2bb8623bdf1a6c78917f7b3441 100644 (file)
--- a/anime.go
+++ b/anime.go
@@ -70,7 +70,7 @@ type Anime struct {
        TemporaryVotes Rating // Votes from people who are still watching this.
        Reviews        Rating // Votes from reviewers.
 
-       Episodes Episodes // List of episodes.
+       Episodes []*Episode // List of episodes.
 
        Awards    []string
        Resources Resources
@@ -144,3 +144,15 @@ func (a *Anime) EpisodeByString(name string) *Episode {
 func (a *Anime) EpisodeByNumber(number int) *Episode {
        return a.EpisodeByString(strconv.Itoa(number))
 }
+
+func (a *Anime) EpisodeByEID(eid EID) *Episode {
+       if a == nil {
+               return nil
+       }
+       for _, ep := range a.Episodes {
+               if ep.EID == eid {
+                       return ep
+               }
+       }
+       return nil
+}