From fdd5ccd0bf899c9cd85aa13882d9bee730fce501 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Tue, 12 Jul 2016 12:56:18 -0400 Subject: tinkered with syndication, still not there --- app/syndication/syndicators.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/syndication/syndicators.py') 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: -- cgit v1.2.3-70-g09d2