summaryrefslogtreecommitdiffstats
path: root/clerk_helper
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-05-01 02:33:25 +0200
committerRasmus Steinke <rasi@xssn.at>2015-05-01 02:33:25 +0200
commit5dec7b5b7fba8c3658ddf83bc2ecc04bd8b0b210 (patch)
tree2868532e7035605f037a9c7b1e8fbe9c337922d9 /clerk_helper
parent8ab18debc847c1fb653498b35cffda063662a720 (diff)
downloadperl-app-clerk-5dec7b5b7fba8c3658ddf83bc2ecc04bd8b0b210.tar.gz
perl-app-clerk-5dec7b5b7fba8c3658ddf83bc2ecc04bd8b0b210.tar.xz
make sure album ratings are set on track 1 only
Diffstat (limited to 'clerk_helper')
-rwxr-xr-xclerk_helper12
1 files changed, 8 insertions, 4 deletions
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)