From: Diogo Franco (Kovensky) Date: Thu, 25 Jul 2013 21:12:12 +0000 (-0300) Subject: anidb: Add shortcut cache querying functions X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b5c4867ce8ddfee4947035afdd90bec82d0474ff;p=go-anidb.git anidb: Add shortcut cache querying functions For instance (*File).Anime() instead of (*File).AID.Anime(). --- diff --git a/episode.go b/episode.go index 9505f3c..581f516 100644 --- a/episode.go +++ b/episode.go @@ -21,3 +21,7 @@ type Episode struct { Cached time.Time // When the data was retrieved from the server } + +func (ep *Episode) Anime() *Anime { + return ep.AID.Anime() +} diff --git a/file.go b/file.go index 08da122..d80a192 100644 --- a/file.go +++ b/file.go @@ -74,6 +74,22 @@ type File struct { Cached time.Time } +func (f *File) Anime() *Anime { + return f.AID.Anime() +} + +func (f *File) Episode() *Episode { + return f.EID.Episode() +} + +func (f *File) Group() *Group { + return f.GID.Group() +} + +func (f *File) MyList() { + _ = f.LID[0] +} + type RelatedEpisodes map[EID]float32 func (er RelatedEpisodes) MarshalJSON() ([]byte, error) { diff --git a/mylist.go b/mylist.go index de3e187..d65d9f4 100644 --- a/mylist.go +++ b/mylist.go @@ -53,3 +53,19 @@ type MyListEntry struct { Cached time.Time } + +func (e *MyListEntry) File() *File { + return e.FID.File() +} + +func (e *MyListEntry) Episode() *Episode { + return e.EID.Episode() +} + +func (e *MyListEntry) Anime() *Anime { + return e.AID.Anime() +} + +func (e *MyListEntry) Group() *Group { + return e.GID.Group() +}