From 7013ac3f904b6d3f8b0378539af4d8586dcf8972 Mon Sep 17 00:00:00 2001 From: William Brannon Date: Tue, 24 Sep 2024 05:02:40 +0000 Subject: [PATCH] change fetch order for comments of videos --- images/comments/run.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/images/comments/run.py b/images/comments/run.py index c900e5f..62b2007 100755 --- a/images/comments/run.py +++ b/images/comments/run.py @@ -132,6 +132,12 @@ def ensure_videos(self): with open(self.video_path, 'wt', encoding='utf-8') as f: json.dump(videos, f) + try: + videos = sorted(videos, key=lambda s: s['snippet']['publishedAt'], + reverse=True) + except KeyError: + logger.exception('Failed to sort videos') + return videos def ensure_comments(self, video):