示例#1
0
文件: main.py 项目: Pirnazar/gphoto
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)
示例#2
0
文件: main.py 项目: Pirnazar/gphoto
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
示例#3
0
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
示例#4
0
def main():
    service = authorize.init('credentials.json')

    new_albums = mainname_to_id(service)
    create_albums(service, new_albums)