You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
#/usr/bin/env python3.7 |
|
|
|
import argparse |
|
import json |
|
|
|
import praw |
|
|
|
POST_MODES = [ "hot" |
|
, "new" |
|
, "rising" |
|
, "controversial" |
|
, "top" ] |
|
USER_AGENT = "python:github.com/benediktkr/reddit-communities2:v0.0.1 by /u/benediktkr" |
|
|
|
def get_parser(): |
|
parser = argparse.ArgumentParser() |
|
parser.add_argument("--seed-subreddit", required=True) |
|
parser.add_argument("--subreddit-mode", choices=POST_MODES, default="hot") |
|
parser.add_argument("--debug", action="store_true") |
|
parser.add_argument("--post-limit", type=int, default=25) |
|
|
|
return parser.parse_args() |
|
|
|
def get_config(path=None): |
|
if not path: |
|
path = ".config" |
|
with open(path, 'r') as f: |
|
return json.loads(f.read()) |
|
|
|
def log_in(): |
|
config = get_config() |
|
return praw.Reddit(client_id=config['id'], |
|
client_secret=config['secret'], |
|
password=config['pass'], |
|
user_agent=USER_AGENT, |
|
username=config['user'])
|
|
|