summaryrefslogtreecommitdiff
path: root/app/syndication/syndicators.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2016-07-12 12:56:18 -0400
committerluxagraf <sng@luxagraf.net>2016-07-12 12:56:18 -0400
commitfdd5ccd0bf899c9cd85aa13882d9bee730fce501 (patch)
treee365548498f243c9e0303e4ab470586ad1a18e0b /app/syndication/syndicators.py
parent36c090402e9916b1920bbf48de306135e44a354f (diff)
tinkered with syndication, still not there
Diffstat (limited to 'app/syndication/syndicators.py')
-rw-r--r--app/syndication/syndicators.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/syndication/syndicators.py b/app/syndication/syndicators.py
index 9393d4d..764f455 100644
--- a/app/syndication/syndicators.py
+++ b/app/syndication/syndicators.py
@@ -1,3 +1,4 @@
+import os
from django.conf import settings
from django.test.client import Client
@@ -51,7 +52,7 @@ def post_to_twitter(obj, ctype):
t = Twython(settings.TWITTER_API_KEY, settings.TWITTER_API_SECRET, settings.TWITTER_ACCESS_TOKEN, settings.TWITTER_ACCESS_SECRET)
imgs = []
if ctype == "lux image":
- p = open(obj.get_image_path_by_size("2280"), 'rb')
+ p = open(obj.get_largest_image(), 'rb')
if obj.caption:
status = obj.caption
else:
@@ -66,7 +67,7 @@ def post_to_twitter(obj, ctype):
for img in soup.find_all('img'):
src = img['src'].split("images/")[1]
i = LuxImage.objects.get(image__icontains=src)
- p = open(i.get_image_path_by_size("2280"), 'rb')
+ p = open(i.get_largest_image(), 'rb')
response = t.upload_media(media=p)
imgs.append(response)
loop = loop+1
@@ -95,9 +96,9 @@ def post_to_twitter(obj, ctype):
def post_photo_to_flickr(photo):
- flickr = flickrapi.FlickrAPI(settings.FLICKR_API_KEY, settings.FLICKR_API_SECRET)
- flickr.auth_url(perms='write')
- flickr.get_access_token(settings.FLICKR_VERIFIER)
+ TOKEN_FILE = os.path.join(settings.PROJ_ROOT, "config/flickrToken")
+ token = open(TOKEN_FILE).read()
+ flickr = flickrapi.FlickrAPI(settings.FLICKR_API_KEY, settings.FLICKR_API_SECRET, token=token)
sent = flickr.upload(filename=photo.get_image_path_by_size("original"), title=photo.title, description=photo.caption)
photo_id = sent.find('photoid').text
photo.flickr_id = photo_id
@@ -112,7 +113,7 @@ def post_to_facebook(obj, ctype):
token = FBOAuthToken.objects.latest()
graph = facebook.GraphAPI(access_token=token.long_token, version='2.2')
if ctype == "lux image":
- p = open(obj.get_image_path_by_size("2280"), 'rb')
+ p = open(obj.get_largest_image(), 'rb')
if obj.caption:
message = obj.caption
else: