From a06816b9c33d0d7d0ef35211c16b5592e0801433 Mon Sep 17 00:00:00 2001 From: Jordan Date: Thu, 16 Apr 2020 01:59:34 -0700 Subject: use natural sort (remove leading zeros) if no track num --- run.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 3bd5e92..9978f83 100755 --- a/run.py +++ b/run.py @@ -102,10 +102,14 @@ def list_books(): for a_file in books[a]['files']: track = books[a]['files'][a_file]['track'] if not track or track in track_list: - key = lambda x: books[a]['files'][x]['title'] + # remove leading zeros from digits (natural sort) + conv = lambda s: [int(x) if x.isdigit() else x.lower() for x in + re.split('(\d+)', s)] + key = lambda x: conv(books[a]['files'][x]['title']) break track_list.append(track) else: + # we have populated and unique track values, use those key = lambda x: books[a]['files'][x]['track'] # populate XML attribute values required by Apple podcasts -- cgit v1.2.3-54-g00ecf