althonos / InstaLooter

Another API-less Instagram pictures and videos downloader.
GNU General Public License v3.0
2.01k stars 256 forks source link

[Feature Request] Any way to download comments too? #74

Open mconigliaro opened 7 years ago

mconigliaro commented 7 years ago

It would be cool if there was a way to download comments too. Maybe store them in a text file with the same name of the image?

althonos commented 7 years ago

Hi there ! Well, the issue is, Instagram does not really load every comment, and it would be really tedious to actually exhaust the comments before switching to another post.

Still, the API gives you access to the comments IG loads first (no idea how they choose them, though):

from instaLooter import InstaLooter

looter = InstaLooter(directory="...", profile="...")
for media in looter.medias():
    for comment in media['comments']['edges']:
        print(comment['node']['owner']['username'], comment['node']['text'])
aandergr commented 7 years ago

If this is still relevant: You may try Instaloader, a feature-rich Instagram downloader which is able to download and locally update the comments.

pip3 install instaloader
instaloader --comments PROFILE
althonos commented 7 years ago

@mconigliaro : I'm thinking about adding a --json-dump flag that would dump the metadata extracted by instaLooter next to the proper image/video file in a JSON file. Would that work for you ?

mconigliaro commented 7 years ago

Seems like it could be useful. I'm not sure what's included in the metadata though. I was really just interested in the comments.

althonos commented 7 years ago

The top (10, if I remember right ?) comments should be included inside of the dump, with username of the commenter and text of the comment. Unfortunately, scraping all the comments would be a pain, since IG uses a cursor system, which means you can only request sequentially, and doing this would (1.) be extremely slow and (2.) go way beyond the scope of this program.