From dfd1e4249321f123c901445cd7ed052e20214c2e Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Sun, 3 Apr 2022 09:57:48 +0300 Subject: [PATCH] Update Metadata.Rating struct My Plex server is returning an array of items as the rating. An example is `[{"image":"themoviedb://image.rating","type":"audience","value":"8.5"}]` This breaks GetSessions(). This change adds a struct to unmarshal a result array item into. --- models.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models.go b/models.go index 428426c..fcd6570 100644 --- a/models.go +++ b/models.go @@ -69,7 +69,7 @@ type Metadata struct { ParentThumb string `json:"parentThumb"` ParentTitle string `json:"parentTitle"` RatingCount string `json:"ratingCount"` - Rating float64 `json:"rating"` + Rating []Rating `json:"rating"` RatingKey string `json:"ratingKey"` SessionKey string `json:"sessionKey"` Summary string `json:"summary"` @@ -86,6 +86,12 @@ type Metadata struct { Writer []TaggedData `json:"Writer"` } +type Rating struct { + Image string `json:"image"` + Type string `json:"type"` + Value string `json:"value"` +} + // AltGUID represents a Globally Unique Identifier for a metadata provider that is not actively being used. type AltGUID struct { ID string `json:"id"`