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)
# 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)
# 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()
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')}
# 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)
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']
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']