an integration between saved reddit posts and pinboard
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.
jowj 97e44e5874
Add a line about installing this.
4 years ago
.gitignore Initial commit 5 years ago
Pipfile Generate actual pipfiles, requirements file. 4 years ago
Pipfile.lock Generate actual pipfiles, requirements file. 4 years ago
README.md Add a line about installing this. 4 years ago
main.py AAAAAH ITS WORKING 5 years ago
pinboard.py AAAAAH ITS WORKING 5 years ago
requirements.txt Generate actual pipfiles, requirements file. 4 years ago

README.md

pynit

an integration between saved reddit posts and pinboard.

specifically, comments and posts saved to your reddit user profile can be pulled into pinboard through this project. the following information is pulled down and used when pinning to pinboard:

  • subreddit (becomes a tag)
  • post title (becomes title)
  • post description, if it exists (becomes description)
  • post url (becomes url)

the tag "added-by-pynnit" is also added to each entry moved to pinboard in this way. This allows for easy viewing of all imported links. I found this very useful when I was writing the script in the first place, but you may not want it.

Using this bullshit

Installing

I use pipenv pretty exclusively because of how it works with my editor. that's the only package manager i've actually tested with, but theoretically the typical pip install -r requirements.txt should work just fine.

Setting up the environment

You need several things to use this project:

  • Reddit username
  • Reddit password
  • Reddit client ID
  • Reddit client secret
  • Pinboard api key

Your reddit un/pw you should already have. The client ID and client secret can be generated by following the instructions here: https://github.com/reddit-archive/reddit/wiki/oauth2

Your pinboard api key can be found here (assuming you are logged in): https://pinboard.in/settings/password/

You need to export these in your shell in the following format:

export REDDIT_UN=''
export REDDIT_PW=''
export REDDIT_ID=''
export REDDIT_SECRET=''
export PINBOARD_TOKEN=''

Then run the following commands, in the order given:

python main.py
python pinboard.py

Pulling reddit posts through the main.py file is very fast. The pinboard step, however, is quite slow. The API docs published by pinboard require that you only make a call once per 3 seconds, so if you're adding a lot of entries at once (say, during the intial move over) this can take a while, but its still fast enough for my purposes.

Information / my shit

Outline:

Getting data from reddit

  • refactor to use praw instead of requests
    • praw has more functionality more obviously than I can figure out with requests.
    • its aggrevating.
  • Figure out how to pull the entire list
    • in praw this is done through "limit=None" arg.
  • Figure out how to enable pulling NSFW items
    • in praw this is actually just done by default
  • Figure out how to differentiate between self.posts, link.posts, and comments
    • each one will have different fields but REDDIT DOESN'T DOCUMENT THIS
    • because reddit is stupid, that's why, i guess.

Putting data in pinboard

So far i've done nothing.

  • Get auth token to work
    • Finally got this to work; I had a fundamental mistunderstanding of what pinboard meant by "method" in the URL.
  • Figure out how to pull existing posts
  • Figure out how to post an item to my feed as public
  • Figure out how to post an item to my feed as private
  • Enable a conditional; NSFW items get posted as private, regular items as public.
  • Iterate through a list.

Information about reddit (i'm so sorry)

So, there are multiple kinds of reddit posts, and each kind of reddit post seems to have distinct names for the same things, which is REALLY fucking annoying. Its extra frustrating because there's not just a quick lookup for this, you have to just dig through Too Much json.

If you're using PRAW, a reddit /post/ has an attribute called .is_self that's boolean. If its true, its a text only post, if its false then its a link post.

Reddit /comments/ do not have this attribute. They DO have an attribute called .is_root, which i use to differentiate themm.