summaryrefslogtreecommitdiffstats
path: root/server/download_script.py
blob: d6e03bc3c7a26f0f6e5d368a7921f3020590796a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import instaloader
import os

L = instaloader.Instaloader()
L.login('xtester2', 'teTeD7QojvhOdvEGa50u6FFJo')
PROFILES = ["aao.remote.ho.jaye"]
BASE_DIR = "/home/genos/imp/work/project/insta/server/downloads"

os.makedirs(BASE_DIR, exist_ok=True)

def download_posts(profile):
    profile_dir = os.path.join(BASE_DIR, profile)
    os.makedirs(profile_dir, exist_ok=True)
    L.dirname_pattern = profile_dir
    posts = instaloader.Profile.from_username(L.context, profile).get_posts()
    for post in posts:
        if post.typename == 'GraphVideo':  # Only download videos
            L.download_post(post, target=profile)
        elif post.typename == 'GraphImage':  # Only download images
            L.download_post(post, target=profile)

for profile in PROFILES:
    download_posts(profile)