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.
josiah 4a7dec3c97
Update some dumb grammar rules.
3 years ago
.gitignore Ignore changes to template.sh so i don't accidentally commit creds. 4 years ago
README.md Update to be ~~~professional~~~ 4 years ago
poetry.lock Move from pipenv to poetry, since that's what the Cool Kids do now. 4 years ago
pynit.py Update some dumb grammar rules. 3 years ago
pyproject.toml Move from pipenv to poetry, since that's what the Cool Kids do now. 4 years ago
requirements.txt Generate actual pipfiles, requirements file. 4 years ago
unlicense add license 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

installing

I use poetry a lot. ~poetry install~ should do you 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 then pass those variables as arguments to the script when run:

syncing posts from reddit

☭ python pynit.py --reddit-un '' --reddit-pw '' --reddit-cid '' --reddit-sec '' --pb-apikey ''

fill in your information and off you go!

updating tags

To be specific, this allows you to update tags in bulk; if you have 80 items under the 'clothing' tag, and 40 items under the 'clothes' tag you can combine them by running this code ☭ python pynit.py -rt --pb-apikey ''

You will then be asked for the tag you want to replace, and what you want to replace it with. This is an entirely pinboard side operation so you don't need any reddit credentials for this.

running in debug mode

☭ python pynit.py -d --reddit-un '' --reddit-pw '' --reddit-cid '' --reddit-sec '' --pb-apikey ''

Thanks to @micah for this. I can't believe there's still so much I don't know about pdb!! The -d flag will do nothing unless the script encounters an exception. If it does, it'll dump you into the pdb.pm() dbg repl. Its SUPER useful while you're tweaking stuff / catching idiot mistakes with your password/mfa/whatever.

background and additional information

getting data from reddit

if you don't have MFA set up for your account (you should do that) then this is easy. everything works as expected. BUT if you DO have MFA set up let me tell you: this gets dumber. when you enter your reddit password you have to also include an active MFA 6 digit code, like this:

... --redditpw "thing:123123"

so good.

putting data in pinboard

This is 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.

bonus (cursed?) 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.

roadmap

  • move reddit/pinboard script to single file.
  • make the script take command line arguments (i.e. must pass -reddit if you want to sync saved posts)
  • write new function update_tags that will take a tag and retag to a new name (add a cli flag)
  • remove requirement for unnecessary creds when doing pinboard specific operations
  • move to poetry from pipenv