def gphoto_upload(album_id, file): from gphotospy import authorize from gphotospy.media import Media from gphotospy.album import Album CLIENT_SECRET_FILE = "gphoto_oauth.json" service = authorize.init(CLIENT_SECRET_FILE) album_manager = Album(service) media_manager = Media(service) media_manager.stage_media(file) media_manager.batchCreate(album_id=album_id)
def create_album(title): from gphotospy import authorize from gphotospy.media import Media from gphotospy.album import Album CLIENT_SECRET_FILE = "gphoto_oauth.json" service = authorize.init(CLIENT_SECRET_FILE) album_manager = Album(service) new_album = album_manager.create(title) id_album = new_album.get("id") return id_album
from gphotospy import authorize from gphotospy.sharedalbum import SharedAlbum from gphotospy.album import Album from googleapiclient.errors import HttpError # Select secrets file CLIENT_SECRET_FILE = "gphoto_oauth.json" # Get authorization and return a service object service = authorize.init(CLIENT_SECRET_FILE) # Init the media manager sharing_manager = SharedAlbum(service) # Set default behaviors sharing_manager.show_only_created(False) # Get iterator over the list of shared albums print("Getting a list of shared albums...") album_iterator = sharing_manager.list() # Loop first 3 elements for _ in range(3): try: # Print only albums's title (if present, otherwise None) print(next(album_iterator).get("title")) except (StopIteration, TypeError) as e: # Handle exception if there are no media left print("No (more) shared albums.") break
def main(): service = authorize.init('credentials.json') new_albums = mainname_to_id(service) create_albums(service, new_albums)