media: add ImdbVotes field to Omdb struct

This commit is contained in:
James Bayliss
2021-02-15 20:06:42 +00:00
parent aadc5ece4f
commit 495c5a5c1a
3 changed files with 2 additions and 1 deletions

View File

@@ -68,5 +68,6 @@ func (c *Client) GetItem(imdbId string) (*Item, error) {
Metascore: util.Atoi(b.Metascore, 0),
RottenTomatoes: rt,
ImdbRating: util.Atof64(b.ImdbRating, 0.0),
ImdbVotes: util.Atoi(b.ImdbVotes, 0),
}, nil
}

View File

@@ -37,4 +37,5 @@ type Item struct {
Metascore int `json:"Metascore,omitempty"`
RottenTomatoes int `json:"RottenTomatoes,omitempty"`
ImdbRating float64 `json:"ImdbRating,omitempty"`
ImdbVotes int `json:"ImdbVotes,omitempty"`
}

View File

@@ -9,6 +9,5 @@ func AsSHA256(o interface{}) string {
// credits: https://blog.8bitzen.com/posts/22-08-2019-how-to-hash-a-struct-in-go
h := sha256.New()
h.Write([]byte(fmt.Sprintf("%v", o)))
return fmt.Sprintf("%x", h.Sum(nil))
}