Update arguments

This commit is contained in:
Serene-Arc
2021-03-01 16:41:31 +10:00
committed by Ali Parlakci
parent 7b33ec07fd
commit c01fc39671

View File

@@ -1,10 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""
This program downloads imgur, gfycat and direct image and video links of
saved posts from a reddit account. It is written in Python 3.
"""
import argparse import argparse
import logging import logging
import sys import sys
@@ -22,34 +17,18 @@ def _add_options():
help="Specifies the directory where posts will be downloaded to", help="Specifies the directory where posts will be downloaded to",
metavar="DIRECTORY") metavar="DIRECTORY")
parser.add_argument("--verbose", "-v", parser.add_argument("--verbose", "-v",
help="Verbose Mode",
action="store_true", action="store_true",
default=False) count=True)
parser.add_argument("--quit", "-q",
help="Auto quit afer the process finishes",
action="store_true",
default=False)
parser.add_argument("--link", "-l", parser.add_argument("--link", "-l",
help="Get posts from link", help="Get posts from link",
action='append', action='append',
metavar="link") metavar="link")
parser.add_argument("--saved",
action="store_true",
required="--unsave" in sys.argv,
help="Triggers saved mode")
parser.add_argument("--unsave",
action="store_true",
help="Unsaves downloaded posts")
parser.add_argument("--submitted", parser.add_argument("--submitted",
action="store_true", action="store_true",
help="Gets posts of --user") help="Gets posts of --user")
parser.add_argument("--upvoted", parser.add_argument("--upvoted",
action="store_true", action="store_true",
help="Gets upvoted posts of --user") help="Gets upvoted posts of --user")
parser.add_argument("--log",
help="Takes a log file which created by itself (json files),reads posts and tries "
"downloading them again.",
metavar="LOG FILE")
parser.add_argument("--subreddit", parser.add_argument("--subreddit",
nargs="+", nargs="+",
help="Triggers subreddit mode and takes subreddit's name without r/. use \"frontpage\" " help="Triggers subreddit mode and takes subreddit's name without r/. use \"frontpage\" "
@@ -59,20 +38,24 @@ def _add_options():
parser.add_argument("--multireddit", parser.add_argument("--multireddit",
help="Triggers multireddit mode and takes multireddit's name without m", help="Triggers multireddit mode and takes multireddit's name without m",
metavar="MULTIREDDIT", metavar="MULTIREDDIT",
action='append',
type=str) type=str)
parser.add_argument("--user", parser.add_argument("--user",
help="reddit username if needed. use \"me\" for current user", help="reddit username if needed. use \"me\" for current user",
required="--multireddit" in sys.argv or "--submitted" in sys.argv, required="--multireddit" in sys.argv or "--submitted" in sys.argv,
metavar="redditor", metavar="redditor",
default=None,
type=str) type=str)
parser.add_argument("--search", parser.add_argument("--search",
help="Searches for given query in given subreddits", help="Searches for given query in given subreddits",
metavar="query", metavar="query",
default=None,
type=str) type=str)
parser.add_argument("--sort", parser.add_argument("--sort",
help="Either hot, top, new, controversial, rising or relevance default: hot", help="Either hot, top, new, controversial, rising or relevance default: hot",
choices=["hot", "top", "new", "controversial", "rising", "relevance"], choices=["hot", "top", "new", "controversial", "rising", "relevance"],
metavar="SORT TYPE", metavar="SORT TYPE",
default='hot',
type=str) type=str)
parser.add_argument("--limit", parser.add_argument("--limit",
help="default: unlimited", help="default: unlimited",
@@ -83,53 +66,32 @@ def _add_options():
help="Either hour, day, week, month, year or all. default: all", help="Either hour, day, week, month, year or all. default: all",
choices=["all", "hour", "day", "week", "month", "year"], choices=["all", "hour", "day", "week", "month", "year"],
metavar="TIME_LIMIT", metavar="TIME_LIMIT",
default='all',
type=str) type=str)
parser.add_argument("--skip", parser.add_argument("--skip",
nargs="+", nargs="+",
help="Skip posts with given type", help="Skip posts with given type",
type=str, type=str,
choices=["images", "videos", "gifs", "self"],
default=[]) default=[])
parser.add_argument("--skip-domain", parser.add_argument("--skip-domain",
nargs="+", nargs="+",
help="Skip posts with given domain", help="Skip posts with given domain",
type=str, type=str,
default=[]) default=[])
parser.add_argument("--set-folderpath", parser.add_argument("--set-folder-scheme",
action="store_true", action="store_true",
help="Set custom folderpath", help="Set custom folderpath",
default='{SUBREDDIT}' default='{SUBREDDIT}'
) )
parser.add_argument("--set-filename", parser.add_argument("--set-file-scheme",
action="store_true", action="store_true",
help="Set custom filename", help="Set custom filename",
default='{REDDITOR}_{TITLE}_{POSTID}' default='{REDDITOR}_{TITLE}_{POSTID}'
) )
parser.add_argument("--set-default-directory",
action="store_true",
help="Set a default directory to be used in case no directory is given",
)
parser.add_argument("--set-default-options",
action="store_true",
help="Set default options to use everytime program runs",
)
parser.add_argument("--use-local-config",
action="store_true",
help="Creates a config file in the program's directory"
" and uses it. Useful for having multiple configs",
)
parser.add_argument("--no-dupes", parser.add_argument("--no-dupes",
action="store_true", action="store_true",
help="Do not download duplicate posts on different subreddits", help="Do not download duplicate posts on different subreddits",
) )
parser.add_argument("--downloaded-posts",
help="Use a hash file to keep track of downloaded files",
type=str
)
parser.add_argument("--no-download",
action="store_true",
help="Just saved posts into a the POSTS.json file without downloading"
)
def _setup_logging(verbosity: int): def _setup_logging(verbosity: int):