def __init__(self, pinboard_user, pinboard_pass, kippt_user, kippt_api_token): self.pinboard = pinboard.connect(username=pinboard_user, password=pinboard_pass) self.kippt = kippt.user(kippt_user, kippt_api_token) if not self.kippt.checkAuth(): raise Exception('Kippt credentials are invalid.')
def save(self): if not self.id and self.post_elsewhere: import pinboard from django.utils.encoding import smart_str pin = pinboard.connect(settings.PINBOARD_USER, settings.PINBOARD_PASS) pin.add(smart_str(self.url), smart_str(self.title), smart_str(self.description), smart_str(self.tags)) if self.description: self.description_html = markdown(self.description) super(Link, self).save()
def startup(): global pinboard_object msg("Pinboard linker script version " + version + ".") login = get_login() try: if len(login) == 1: pinboard_object = pinboard.connect(token=login[0]) else: pinboard_object = pinboard.open(login[0], login[1]) except HTTPError, e: if e.code == 401: err("Oops! Did you enter the correct login information?") else: err("Error! Unknown exception: " + str(e))
def get_posts_newer_than(datetime_threshold): p = pinboard.connect(PINBOARD_USERNAME, PINBOARD_PASSWORD) fromdt = str(datetime_threshold) #FIXME python-pinboard converts datetimes to date strings :( posts = p.posts(fromdt=fromdt, count=FETCH_LIMIT) return [p for p in posts if p.get('shared', 'yes') == 'yes']
# limitations under the License. import datetime import os from jinja2 import Environment, FileSystemLoader import pinboard import config def is_autoblog_tag(s): return s == config.PINBOARD_TAG p = pinboard.connect(token=config.PINBOARD_API_TOKEN) to_date = datetime.datetime.utcnow() days = datetime.timedelta(days=config.DAYS) from_date = to_date - days posts = p.posts(tag=config.PINBOARD_TAG, fromdt=from_date, todt=to_date) env = Environment(loader=FileSystemLoader('templates')) env.tests['autoblog_tag'] = is_autoblog_tag template = env.get_template('pelican.md') title = config.POST_TITLE_PREFIX + " " + to_date.strftime("%d %b %Y") slug = title.lower().replace(" ", "-") output = template.render(title=title, date=to_date.strftime("%Y-%m-%d"),
def get_posts_newer_than(datetime_threshold): p = pinboard.connect(PINBOARD_USERNAME, PINBOARD_PASSWORD) fromdt = str(datetime_threshold) #FIXME python-pinboard converts datetimes to date strings :( return p.posts(fromdt=fromdt, count=FETCH_LIMIT)