summaryrefslogtreecommitdiff
path: root/app/links/retriever.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-11-13 11:09:59 -0500
committerluxagraf <sng@luxagraf.net>2015-11-13 11:09:59 -0500
commit8d91fcde168b141ffa33173380e75739fdf45cd2 (patch)
tree8b9a4e493461df5bec0f60b846d0ce3e48d3f43c /app/links/retriever.py
parent92abffcc98404825324341d5ee654642364890bb (diff)
rewrote Links to make them more browse/earacble on live site and in
admin, also ported to CBVs/new build system and added back some templates for viewing. Deleted tumblr integration.
Diffstat (limited to 'app/links/retriever.py')
-rw-r--r--app/links/retriever.py34
1 files changed, 2 insertions, 32 deletions
diff --git a/app/links/retriever.py b/app/links/retriever.py
index 9aec34d..843487a 100644
--- a/app/links/retriever.py
+++ b/app/links/retriever.py
@@ -6,19 +6,18 @@ from django.core.mail import EmailMessage
from django.conf import settings
from links.models import Link
-# https://github.com/mgan59/python-pinboard/
-#import pinboard
import requests
import json
+
def sync_pinboard_links():
PB_URL = "https://api.pinboard.in/v1/posts/all?results=70&format=json"
r = requests.get(PB_URL, auth=((settings.PIN_USER, settings.PIN_PASS)))
links = json.loads(r.text)
for link in links:
try:
- #check to see if link exists
+ # check to see if link exists
row = Link.objects.get(link_id=link['hash'])
print("already have" + row.title)
except ObjectDoesNotExist:
@@ -37,35 +36,6 @@ def sync_pinboard_links():
l.tags.add(t)
email_link(l)
-"""
-def sync_pinboard_links_old():
- sync bookmarks from my pinboard account
- dependancies: python-pinboard https://github.com/mgan59/python-pinboard/
- p = pinboard.open(settings.PIN_USER, settings.PIN_PASS)
- dupe = False
- links = p.posts(count=30)
- for link in links:
- try:
- #check to see if link exists
- row = Link.objects.get(link_id=safestr(link['hash']))
- except ObjectDoesNotExist:
- l, created = Link.objects.get_or_create(
- title=link['description'],
- link_id=safestr(link['hash']),
- url=safestr(link['href']),
- description=safestr(link['extended']),
- rating="3",
- pub_date=datetime.datetime.strptime(link['time'], "%Y-%m-%dT%H:%M:%SZ"),
- status=0
- )
- print l.title
- if created:
- print l.title
- for t in link['tags']:
- l.tags.add(t)
- email_link(l)
-
-"""
def email_link(link):
"""