(scripts) Improve retrieve rating for albums
This commit is contained in:
@@ -187,7 +187,6 @@ class ITunesParser:
|
|||||||
'Album': akey,
|
'Album': akey,
|
||||||
'Track Count': 0,
|
'Track Count': 0,
|
||||||
'Play Count': 0,
|
'Play Count': 0,
|
||||||
'Rating': 0,
|
|
||||||
'Genre': set(),
|
'Genre': set(),
|
||||||
'Artist': set(),
|
'Artist': set(),
|
||||||
'Avg Bit Rate': track['Bit Rate'],
|
'Avg Bit Rate': track['Bit Rate'],
|
||||||
@@ -199,22 +198,18 @@ class ITunesParser:
|
|||||||
# Compute information
|
# Compute information
|
||||||
play_count = track['Play Count'] if 'Play Count' in track else 0
|
play_count = track['Play Count'] if 'Play Count' in track else 0
|
||||||
|
|
||||||
rating = track['Rating'] if 'Rating' in track else 0
|
|
||||||
rating = self.calc_average(rating, self._albums[akey]['Rating'], self._albums[akey]['Track Count'])
|
|
||||||
|
|
||||||
total_time = track['Total Time'] if 'Total Time' in track else 0
|
total_time = track['Total Time'] if 'Total Time' in track else 0
|
||||||
|
|
||||||
|
avg_bitrate = self.calc_average(track['Bit Rate'], self._albums[akey]['Avg Bit Rate'], self._albums[akey]['Track Count'])
|
||||||
|
|
||||||
|
self._albums[akey]['Avg Bit Rate'] = avg_bitrate
|
||||||
|
self._albums[akey]['Track Count'] += 1
|
||||||
|
self._albums[akey]['Play Count'] += play_count
|
||||||
|
self._albums[akey]['Total Time'] += total_time
|
||||||
|
|
||||||
if self._albums[akey]['Min Bit Rate'] > track['Bit Rate']:
|
if self._albums[akey]['Min Bit Rate'] > track['Bit Rate']:
|
||||||
self._albums[akey]['Min Bit Rate'] = track['Bit Rate']
|
self._albums[akey]['Min Bit Rate'] = track['Bit Rate']
|
||||||
|
|
||||||
avg_bitrate = self.calc_average(track['Bit Rate'], self._albums[akey]['Avg Bit Rate'], self._albums[akey]['Track Count'])
|
|
||||||
self._albums[akey]['Avg Bit Rate'] = avg_bitrate
|
|
||||||
|
|
||||||
self._albums[akey]['Track Count'] += 1
|
|
||||||
self._albums[akey]['Rating'] = rating
|
|
||||||
self._albums[akey]['Play Count'] += play_count
|
|
||||||
self._albums[akey]['Total Time'] += total_time
|
|
||||||
|
|
||||||
if 'Genre' in track:
|
if 'Genre' in track:
|
||||||
# Split up the Genres
|
# Split up the Genres
|
||||||
genre_parts = track['Genre'].split('/')
|
genre_parts = track['Genre'].split('/')
|
||||||
@@ -225,7 +220,9 @@ class ITunesParser:
|
|||||||
|
|
||||||
if 'Album Rating' in track:
|
if 'Album Rating' in track:
|
||||||
self._albums[akey]['Album Rating'] = track['Album Rating']
|
self._albums[akey]['Album Rating'] = track['Album Rating']
|
||||||
self._albums[akey]['Album Rating Computed'] = True
|
|
||||||
|
if 'Album Rating Computed' in track:
|
||||||
|
self._albums[akey]['Album Rating Computed'] = track['Album Rating Computed']
|
||||||
|
|
||||||
if 'Album Artist' in track:
|
if 'Album Artist' in track:
|
||||||
self._albums[akey]['Album Artist'] = track['Album Artist']
|
self._albums[akey]['Album Artist'] = track['Album Artist']
|
||||||
@@ -278,7 +275,6 @@ class WriteElsJson:
|
|||||||
file_albums = io.open(output_file, 'wb')
|
file_albums = io.open(output_file, 'wb')
|
||||||
for _, album in albums.items():
|
for _, album in albums.items():
|
||||||
persistent_id = album['Persistent ID']
|
persistent_id = album['Persistent ID']
|
||||||
album['Rating'] = round(album['Rating'])
|
|
||||||
album['Avg Bit Rate'] = round(album['Avg Bit Rate'])
|
album['Avg Bit Rate'] = round(album['Avg Bit Rate'])
|
||||||
|
|
||||||
json_track_index = {
|
json_track_index = {
|
||||||
|
|||||||
Reference in New Issue
Block a user