From 97a65ad52d2917000e08fdcd34b612927e2b4ad0 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 30 Nov 2018 09:41:14 +0100 Subject: [PATCH 1/2] use code as secondary sort --- recommendation_engine.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recommendation_engine.py b/recommendation_engine.py index 00cd055..e32d800 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -470,10 +470,15 @@ class Engine: f.write(json.dumps(videos, indent=4, sort_keys=True)) # Get video order order = {video['id']: int(video['order']) for video in videos} + code = {video['id']: video['code'] for video in videos} # Sort clips clips = sorted( clips, - key=lambda clip: (order[clip['id'].split('/')[0]], clip['in']) + key=lambda clip: ( + order[clip['id'].split('/')[0]], + ox.sort_string(code[clip['id'].split('/')[0]], + clip['in'] + ) ) # Get and cache playlists self.playlists = [playlist for playlist in [{ From 3c80c721d35f678477b70ce5d020c2dfec918f7f Mon Sep 17 00:00:00 2001 From: j Date: Fri, 30 Nov 2018 09:52:22 +0100 Subject: [PATCH 2/2] typo --- recommendation_engine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recommendation_engine.py b/recommendation_engine.py index e32d800..64d7fe5 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -476,7 +476,7 @@ class Engine: clips, key=lambda clip: ( order[clip['id'].split('/')[0]], - ox.sort_string(code[clip['id'].split('/')[0]], + ox.sort_string(code[clip['id'].split('/')[0]]), clip['in'] ) ) @@ -493,7 +493,7 @@ class Engine: } for clip in clips if clip['value'] == storyline['name']] } for storyline in storylines] if playlist['clips']] with open(os.path.join(self.path, 'playlists.json'), 'w') as f: - f.write(json.dumps(self.playlists, indent=4, sort_keys=True)) + f.write(json.dumps(self.playlists, indent=4, sort_keys=True, ensure_ascii=False)) self.update_keywords() def update_keywords(self):