1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-08-16 11:49:39 +02:00

194_top_x_of_user example: Fix sort order

This commit is contained in:
Alexander Graf 2019-08-10 16:25:22 +02:00
parent a88316224b
commit 75a729781d

View File

@ -9,7 +9,9 @@ X_percentage = 10 # percentage of posts that should be downloaded
L = Instaloader()
profile = Profile.from_username(L.context, PROFILE)
posts_sorted_by_likes = sorted(profile.get_posts(), key = lambda p: p.likes + p.comments)
posts_sorted_by_likes = sorted(profile.get_posts(),
key=lambda p: p.likes + p.comments,
reverse=True)
for post in islice(posts_sorted_by_likes, ceil(profile.mediacount * X_percentage / 100)):
L.download_post(post, PROFILE)