From d39834b0ba34c9f67d85b6168c75d4d2e947c5ab Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 31 Mar 2016 09:53:33 -0400 Subject: renamed medium to syndicators --- app/syndication/medium.py | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 app/syndication/medium.py (limited to 'app/syndication/medium.py') diff --git a/app/syndication/medium.py b/app/syndication/medium.py deleted file mode 100644 index de157af..0000000 --- a/app/syndication/medium.py +++ /dev/null @@ -1,31 +0,0 @@ -from django.conf import settings - -from bs4 import BeautifulSoup -from medium import Client - - -def absolute_urls_for_syndication(s): - soup = BeautifulSoup(s, "lxml") - for a in soup.find_all('a'): - if a['href'][:1] == "/": - a['href'] = "https://luxagraf.net%s" % a['href'] - print(soup) - - -def post_to_medium(item): - client = Client(application_id=settings.MEDIUM_CLIENT_ID, application_secret=settings.MEDIUM_CLIENT_SECRET) - client.access_token = settings.MEDIUM_INT_TOKEN - user = client.get_current_user() - head = '

This was originally posted on my own site.

' % item.get_absolute_url() - body = "%s %s" % (head, absolute_urls_for_syndication(item.body_html)) - # Create a post. - post = client.create_post( - user_id=user["id"], - title=item.title, - content=body, - content_format="html", - publish_status="public", - canonicalUrl="https://luxagraf.net%s" % item.get_absolute_url(), - license="all-rights-reserved" - ) - return post["url"] -- cgit v1.2.3-70-g09d2