summaryrefslogtreecommitdiffstats
path: root/clerk_helper
diff options
context:
space:
mode:
authorjunkmechanic <ankurcool.unforgiven@gmail.com>2015-04-13 19:37:49 +0200
committerjunkmechanic <ankurcool.unforgiven@gmail.com>2015-04-13 19:37:49 +0200
commit8396834685798b3d616174e649d23d5053d0ec54 (patch)
tree45441f3a4f5ea6f4cc2dcb990e42595da8e66f73 /clerk_helper
parenta9f67269470d518563c95d77204fc61254737cf2 (diff)
downloadperl-app-clerk-8396834685798b3d616174e649d23d5053d0ec54.tar.gz
perl-app-clerk-8396834685798b3d616174e649d23d5053d0ec54.tar.xz
accounting for disc number for sorting tracks
Diffstat (limited to 'clerk_helper')
-rwxr-xr-xclerk_helper14
1 files changed, 12 insertions, 2 deletions
diff --git a/clerk_helper b/clerk_helper
index 1eb7e02..7c5c562 100755
--- a/clerk_helper
+++ b/clerk_helper
@@ -80,7 +80,7 @@ def lookup(key, fields):
def createCache(args):
# track cache creation
key = 'artist'
- fields = ('artist', 'track', 'title', 'album')
+ fields = ('artist', 'track', 'title', 'album', 'disc')
all_tracks = list({repr(t): t for t in lookup(key, fields)}.values())
with open(os.getenv('HOME')+'/.config/clerk/tracks.cache.json', "w") as cache_file:
json.dump(all_tracks, cache_file)
@@ -103,10 +103,20 @@ def createCache(args):
json.dump([entry for entry in album_cache.values()], cache_file)
+def track_sort(track_num):
+ if track_num == '':
+ return 0
+ else:
+ return int(track_num.split('/')[0])
+
+
def getTracks(args):
with open(os.getenv('HOME')+'/.config/clerk/tracks.cache.json') as cache_file:
content = json.load(cache_file)
- sorted_content = sorted(content, key=lambda x: (x['artist'], x['album'], x['track']))
+ sorted_content = sorted(content, key=lambda x: (x['artist'],
+ x['album'],
+ x['disc'],
+ track_sort(x['track'])))
print('\n'.join([os.getenv('separator').join([entry['artist'],
entry['track'],
entry['title'],