How to use the instaloader.Tristate.always function in instaloader

To help you get started, we’ve selected a few instaloader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instaloader / instaloader / instaloader.py View on Github external
raise SystemExit(1)

        if ':feed-all' in args.profile or ':feed-liked' in args.profile:
            raise SystemExit(":feed-all and :feed-liked were removed. Use :feed as target and "
                             "eventually --only-if=viewer_has_liked.")

        download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
        download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
        download_comments = Tristate.always if args.comments else Tristate.no_extra_query
        save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
        save_metadata = Tristate.always if args.metadata_json else Tristate.never

        if args.geotags and args.no_geotags:
            raise SystemExit("--geotags and --no-geotags given. I am confused and refuse to work.")
        elif args.geotags:
            download_geotags = Tristate.always
        elif args.no_geotags:
            download_geotags = Tristate.never
        else:
            download_geotags = Tristate.no_extra_query

        loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
                             user_agent=args.user_agent,
                             dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
                             download_videos=download_videos, download_video_thumbnails=download_video_thumbnails,
                             download_geotags=download_geotags,
                             save_captions=save_captions, download_comments=download_comments,
                             save_metadata=save_metadata, max_connection_attempts=args.max_connection_attempts)
        loader.main(args.profile,
                    username=args.login.lower() if args.login is not None else None,
                    password=args.password,
                    sessionfile=args.sessionfile,
github instaloader / instaloader / instaloader.py View on Github external
g_misc.add_argument('--version', action='version', help='Show version number and exit.',
                        version=__version__)

    args = parser.parse_args()
    try:
        if args.login is None and (args.stories or args.stories_only):
            print("--login=USERNAME required to download stories.", file=sys.stderr)
            args.stories = False
            if args.stories_only:
                raise SystemExit(1)

        if ':feed-all' in args.profile or ':feed-liked' in args.profile:
            raise SystemExit(":feed-all and :feed-liked were removed. Use :feed as target and "
                             "eventually --only-if=viewer_has_liked.")

        download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
        download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
        download_comments = Tristate.always if args.comments else Tristate.no_extra_query
        save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
        save_metadata = Tristate.always if args.metadata_json else Tristate.never

        if args.geotags and args.no_geotags:
            raise SystemExit("--geotags and --no-geotags given. I am confused and refuse to work.")
        elif args.geotags:
            download_geotags = Tristate.always
        elif args.no_geotags:
            download_geotags = Tristate.never
        else:
            download_geotags = Tristate.no_extra_query

        loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
                             user_agent=args.user_agent,
github instaloader / instaloader / instaloader.py View on Github external
try:
        if args.login is None and (args.stories or args.stories_only):
            print("--login=USERNAME required to download stories.", file=sys.stderr)
            args.stories = False
            if args.stories_only:
                raise SystemExit(1)

        if ':feed-all' in args.profile or ':feed-liked' in args.profile:
            raise SystemExit(":feed-all and :feed-liked were removed. Use :feed as target and "
                             "eventually --only-if=viewer_has_liked.")

        download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
        download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
        download_comments = Tristate.always if args.comments else Tristate.no_extra_query
        save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
        save_metadata = Tristate.always if args.metadata_json else Tristate.never

        if args.geotags and args.no_geotags:
            raise SystemExit("--geotags and --no-geotags given. I am confused and refuse to work.")
        elif args.geotags:
            download_geotags = Tristate.always
        elif args.no_geotags:
            download_geotags = Tristate.never
        else:
            download_geotags = Tristate.no_extra_query

        loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
                             user_agent=args.user_agent,
                             dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
                             download_videos=download_videos, download_video_thumbnails=download_video_thumbnails,
                             download_geotags=download_geotags,
                             save_captions=save_captions, download_comments=download_comments,
github instaloader / instaloader / instaloader.py View on Github external
args = parser.parse_args()
    try:
        if args.login is None and (args.stories or args.stories_only):
            print("--login=USERNAME required to download stories.", file=sys.stderr)
            args.stories = False
            if args.stories_only:
                raise SystemExit(1)

        if ':feed-all' in args.profile or ':feed-liked' in args.profile:
            raise SystemExit(":feed-all and :feed-liked were removed. Use :feed as target and "
                             "eventually --only-if=viewer_has_liked.")

        download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
        download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
        download_comments = Tristate.always if args.comments else Tristate.no_extra_query
        save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
        save_metadata = Tristate.always if args.metadata_json else Tristate.never

        if args.geotags and args.no_geotags:
            raise SystemExit("--geotags and --no-geotags given. I am confused and refuse to work.")
        elif args.geotags:
            download_geotags = Tristate.always
        elif args.no_geotags:
            download_geotags = Tristate.never
        else:
            download_geotags = Tristate.no_extra_query

        loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
                             user_agent=args.user_agent,
                             dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
                             download_videos=download_videos, download_video_thumbnails=download_video_thumbnails,
github instaloader / instaloader / instaloader.py View on Github external
version=__version__)

    args = parser.parse_args()
    try:
        if args.login is None and (args.stories or args.stories_only):
            print("--login=USERNAME required to download stories.", file=sys.stderr)
            args.stories = False
            if args.stories_only:
                raise SystemExit(1)

        if ':feed-all' in args.profile or ':feed-liked' in args.profile:
            raise SystemExit(":feed-all and :feed-liked were removed. Use :feed as target and "
                             "eventually --only-if=viewer_has_liked.")

        download_videos = Tristate.always if not args.no_videos else Tristate.no_extra_query
        download_video_thumbnails = Tristate.always if not args.no_video_thumbnails else Tristate.never
        download_comments = Tristate.always if args.comments else Tristate.no_extra_query
        save_captions = Tristate.no_extra_query if not args.no_captions else Tristate.never
        save_metadata = Tristate.always if args.metadata_json else Tristate.never

        if args.geotags and args.no_geotags:
            raise SystemExit("--geotags and --no-geotags given. I am confused and refuse to work.")
        elif args.geotags:
            download_geotags = Tristate.always
        elif args.no_geotags:
            download_geotags = Tristate.never
        else:
            download_geotags = Tristate.no_extra_query

        loader = Instaloader(sleep=not args.no_sleep, quiet=args.quiet,
                             user_agent=args.user_agent,
                             dirname_pattern=args.dirname_pattern, filename_pattern=args.filename_pattern,
github instaloader / instaloader / instaloader.py View on Github external
def __init__(self,
                 sleep: bool = True, quiet: bool = False,
                 user_agent: Optional[str] = None,
                 dirname_pattern: Optional[str] = None,
                 filename_pattern: Optional[str] = None,
                 download_videos: Tristate = Tristate.always,
                 download_video_thumbnails: Tristate = Tristate.always,
                 download_geotags: Tristate = Tristate.no_extra_query,
                 save_captions: Tristate = Tristate.no_extra_query,
                 download_comments: Tristate = Tristate.no_extra_query,
                 save_metadata: Tristate = Tristate.never,
                 max_connection_attempts: int = 3):

        # configuration parameters
        self.user_agent = user_agent if user_agent is not None else default_user_agent()
        self.session = self._get_anonymous_session()
        self.username = None
        self.sleep = sleep
        self.quiet = quiet
        self.dirname_pattern = _PathPattern(dirname_pattern if dirname_pattern is not None else '{target}')
        if filename_pattern is not None:
            filename_pattern = re.sub(r"({(?:post\.)?date)([:}])", r"\1_utc\2", filename_pattern)
            self.filename_pattern_old = filename_pattern.replace('{date_utc}', '{date_utc:%Y-%m-%d_%H-%M-%S}')
github instaloader / instaloader / instaloader.py View on Github external
if self.download_video_thumbnails is Tristate.always:
                downloaded = self.download_pic(filename=filename, filename_alt=filename_old,
                                               url=post.url, mtime=post.date_local)
        else:
            self.error("Warning: {0} has unknown typename: {1}".format(post, post.typename))

        # Save caption if desired
        if self.save_captions is not Tristate.never:
            if post.caption:
                self.save_caption(filename=filename, filename_alt=filename_old,
                                  mtime=post.date_local, caption=post.caption)
            else:
                self._log("", end=' ', flush=True)

        # Download video if desired
        if post.is_video and self.download_videos is Tristate.always:
            downloaded |= self.download_pic(filename=filename, filename_alt=filename_old,
                                            url=post.video_url, mtime=post.date_local)

        # Download geotags if desired
        if self.download_geotags is Tristate.always:
            location = post.get_location()
            if location:
                self.save_location(filename, location, post.date_local)

        # Update comments if desired
        if self.download_comments is Tristate.always:
            self.update_comments(filename=filename, filename_alt=filename_old, post=post)

        # Save metadata as JSON if desired.  It might require an extra query, depending on which information has been
        # already obtained.  Regarding Tristate interpretation, we always assume that it requires an extra query.
        if self.save_metadata is Tristate.always:
github instaloader / instaloader / instaloader.py View on Github external
def __init__(self,
                 sleep: bool = True, quiet: bool = False,
                 user_agent: Optional[str] = None,
                 dirname_pattern: Optional[str] = None,
                 filename_pattern: Optional[str] = None,
                 download_videos: Tristate = Tristate.always,
                 download_video_thumbnails: Tristate = Tristate.always,
                 download_geotags: Tristate = Tristate.no_extra_query,
                 save_captions: Tristate = Tristate.no_extra_query,
                 download_comments: Tristate = Tristate.no_extra_query,
                 save_metadata: Tristate = Tristate.never,
                 max_connection_attempts: int = 3):

        # configuration parameters
        self.user_agent = user_agent if user_agent is not None else default_user_agent()
        self.session = self._get_anonymous_session()
        self.username = None
        self.sleep = sleep
        self.quiet = quiet
        self.dirname_pattern = _PathPattern(dirname_pattern if dirname_pattern is not None else '{target}')
        if filename_pattern is not None:
            filename_pattern = re.sub(r"({(?:post\.)?date)([:}])", r"\1_utc\2", filename_pattern)