Call functions according to provided cli arguments
This commit is contained in:
parent
85c35b829e
commit
554f1582f6
1 changed files with 17 additions and 0 deletions
17
main.py
17
main.py
|
@ -4,6 +4,7 @@ import praw
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
import argparse
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
@ -15,6 +16,22 @@ reddit = praw.Reddit(
|
||||||
user_agent = os.environ["PRAW_USER_AGENT"],
|
user_agent = os.environ["PRAW_USER_AGENT"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--subreddits', action="store_true", help="Save subcribed subreddits in subreddits.txt")
|
||||||
|
parser.add_argument('--multireddits', action="store_true", help="Save user's multireddits in multireddits.yaml")
|
||||||
|
parser.add_argument('--saved', action="store_true", help="Save saved comments and submissions in saved.yaml")
|
||||||
|
parser.add_argument('--redditor', action="store_true", help="Save redditor's submissions and comments in redditor.yaml")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.subreddits:
|
||||||
|
subreddits(reddit)
|
||||||
|
if args.multireddits:
|
||||||
|
multireddits(reddit)
|
||||||
|
if args.saved:
|
||||||
|
saved(reddit)
|
||||||
|
if args.redditor:
|
||||||
|
redditor(reddit)
|
||||||
|
|
||||||
def subreddits(reddit):
|
def subreddits(reddit):
|
||||||
with open("subreddits.txt", "w") as file:
|
with open("subreddits.txt", "w") as file:
|
||||||
for subreddit in reddit.user.subreddits(limit=None):
|
for subreddit in reddit.user.subreddits(limit=None):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue