diff --git a/README.rst b/README.rst index 34efecb..a0a45e3 100644 --- a/README.rst +++ b/README.rst @@ -3,16 +3,16 @@ Shreddit Details ----------- -Uses the reddit_api over at https://github.com/mellort/reddit_api to do all the heavy lifting. +Uses the praw over at https://github.com/praw-dev/praw to do all the heavy lifting. Usage ----------- - Just run `./schreddit` -- You may want to check out the reddit_api, build it using `python setup.py build` and then copy the /reddit directory to this directory. The reason I don't provide it is that the reddit_api changes frequently and I don't want to include a static old version here. I also don't want to have a git repo in a git repo. +- You will need the `praw` Reddit Python library installed somewhere. I advise taking a read of https://github.com/praw-dev/praw#installation Tit-bits ----------- -- If you fill in your user/passwd in your reddit_api then you won't be asked for login details when you run the program! Otherwise you'll be prompted every time. +- If you fill in your user/passwd in your reddit.cfg then you won't be asked for login details when you run the program! Otherwise you'll be prompted every time. Cron examples ----------- diff --git a/shreddit b/shreddit index d1faa55..6be20f1 100755 --- a/shreddit +++ b/shreddit @@ -1,6 +1,6 @@ #!/usr/bin/env python2 -import reddit +import praw import ConfigParser from datetime import datetime, timedelta @@ -15,9 +15,15 @@ verbose = config.getboolean('main', 'verbose') clear_vote = config.getboolean('main', 'clear_vote') item = config.get('main', 'item') -r = reddit.Reddit(user_agent="Shreddit-PRAW") -# add user: / pswd: to the [reddit] config section -r.login() +_user = config.get('main', 'username') +_pass = config.get('main', 'password') + +r = praw.Reddit(user_agent="Shreddit-PRAW 2.0") + +if _user and _pass: + r.login(_user, _pass) +else: + r.login() if verbose: print "Logged in as %s" % r.user diff --git a/shreddit.cfg b/shreddit.cfg index f6de483..2a89e83 100644 --- a/shreddit.cfg +++ b/shreddit.cfg @@ -1,7 +1,10 @@ -# User and password will be prompted for -# or can be edited in the reddit_api [reddit] section [main] +# Login details for Reddit. Fill out if you don't wish +# to be prompted for a login every time you run Shreddit. +username = +password = + # How many hours of comments you want to keep # 24 hours in a day, # 168 hours in a week,