]> git.lizzy.rs Git - go-anidb.git/commitdiff
anidb: Add (*Anime).EpisodeByEID
authorDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Tue, 16 Jul 2013 15:58:52 +0000 (12:58 -0300)
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Tue, 16 Jul 2013 15:58:52 +0000 (12:58 -0300)
Also remove redundant type Episodes []*Episode -- the Episodes type
didn't have any methods.

anime.go
episode.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
+}
index 80b2b4775a1e87c7e5e53cfa199df85d438a0867..9505f3c1bb0653c9898f753d16651d52fa4c145b 100644 (file)
@@ -21,5 +21,3 @@ type Episode struct {
 
        Cached time.Time // When the data was retrieved from the server
 }
-
-type Episodes []*Episode