From 5dec7b5b7fba8c3658ddf83bc2ecc04bd8b0b210 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Fri, 1 May 2015 02:33:25 +0200 Subject: make sure album ratings are set on track 1 only --- clerk_helper | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'clerk_helper') diff --git a/clerk_helper b/clerk_helper index 0c0befe..7afc05d 100755 --- a/clerk_helper +++ b/clerk_helper @@ -306,20 +306,24 @@ def importTrackRatings(args): def importAlbumRatings(args): client.clear() - list = client.sticker_find('song', "", 'albumrating') + ratelist = client.sticker_find('song', "", 'albumrating') rated_tracks = [] - for i in list: + for i in ratelist: rating_temp = i['sticker'] rating = rating_temp.split('=')[1] for x in client.find('file', i['file']): artist = x['albumartist'] album = x['album'] date = x['date'] + if isinstance(x, list): + track = x['track'][0] + else: + track = x['track'] if 'disc' in x: disc = x['disc'] else: disc = "" - entry = {'albumartist': artist, 'album': album, 'date': date, 'disc': disc, 'rating': rating} + entry = {'albumartist': artist, 'track': track, 'album': album, 'date': date, 'disc': disc, 'rating': rating} rated_tracks.append(entry) with open(os.getenv('HOME')+'/.config/clerk/albumratings.json', 'w') as ratingfile: json.dump(rated_tracks, ratingfile) @@ -337,7 +341,7 @@ def sendStickers(args): with open(os.getenv('HOME')+'/.config/clerk/albumratings.json') as cache_file: content = json.load(cache_file) for album in content: - uri = client.find('albumartist', album['albumartist'], 'album', album['album'], 'disc', album['disc'], 'date', album['date'], 'track', '1') + uri = client.find('albumartist', album['albumartist'], 'album', album['album'], 'disc', album['disc'], 'date', album['date'], 'track', album['track']) rating = album['rating'] for x in uri: client.sticker_set('song', x['file'], 'albumrating', rating) -- cgit v1.2.3-24-g4f1b