Downvoted argument added to ./script.py's parser, programMode and Attributes dictonary.

This commit is contained in:
2019-12-23 01:10:06 +01:00
parent d6194c57d9
commit f32d17796a
2 changed files with 21 additions and 3 deletions

View File

@@ -114,6 +114,10 @@ def parseArguments(arguments=[]):
action="store_true",
help="Gets upvoted posts of --user")
parser.add_argument("--downvoted",
action="store_true",
help="Gets downvoted posts of --user")
parser.add_argument("--log",
help="Takes a log file which created by itself " \
"(json files), reads posts and tries downloadin" \
@@ -187,7 +191,7 @@ def checkConflicts():
search = 1 if GLOBAL.arguments.search else 0
modes = [
"saved","subreddit","submitted","log","link","upvoted","multireddit"
"saved","subreddit","submitted","log","link","upvoted","downvoted","multireddit"
]
values = {
@@ -241,7 +245,7 @@ class PromptUser:
print("select program mode:")
programModes = [
"search","subreddit","multireddit",
"submitted","upvoted","saved","log"
"submitted","upvoted","downvoted","saved","log"
]
programMode = self.chooseFrom(programModes)
@@ -345,6 +349,10 @@ class PromptUser:
elif programMode == "upvoted":
GLOBAL.arguments.upvoted = True
GLOBAL.arguments.user = input("\nredditor: ")
elif programMode == "downvoted":
GLOBAL.arguments.downvoted = True
GLOBAL.arguments.user = input("\nredditor: ")
elif programMode == "saved":
GLOBAL.arguments.saved = True
@@ -419,6 +427,9 @@ def prepareAttributes():
elif GLOBAL.arguments.upvoted is True:
ATTRIBUTES["upvoted"] = True
elif GLOBAL.arguments.downvoted is True:
ATTRIBUTES["downvoted"] = True
elif GLOBAL.arguments.submitted is not None:
ATTRIBUTES["submitted"] = True

View File

@@ -92,7 +92,7 @@ def LinkParser(LINK):
if index == 0:
RESULT["subreddit"] = "frontpage"
elif SplittedLink[index] in ["submitted","saved","posts","upvoted"]:
elif SplittedLink[index] in ["submitted","saved","posts","upvoted","downvoted"]:
if SplittedLink[index] == "submitted" or \
SplittedLink[index] == "posts":
RESULT["submitted"] = {}
@@ -103,6 +103,9 @@ def LinkParser(LINK):
elif SplittedLink[index] == "upvoted":
RESULT["upvoted"] = True
elif SplittedLink[index] == "downvoted":
RESULT["downvoted"] = True
elif "?" in SplittedLink[index]:
ParsedQuery = QueryParser(SplittedLink[index],index)
if ParsedQuery["HEADER"] == "search":
@@ -119,6 +122,7 @@ def LinkParser(LINK):
RESULT["queries"] = ParsedQuery
if not ("upvoted" in RESULT or \
"downvoted" in RESULT or \
"saved" in RESULT or \
"submitted" in RESULT or \
"multireddit" in RESULT) and \
@@ -221,6 +225,9 @@ def LinkDesigner(LINK):
elif "upvoted" in attributes:
MODE["upvoted"] = True
elif "downvoted" in attributes:
MODE["downvoted"] = True
elif "multireddit" in attributes:
MODE["multireddit"] = attributes["multireddit"]