예제 #1
0
    def get_context_data(self,**kwargs):
        context = super(Albums, self).get_context_data(**kwargs)
        flickr_api.enable_cache(cache)
        flickr_api.set_keys(api_key=settings.FLICKR_API,api_secret=settings.FLICKR_SECRET)
        user = flickr_api.Person.findByUserName('aloinargixao')
        photosets = user.getPhotosets()

        albums = []
        for photoset in photosets:
            pic = photoset.getPhotos()[:1]
            thumb_source = pic[0].getSizes()['Small']['source']
            dict = {'id':photoset.id,'title':photoset.title,'pic':thumb_source}
            albums.append(dict)

        context['albums'] = albums
        context["active"] = "album"
        return context
예제 #2
0
from django.conf import settings
from django.db import models
from django.template.defaultfilters import slugify
import flickr_api
from flickr_api.method_call import call_api

# Enable caching
from django.core.cache import cache
flickr_api.enable_cache(cache)


class Portfolio(object):

    def __init__(self, user_id):
        """
        sections is a dictionary with keys as a title of the section and values as the flickr set ID for items to display in that section
        """
#        self.user = flickr_api.Person(id=user_id) # Not currently used
        self._sections = []

    def setSections(self, section_settings):
        for section in section_settings:
            self._sections.append(PortfolioSection(section['title'], section['photoset_id']))

    def getSections(self):
        return self._sections


class PortfolioSection(object):

    def __init__(self, title, photoset_id):
예제 #3
0
def enable_cache(enable):
    if enable:
        f.enable_cache()
    else:
        f.disable_cache()
예제 #4
0

if __name__ == "__main__":
    parser = argparse.ArgumentParser("Explorify dataset generator")
    parser.add_argument('-c',
                        '--city',
                        type=str,
                        default="atlanta",
                        help="City to get pictures from")
    parser.add_argument('-r',
                        '--radius',
                        type=float,
                        default=20.0,
                        help="Radius of the city to cover (in km)")
    parser.add_argument('-m',
                        '--max-photos',
                        type=int,
                        default=int(1e4),
                        help="Maximum number of photos to store")
    parser.add_argument('-d',
                        '--dataset-file',
                        type=str,
                        default="./dataset.h5",
                        help="Path to h5 file to create")
    args = parser.parse_args()

    flickr_api.enable_cache()
    api_credentials = load_credentials()
    generate(api_credentials, args.city, args.radius, args.max_photos,
             args.dataset_file)
예제 #5
0
"""
FlickrBox
"""

import os
from pathlib import Path
import time
import logging
import _thread

import flickr_api as flickr
from watchdog.observers import Observer
import watchdog.events

flickr.enable_cache()

logging.basicConfig(format='- %(message)s', level=logging.DEBUG)


class Flickrbox:
    """
    In-memory representation of Flickr library
    """
    # https://help.yahoo.com/kb/flickr/photo-file-formats-sln8771.html
    valid_extensions = [".jpg", ".jpeg", ".png", ".gif"]

    def __init__(self, dirname="FlickrBox", path=Path.home(), sync=False):
        self.dirname = dirname
        self.path = os.path.join(path, dirname)

        self._upload_tickets = {}
예제 #6
0
def start(keyfile=None, authfile=None):
    _set_keys(keyfile)
    _set_auth(authfile)
    flickr_api.enable_cache()
    return flickr_api