Improve verbose mode
This commit is contained in:
parent
91d71565cc
commit
ed0564fba0
|
@ -536,8 +536,8 @@ def download(submissions):
|
||||||
|
|
||||||
for i in range(subsLenght):
|
for i in range(subsLenght):
|
||||||
print(
|
print(
|
||||||
f"\n({i+1}/{subsLenght}) ({submissions[i]['postType'].upper()}) " \
|
f"\n({i+1}/{subsLenght}) – {submissions[i]['postType'].upper()} " \
|
||||||
f"(r/{submissions[i]['postSubreddit']})",end=""
|
f"– r/{submissions[i]['postSubreddit']}",end=""
|
||||||
)
|
)
|
||||||
|
|
||||||
if isPostExists(submissions[i]):
|
if isPostExists(submissions[i]):
|
||||||
|
@ -620,7 +620,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
GLOBAL.directory = Path(input("download directory: "))
|
GLOBAL.directory = Path(input("download directory: "))
|
||||||
|
|
||||||
print("\n"," ".join(sys.argv),"\n")
|
print("\n"," ".join(sys.argv),"\n",noPrint=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
checkConflicts()
|
checkConflicts()
|
||||||
|
|
|
@ -126,8 +126,6 @@ def getPosts(args):
|
||||||
if args["user"] == "me":
|
if args["user"] == "me":
|
||||||
args["user"] = str(reddit.user.me())
|
args["user"] = str(reddit.user.me())
|
||||||
|
|
||||||
# print("\nGETTING POSTS\n.\n.\n.\n")
|
|
||||||
|
|
||||||
if not "search" in args:
|
if not "search" in args:
|
||||||
if args["sort"] == "top" or args["sort"] == "controversial":
|
if args["sort"] == "top" or args["sort"] == "controversial":
|
||||||
keyword_params = {
|
keyword_params = {
|
||||||
|
@ -159,7 +157,7 @@ def getPosts(args):
|
||||||
sort=args["sort"],
|
sort=args["sort"],
|
||||||
subreddit=args["subreddit"],
|
subreddit=args["subreddit"],
|
||||||
time=args["time"]
|
time=args["time"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
reddit.subreddit(args["subreddit"]).search(
|
reddit.subreddit(args["subreddit"]).search(
|
||||||
|
@ -187,7 +185,7 @@ def getPosts(args):
|
||||||
"saved posts\nuser:{username}\nlimit={limit}\n".format(
|
"saved posts\nuser:{username}\nlimit={limit}\n".format(
|
||||||
username=reddit.user.me(),
|
username=reddit.user.me(),
|
||||||
limit=args["limit"]
|
limit=args["limit"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
return redditSearcher(reddit.user.me().saved(limit=args["limit"]))
|
return redditSearcher(reddit.user.me().saved(limit=args["limit"]))
|
||||||
|
|
||||||
|
@ -202,7 +200,7 @@ def getPosts(args):
|
||||||
sort=args["sort"],
|
sort=args["sort"],
|
||||||
subreddit=args["subreddit"],
|
subreddit=args["subreddit"],
|
||||||
time=args["time"]
|
time=args["time"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
getattr(reddit.front,args["sort"]) (**keyword_params)
|
getattr(reddit.front,args["sort"]) (**keyword_params)
|
||||||
|
@ -216,7 +214,7 @@ def getPosts(args):
|
||||||
sort=args["sort"],
|
sort=args["sort"],
|
||||||
subreddit=args["subreddit"],
|
subreddit=args["subreddit"],
|
||||||
time=args["time"]
|
time=args["time"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
getattr(
|
getattr(
|
||||||
|
@ -234,7 +232,7 @@ def getPosts(args):
|
||||||
sort=args["sort"],
|
sort=args["sort"],
|
||||||
multireddit=args["multireddit"],
|
multireddit=args["multireddit"],
|
||||||
time=args["time"]
|
time=args["time"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
|
@ -255,7 +253,7 @@ def getPosts(args):
|
||||||
sort=args["sort"],
|
sort=args["sort"],
|
||||||
user=args["user"],
|
user=args["user"],
|
||||||
time=args["time"]
|
time=args["time"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
getattr(
|
getattr(
|
||||||
|
@ -268,7 +266,7 @@ def getPosts(args):
|
||||||
"upvoted posts of {user}\nlimit: {limit}\n".format(
|
"upvoted posts of {user}\nlimit: {limit}\n".format(
|
||||||
user=args["user"],
|
user=args["user"],
|
||||||
limit=args["limit"]
|
limit=args["limit"]
|
||||||
).upper()
|
).upper(),noPrint=True
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
|
@ -278,7 +276,7 @@ def getPosts(args):
|
||||||
raise InsufficientPermission
|
raise InsufficientPermission
|
||||||
|
|
||||||
elif "post" in args:
|
elif "post" in args:
|
||||||
print("post: {post}\n".format(post=args["post"]).upper())
|
print("post: {post}\n".format(post=args["post"]).upper(),noPrint=True)
|
||||||
return redditSearcher(
|
return redditSearcher(
|
||||||
reddit.submission(url=args["post"]),SINGLE_POST=True
|
reddit.submission(url=args["post"]),SINGLE_POST=True
|
||||||
)
|
)
|
||||||
|
@ -307,7 +305,8 @@ def redditSearcher(posts,SINGLE_POST=False):
|
||||||
|
|
||||||
allPosts = {}
|
allPosts = {}
|
||||||
|
|
||||||
print("GETTING POSTS")
|
print("\nGETTING POSTS",end=" ")
|
||||||
|
if GLOBAL.arguments.verbose: print("\n")
|
||||||
postsFile = createLogFile("POSTS")
|
postsFile = createLogFile("POSTS")
|
||||||
|
|
||||||
if SINGLE_POST:
|
if SINGLE_POST:
|
||||||
|
@ -344,7 +343,7 @@ def redditSearcher(posts,SINGLE_POST=False):
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if subCount % 1000 == 0:
|
if subCount % 1000 == 0:
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n"+" "*14)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -372,13 +371,18 @@ def redditSearcher(posts,SINGLE_POST=False):
|
||||||
|
|
||||||
postsFile.add(allPosts)
|
postsFile.add(allPosts)
|
||||||
|
|
||||||
if not len(subList) == 0:
|
if not len(subList) == 0:
|
||||||
print(
|
if GLOBAL.arguments.NoDownload or GLOBAL.arguments.verbose:
|
||||||
f"\n\nTotal of {len(subList)} submissions found!\n"\
|
print(
|
||||||
f"{gfycatCount} GFYCATs, {imgurCount} IMGURs, " \
|
f"\n\nTotal of {len(subList)} submissions found!"
|
||||||
f"{eromeCount} EROMEs, {directCount} DIRECTs " \
|
)
|
||||||
f"and {selfCount} SELF POSTS"
|
print(
|
||||||
)
|
f"{gfycatCount} GFYCATs, {imgurCount} IMGURs, " \
|
||||||
|
f"{eromeCount} EROMEs, {directCount} DIRECTs " \
|
||||||
|
f"and {selfCount} SELF POSTS",noPrint=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print()
|
||||||
return subList
|
return subList
|
||||||
else:
|
else:
|
||||||
raise NoMatchingSubmissionFound
|
raise NoMatchingSubmissionFound
|
||||||
|
|
|
@ -90,7 +90,7 @@ def createLogFile(TITLE):
|
||||||
|
|
||||||
return FILE
|
return FILE
|
||||||
|
|
||||||
def printToFile(*args, **kwargs):
|
def printToFile(*args, noPrint=False,**kwargs):
|
||||||
"""Print to both CONSOLE and
|
"""Print to both CONSOLE and
|
||||||
CONSOLE LOG file in a folder time stampt in the name
|
CONSOLE LOG file in a folder time stampt in the name
|
||||||
"""
|
"""
|
||||||
|
@ -98,7 +98,12 @@ def printToFile(*args, **kwargs):
|
||||||
TIME = str(time.strftime("%d-%m-%Y_%H-%M-%S",
|
TIME = str(time.strftime("%d-%m-%Y_%H-%M-%S",
|
||||||
time.localtime(GLOBAL.RUN_TIME)))
|
time.localtime(GLOBAL.RUN_TIME)))
|
||||||
folderDirectory = GLOBAL.directory / "LOG_FILES" / TIME
|
folderDirectory = GLOBAL.directory / "LOG_FILES" / TIME
|
||||||
print(*args,**kwargs)
|
|
||||||
|
if not noPrint or \
|
||||||
|
GLOBAL.arguments.verbose or \
|
||||||
|
"file" in kwargs:
|
||||||
|
|
||||||
|
print(*args,**kwargs)
|
||||||
|
|
||||||
if not path.exists(folderDirectory):
|
if not path.exists(folderDirectory):
|
||||||
makedirs(folderDirectory)
|
makedirs(folderDirectory)
|
||||||
|
|
Loading…
Reference in a new issue