From 447ade9a8655c32ee64f9201d388432afdc7779e Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Wed, 19 Apr 2017 22:40:59 +0200 Subject: [PATCH] Fix bad rating calculation --- iTunesParser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iTunesParser.py b/iTunesParser.py index b5e0a98..897773b 100644 --- a/iTunesParser.py +++ b/iTunesParser.py @@ -219,6 +219,7 @@ class ITunesParser: file_artist = io.open('es-artist-data.json', 'wb') for artist in self._artists: persistent_id = self._artists[artist]['Persistent ID'] + self._artists[artist]['Rating'] = round(self._artists[artist]['Rating']) json_track_index = { "index": {"_index": "itunessongs", "_type": "artist", "_id": persistent_id} } @@ -236,6 +237,7 @@ class ITunesParser: file_albums = io.open('es-albums-data.json', 'wb') for album in self._albums: persistent_id = self._albums[album]['Persistent ID'] + self._albums[album]['Rating'] = round(self._albums[album]['Rating']) json_track_index = { "index": {"_index": "itunessongs", "_type": "album", "_id": persistent_id} } @@ -250,7 +252,7 @@ class ITunesParser: """ Calculate average rating from a current rating, a rating value to add and the number of elements """ - return (current_rating * count + added_value) // (count + 1) + return (current_rating * count + added_value) / (count + 1) @classmethod def calc_id(cls, key):