97 lines
2.5 KiB
Python
97 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Setup the argparser"""
|
|
import argparse
|
|
|
|
scrapper_types = (
|
|
"push",
|
|
"main",
|
|
"instagram",
|
|
"kemono",
|
|
"comic",
|
|
"manga",
|
|
"webcomic",
|
|
)
|
|
# Define types of instagram stories
|
|
instagram_types = ["posts", "reels", "channel", "stories", "highlights"]
|
|
|
|
|
|
def argparser(users: list) -> argparse.Namespace:
|
|
"""Returns an argparser to evaluate user input"""
|
|
# ARG PARSER
|
|
parser = argparse.ArgumentParser(
|
|
prog="Downloader",
|
|
description="Download images and galleries from a wide array of websites"
|
|
" either by using links or chosing from user define lists."
|
|
" This program also takes care of archiving tasks,"
|
|
" that keep the run time fast and prevents downloading duplicates.",
|
|
)
|
|
# Chose the type of scrapper
|
|
parser.add_argument(
|
|
choices=scrapper_types,
|
|
nargs="?",
|
|
dest="scrapper",
|
|
help="Select a scrapper.",
|
|
)
|
|
# Parse user list
|
|
parser.add_argument(
|
|
"-u",
|
|
"--user",
|
|
choices=users,
|
|
dest="user",
|
|
help="Selects the personal user list to process. Defaults to everyone",
|
|
default="everyone",
|
|
type=str,
|
|
)
|
|
# Parse individual links
|
|
parser.add_argument(
|
|
"-i",
|
|
"--input",
|
|
nargs="*",
|
|
dest="link",
|
|
action="append",
|
|
help="Download the provided links",
|
|
type=str,
|
|
)
|
|
# Set the print list flag
|
|
parser.add_argument(
|
|
"-l",
|
|
"--list",
|
|
dest="flag_list",
|
|
action="store_true",
|
|
help="Prints a list of all the added links and prompts for a choice",
|
|
)
|
|
# Set the use archiver flag
|
|
parser.add_argument(
|
|
"-a",
|
|
"--no-archive",
|
|
dest="flag_archive",
|
|
action="store_false",
|
|
help="Disables the archiver flag",
|
|
)
|
|
# Set the skip flag
|
|
parser.add_argument(
|
|
"-s",
|
|
"--no_skip",
|
|
dest="flag_skip",
|
|
action="store_false",
|
|
help="Disables the skip function, downloads the entire gallery",
|
|
)
|
|
parser.add_argument(
|
|
"-v",
|
|
"--verbose",
|
|
dest="flag_verbose",
|
|
action="store_true",
|
|
help="Prints the generated commands instead of running them",
|
|
)
|
|
parser.add_argument(
|
|
"-t",
|
|
"--type-post",
|
|
choices=instagram_types,
|
|
nargs="*",
|
|
dest="post_type",
|
|
help="Filters posts on instagram by type",
|
|
default=instagram_types,
|
|
type=str,
|
|
)
|
|
return parser.parse_args()
|