diff --git a/iTunesParser.py b/iTunesParser.py index efb5d09..85cc7e1 100644 --- a/iTunesParser.py +++ b/iTunesParser.py @@ -137,29 +137,30 @@ class ITunesParser: if akey not in self._artists: self._artists[akey] = { 'id': len(self._artists), # TODO Calc an uniq ID (permit to replace data) - 'name': akey, - 'count': 0, 'plays': 0, 'rating': 0, - # TODO Use Rating with R upper case to be coherent with iTunes data - 'genres': set() + 'Name': akey, + 'Track Count': 0, + 'Play Count': 0, + 'Rating': 0, + 'Genre': set() } # Compute information rating = track['Rating'] if 'Rating' in track else 0 # TODO If no Rating, don't take 0 - plays = track['Play Count'] if 'Play Count' in track else 0 + play_count = track['Play Count'] if 'Play Count' in track else 0 - rating = self._calc_rating(rating, self._artists[akey]['rating'], self._artists[akey]['count']) + rating = self._calc_rating(rating, self._artists[akey]['Rating'], self._artists[akey]['Track Count']) - self._artists[akey]['count'] += 1 - self._artists[akey]['rating'] = rating - self._artists[akey]['plays'] += plays + self._artists[akey]['Track Count'] += 1 + self._artists[akey]['Rating'] = rating + self._artists[akey]['Play Count'] += play_count if 'Genre' not in track: return # Split up the Genres genre_parts = track['Genre'].split('/') - self._artists[akey]['genres'] |= set(genre_parts) + self._artists[akey]['Genre'] |= set(genre_parts) return def _process_album(self, track): @@ -174,10 +175,11 @@ class ITunesParser: if akey not in self._albums: self._albums[akey] = { 'id': len(self._albums), - 'name': akey, - 'count': 0, 'plays': 0, 'rating': 0, - # TODO Use Rating with R upper case to be coherent with iTunes data - 'genres': set(), + 'Name': akey, + 'Track Count': 0, + 'Play Count': 0, + 'Rating': 0, + 'Genre': set(), 'artist': set() } @@ -185,20 +187,20 @@ class ITunesParser: rating = track['Rating'] if 'Rating' in track else 0 # TODO Use Album Rating # TODO If no Rating, don't take 0 - plays = track['Play Count'] if 'Play Count' in track else 0 + play_count = track['Play Count'] if 'Play Count' in track else 0 - rating = self._calc_rating(rating, self._albums[akey]['rating'], self._albums[akey]['count']) + rating = self._calc_rating(rating, self._albums[akey]['Rating'], self._albums[akey]['Track Count']) - self._albums[akey]['count'] += 1 - self._albums[akey]['rating'] = rating - self._albums[akey]['plays'] += plays + self._albums[akey]['Track Count'] += 1 + self._albums[akey]['Rating'] = rating + self._albums[akey]['Play Count'] += play_count if 'Genre' not in track: return # Split up the Genres genre_parts = track['Genre'].split('/') - self._albums[akey]['genres'] |= set(genre_parts) + self._albums[akey]['Genre'] |= set(genre_parts) ## Add different artists if 'Artist' not in track: