예제 #1
0
import sys
import os
import logging

# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### First get all albums for a user so we have an object to work with
###
### A good sequence to run this example is to do albums_create.py first.
### This will create an album called 'APITestAlbum' for testing purposes.
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    if (albumitem['name'] == 'APITestAlbum'):
        selected_album = albumitem['id']
        break

eyefi.Albums().delete(selected_album)
예제 #2
0
# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### First search all the user's albums for the 'APITestAlbum' album so we have an object to work with
###
### A good sequence to run this example is to do albums_create.py first
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    if (albumitem['name'] == 'APITestAlbum'):
        selected_album = albumitem['id']
        break

###
### Now update the album twice - once to rename to APITestAlbumTest and once to rename it back.
###

data = {'name': 'APITestAlbumTest'}
eyefi.Albums().update(selected_album, data)

data = {'name': 'APITestAlbum'}
eyefi.Albums().update(selected_album, data)
예제 #3
0
# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### First search all the user's albums for the 'APITestAlbum' album so we have an object to work with
###
### This album will have it's photo order reversed
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    if (albumitem['name'] == 'APITestAlbum'):
        selected_album = albumitem['id']
        break

###
### Now get the photos in the album so there is one to remove.  Note that Albums().get_files() returns
### a bare list of items.  This is slightly different from Files().get().
###

fileitems = eyefi.Albums().get_files(selected_album)['items']

fileitems.reverse()
예제 #4
0
import logging

# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### First search all the user's albums for the 'APITestAlbum' album so we have an object to work with
###
### A good sequence to run this example is to do albums_create.py first
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    if (albumitem['name'] == 'APITestAlbum'):
        selected_album = albumitem['id']
        break

###
### Now get the photos in the album so there is one to remove.
###

fileitems = eyefi.Albums().get_files(selected_album)['items']
eyefi.Albums().remove_file(selected_album, fileitems[0]['id'])
###
### This is a small folder uploader.  It will get a list of .jpg files in the current directory, upload them,
### create an album named after the parent directory, and add the photos to the new album.
###

### Get list of files in current directory (case insensitive *.jpg))

fileitems = fnmatch.filter(os.listdir(os.getcwd()), '*.[Jj][Pp][Gg]')

### Find our parent directory name for the Album

albumname = os.path.basename(os.path.abspath(os.getcwd()))

### Create the album

albumresponse = eyefi.Albums().create({'name': albumname})
albumid = albumresponse['id']
if (albumid == None):
    print 'Album ' + albumname + ' failed to create.'
    exit(-1)

print 'Created Album ' + albumname

### Upload the photos and attach them to the album

for fileitem in fileitems:
    ### Get the file modified time and use as date_time_taken..
    datetimestampformatted = time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime(os.path.getmtime(fileitem)))
    data = {'date_time_taken': datetimestampformatted}

    files = {fileitem: open(fileitem,'rb')}
예제 #6
0
# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### First search all the user's albums for the 'APITestAlbum' album so we have an object to work with
###
### A good sequence to run this example is to do albums_create.py first
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    if (albumitem['name'] == 'APITestAlbum'):
        selected_album = albumitem['id']
        break

###
### Now grab 3 files to add to the album.  A list of files is stored under the 'items' key returned
### from Files().get()
###

fileitems = eyefi.Files().get()['items']
del fileitems[3:]

eyefi.Albums().add_files(selected_album, fileitems)
예제 #7
0
import sys
import os
import logging

# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### API Call is Albums().create(albumdata) - create an album with the attributes specified in albumdata
### as a dictionary
###

albumdata = {'name': 'APITestAlbum'}
albumitem = eyefi.Albums().create(albumdata)

print 'Album ' + str(
    albumitem['id']) + ' created with name ' + albumitem['name']
예제 #8
0
import sys
import os
import logging

# Temporary until real install is setup
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../lib'))

import eyefi

logging.basicConfig(level=logging.INFO)

eyefi.set_token(eyefi.get_home_token())

###
### API Call is Albums().get() - list all albums for user
###

albumitems = eyefi.Albums().get()

for albumitem in albumitems:
    print str(albumitem['id']) + ' ' + albumitem['name']