コード例 #1
0
ファイル: photo.py プロジェクト: thomasw/creepytown
    def size_data(self):
        "Data about this photo from the getSizes endpoint."
        try:
            return self._sizes
        except AttributeError:
            sizes = normalize_json(API.photos_getSizes(photo_id=self.id))
            self._sizes = dotdict(sizes['sizes'])

        return self._sizes
コード例 #2
0
ファイル: sets.py プロジェクト: thomasw/creepytown
def index_set_photos(photoset, index):
    """Add all photos in photoset to the specified DownloadIndex."""
    photos = normalize_json(API.photosets_getPhotos(photoset_id=photoset.id))
    photos = dotdict(photos['photoset'])

    # TODO: We need to add pagination support for big sets.
    assert int(photos.total) == len(photos.photo), "This user has set with too many photos."

    print "Indexing the %s photos in this set:\n" % photos.total

    for idx, photo in enumerate(photos.photo, 1):
        photo = Photo(photo)

        print "%s. %s" % (idx, photo.details)

        index.add_to_index(photo, photoset)
コード例 #3
0
ファイル: photostream.py プロジェクト: thomasw/creepytown
def index_all_photostream_photos(user_id, index):
    """Add the user's photostream photos to the specified DownloadIndex"""
    print "Inspecting photostream of user %s..." % user_id

    count = 1

    for output in Paginator(API.people_getPublicPhotos, user_id=user_id):
        stream = normalize_json(output)
        stream = dotdict(stream['photos'])

        print "\nIndexing page %s of %s:\n" % (stream.page, stream.pages)

        total = stream.total

        for photo in stream.photo:
            photo = Photo(photo)

            print "%s. %s" % (count, photo.details)

            index.add_to_index(photo)
            
            count += 1

    print "\n%s photostream photos found." % total
コード例 #4
0
ファイル: sets.py プロジェクト: thomasw/creepytown
def get_sets(user_id):
    """Retrieve a listing of the specified user's sets."""
    sets = normalize_json(API.photosets_getList(user_id=user_id))
    return dotdict(sets['photosets'])