Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download only instagram videos with instaloader

This code is working for downloading all photos and videos

from instaloader import Instaloader, Profile

L = Instaloader()
PROFILE = "username"
profile = Profile.from_username(L.context, PROFILE)

posts_sorted_by_likes = sorted(profile.get_posts(), key=lambda post: post.likes,reverse=True)

for post in posts_sorted_by_likes:
L.download_post(post, PROFILE)

Now i want to download only videos, But I can't. How can I filter this code for only videos?

like image 737
Rasedul Islam Avatar asked Sep 14 '25 05:09

Rasedul Islam


1 Answers

Post has an is_video property

for post in posts_sorted_by_likes:
    if post.is_video:
        L.download_post(post, PROFILE)
like image 92
Abhinav Mathur Avatar answered Sep 16 '25 19:09

Abhinav Mathur