diff options
Diffstat (limited to 'apps/links/utils.py')
-rw-r--r-- | apps/links/utils.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/apps/links/utils.py b/apps/links/utils.py index 2649dde..d8463e0 100644 --- a/apps/links/utils.py +++ b/apps/links/utils.py @@ -68,6 +68,51 @@ def sync_magnolia_links(*args, **kwargs): send_to_deliciousfb(l) if(dupe): break + +def sync_delicious_links(*args, **kwargs): + b = delicious.get(settings.DELICIOUS_USER, settings.DELICIOUS_PASS) + dupe = False + for post in b['posts']: + taglist = [] + try: + row = Link.objects.get(magnolia_id=safestr(post['hash'])) + # If the row exists already, set the dupe flag + dupe = True + except ObjectDoesNotExist: + #f = copy_file(safestr(post.findtext('screenshot')), safestr(info['id'])) + #fake the image since delicious doesn't offer them + local_image_url = "%s/%s.jpg" %(safestr(datetime.datetime.today().strftime("%b").lower()), safestr(post['hash'])) + tags = str(post['tag']).split(" ") + for tag in tags: + taglist.append(tag) + for tag in taglist: + if tag == '2lux': + status = 1 + break + else: + status = 0 + descr = markdown.markdown(unquotehtml(safestr(post['extended'])), safe_mode = False) + l, created = Link.objects.get_or_create( + title = post['description'], + magnolia_id = safestr(post['hash']), + url = safestr(post['href']), + description = descr, + screen_url = local_image_url, + #fake the rating since delicious doesn't offer such things + rating = "3", + pub_date = datetime.datetime.strptime(post['time'], "%Y-%m-%dT%H:%M:%SZ"), + status = status, + enable_comments = True, + tags = ", ".join(t for t in taglist if t != "2lux") + ) + + email_link(l) + if l.status == 1: + post_to_tumblr(l) + send_to_deliciousfb(l) + if(dupe): + break + """ b, created = Link.objects.get_or_create( url = info['href'], @@ -102,7 +147,7 @@ def sync_magnolia_links(*args, **kwargs): pub_date = datetime.datetime(*(time.strptime(str(b.created[:-6]), '%Y-%m-%dT%H:%M:%S')[0:6])), status = public, enable_comments = True, - tags=", ".join(t.name for t in b.tags.tag if t.name != "2lux") + ) email_link(l) send_to_delicious(l) |