Skip to content

Commit

Permalink
change fetch order for comments of videos
Browse files Browse the repository at this point in the history
  • Loading branch information
wwbrannon committed Sep 24, 2024
1 parent 2a394f2 commit 7013ac3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions images/comments/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7013ac3

Please sign in to comment.