0

I'm trying to download all stories of what my profile follows using "Instaloader" in a Python module. The default naming pattern uses "{date_utc}_UTC". I want to name all stories with the "profilename-dateuploaded" pattern and store them in separate folders based on profile names, but I don't know how to pass the parameters through, this is what I have:

import instaloader

L = instaloader.Instaloader()
L.login(user, password)

for story in L.get_stories():
    for item in story.get_items():
        L.download_storyitem(item, ':story')

Where exactly can I pass those arguments? Thanks!

SG pro
  • 1
  • 2

1 Answers1

0

This is what I did:

profile = self.insta_session.check_profile_id(user_handle)

        for story in self.insta_session.get_stories([profile.userid]):
            # story is a Story object
            for item in story.get_items():
                try:
                    # item is a StoryItem object
                    filename = f'media/{story.owner_username}/stories'
                    Path(filename).mkdir(parents=True, exist_ok=True)
                    if not item.is_video:
                        logger.info(' Downloading image...')
                        status = self.insta_session.download_pic(
                            f'{filename}/{item.date_utc}', item.url, item.date_utc)
                    if item.is_video:
                        logger.info(' Downloading video...')
                        status = self.insta_session.download_pic(
                            f'{filename}/{item.date_utc}', url=item.video_url, mtime=item.date_local)

                    if not status:
                        continue
                except Exception as err:
                    logger.info('Download failed: %s', err)
                    continue
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35
fkhan
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 01 '22 at 03:05