diff options
author | luxagraf <sng@luxagraf.net> | 2016-03-31 11:09:08 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2016-03-31 11:09:08 -0400 |
commit | 9bc9b213fb5849b20c965b7bd6695b5796ba19ae (patch) | |
tree | bfe475dee42e6ebc814fb1d6c0f270df3627f814 /app/syndication/syndicators.py | |
parent | f81d4cdc61baf6904746ace7226eb6031de32b1a (diff) |
added support for Facebook Instant Articles to syndication app
Diffstat (limited to 'app/syndication/syndicators.py')
-rw-r--r-- | app/syndication/syndicators.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/app/syndication/syndicators.py b/app/syndication/syndicators.py index de157af..82b9564 100644 --- a/app/syndication/syndicators.py +++ b/app/syndication/syndicators.py @@ -1,7 +1,8 @@ from django.conf import settings +from django.test.client import Client from bs4 import BeautifulSoup -from medium import Client +from medium import Client as MediumClient def absolute_urls_for_syndication(s): @@ -9,11 +10,11 @@ def absolute_urls_for_syndication(s): for a in soup.find_all('a'): if a['href'][:1] == "/": a['href'] = "https://luxagraf.net%s" % a['href'] - print(soup) + return soup def post_to_medium(item): - client = Client(application_id=settings.MEDIUM_CLIENT_ID, application_secret=settings.MEDIUM_CLIENT_SECRET) + client = MediumClient(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 = '<p><i>This was originally posted <a href="https://luxagraf.net%s" rel="canonical">on my own site</a>.</i></p>' % item.get_absolute_url() @@ -29,3 +30,11 @@ def post_to_medium(item): license="all-rights-reserved" ) return post["url"] + + +def build_facebook_feed(item): + c = Client() + response = c.get('/iafeed.xml', HTTP_HOST='127.0.0.1') + f = open("%siafeed.xml" % settings.FLATFILES_ROOT, 'wb') + f.write(response.content) + f.close() |