From 495c5a5c1a9ea3ff419f1f98718f5b0ed152a152 Mon Sep 17 00:00:00 2001 From: James Bayliss Date: Mon, 15 Feb 2021 20:06:42 +0000 Subject: [PATCH] media: add ImdbVotes field to Omdb struct --- media/omdb/media.go | 1 + media/omdb/struct.go | 1 + util/hash.go | 1 - 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/media/omdb/media.go b/media/omdb/media.go index a689c2a..e5e2e58 100644 --- a/media/omdb/media.go +++ b/media/omdb/media.go @@ -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 } diff --git a/media/omdb/struct.go b/media/omdb/struct.go index e181950..99c36e6 100644 --- a/media/omdb/struct.go +++ b/media/omdb/struct.go @@ -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"` } diff --git a/util/hash.go b/util/hash.go index 16a2c20..5d6edd2 100644 --- a/util/hash.go +++ b/util/hash.go @@ -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)) }