summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xclerk_helper25
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()