diff options
author | Rasmus Steinke <rasi@xssn.at> | 2015-03-13 04:19:07 +0100 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2015-03-13 04:19:07 +0100 |
commit | 85213131f368c433a232994fa387b29d8ae026a2 (patch) | |
tree | 4bf6f7384b1768c051a355164e55671d8f6d2ca7 | |
parent | c4b6a8a3b00fe216f6c99835cf116cddd17075f2 (diff) | |
download | perl-app-clerk-85213131f368c433a232994fa387b29d8ae026a2.tar.gz perl-app-clerk-85213131f368c433a232994fa387b29d8ae026a2.tar.xz |
Be more strict
-rwxr-xr-x | clerk_helper | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clerk_helper b/clerk_helper index 14ac637..fe2c1e3 100755 --- a/clerk_helper +++ b/clerk_helper @@ -152,6 +152,28 @@ def restoreTrackRating(args): client.sticker_set('song', song['file'], 'rating', columns[0]) print("Imported song "+song['title']+" with rating of "+columns[0]) +def restoreAlbumRating(args): + client.clear() + matches = [] + for root, dirnames, filenames in os.walk(config['global']['music_path']): + for filename in fnmatch.filter(filenames, 'album.rating'): + matches.append(os.path.join(root, filename)) + for song in matches: + ratingfile = open(song, 'r') + for line in ratingfile: + tags = line.split(" "+config['global']['separator']+" ") + album = tags[5].rstrip('\n') + client.findadd('artist', tags[1], 'album', album, 'track', tags[2], 'title', tags[3], 'date', tags[4]) + + for song in client.playlistinfo(): + ratingfile = open(config['global']['music_path']+"/"+os.path.dirname(song['file'])+'/album.rating', 'r') + for line in ratingfile: + columns = line.split(" "+config['global']['separator']+" ") + if song['title'] in line and song['date'] in line and song['album'] in line and song['track'] in line: + client.sticker_set('song', song['file'], 'albumrating', columns[0]) + print("Imported album "+song['album']+" with rating of "+columns[0]) + + #create commandline arguments parser = argparse.ArgumentParser(prog='mppc', description='A mpc clone in python') subparsers = parser.add_subparsers() @@ -177,6 +199,9 @@ parser_lastcache.set_defaults(call=lastCache) parser_restoretracks = subparsers.add_parser('restoretracks', help="restore sticker database from rating files") parser_restoretracks.set_defaults(call=restoreTrackRating) +parser_restorealbums = subparsers.add_parser('restorealbums', help="restore sticker database from rating files") +parser_restorealbums.set_defaults(call=restoreAlbumRating) + #parse arguments (thanks jat) args = parser.parse_args() |