Skip to main content

gPhotoSpy

Interact with Google Photos in Python

PyPI version Documentation Status License: MIT

NOTE: Updated to Google API 2.0.0; please update this package to the new version.

Sorry for breaking some compatibility here, but Google has had some small changes under the hood, which require this update (See Issue#12).

Installation

You can use Pypi distribution (recommended method):

pip install gphotospy

Otherwise clone this repo and use the modules in gphotospy directly (not recommended).

Usage examples

This library is unofficial; most of the API is covered, however no proper test coverage has been implemented so far.

Please refer to Google's authorization guide (recommended), or see the below "Set up authorization" for a quick review on how to get Google's API keys and authorization (save it in a gphoto_oauth.json file).

from gphotospy import authorize
from gphotospy.album import Album

# Select secrets file (got through Google's API console)
CLIENT_SECRET_FILE = "gphoto_oauth.json" # Here your secret's file. See below.

# Get authorization and return a service object
service = authorize.init(CLIENT_SECRET_FILE)

# Init the album manager
album_manager = Album(service)

# Create a new album
new_album = album_manager.create('test album')

# Get the album id and share it
id_album = new_album.get("id")
album_manager.share(id_album)

Examples

Check the examples folder for more examples of use.

Tutorials

Check the wiki for tutorials

API Coverage

  • OAuth authorization
  • Google server upload
    • Simple uploader
    • Resumable uploader
  • Albums
    • addEnrichment
    • batchAddMediaItems
    • batchRemoveMediaItems
    • create
    • get
    • list
    • share
    • unshare
  • MediaItems
    • batchCreate
    • batchGet
    • get
    • list
    • search
  • SharedAlbums
    • get
    • join
    • leave
    • list

Test Coverage

Not yet implemented. The tests have been done "live" on my account. I'm planning to set up mock tests for this suite, just for regression purposes.

Documentation

  • Docstrings
  • Examples
  • [-] Tutorials (See the wiki)
  • API docs (must be improved though)

Near future plans

These are the next steps:

  • Finish Documentation
  • Mock tests
  • Resumable Uploads
  • Objects representations
    • Media
    • Album
    • ...

Accepting ideas, so don't be shy and put them forth!

Set up authorization

Browse through Google's authorization guide

Quick recap:

Go to Google Cloud Console. Set up a new project, then on the menu select: Api & Services > Library. In the library, search for "photos", select Photo Library API and click on the ENABLE button. On the API & Services, Photo Library API select Credentials, and select the +CREDENTIALS and select in the dropdown OAuth client ID. Select the type of app to be created (for desktop application select "other") and give it a name. If you are an occasional user, you should before this thing select the authorization display (OAuth Consent Screen), and make it public (if you are not a g-Suite user $$$. THe interface prompts you already to do so, if never done before). After this, coming back to the main interface, select in the row of the OAuth 2.0 Client ID just created the download button (rightmost one). Download the .json file in the root of the project, and give it a meaningful name (because it must be used afterwards). Remember to keep all these secret files far from git pushes, so if you are committing your porject to a repository, add the downloaded file to the .gitignore.

Once run the authentication it should open a browser to authenticate. If you are creating a project for non commercial use you need not apply for review, but you have to allow it, because Google show a big message of warining. Clicking on advanced, it shows the button to allow the authorization, even though the app is not reviewed by Google (useful for tests and personal use projects). A .token file will keep the authorization for further use

Contributing

Please give me some heads up if you are working on an interesting feature to add to gphotospy before a PR (well, even afterwards it's ok).

  1. Fork it (https://github.com/davidedelpapa/gphotospy/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

MIT, see the LICENSE file.

Changelog

  • V. 0.1.2: Added media item object representation
  • V. 0.1.1: Added documentation
  • V. 0.1.0: Fisrt usable version

About me

Too shy to talk about it (not true). This project though has been a relief during COVID lockdown.

Release files for gphotospy 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gphotospy 0.2.1
File Size Uploaded
gphotospy-0.2.1.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gphotospy 0.2.1
File Interpreter ABI Platform
gphotospy-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 37.4 kB

Release files / gphotospy-0.2.1.tar.gz

Download URL gphotospy-0.2.1.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1d5417e277381751a858435f440504102c0188c7ae12c954fd85f0c3eadbcf79
BLAKE2b-256 checksum
How to use checksums
8baa5024544da29a2fd6cff020fd9fe59bb971ff41c11d2d3dbd3a6b971b3d90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

Release files / gphotospy-0.2.1-py3-none-any.whl

Download URL gphotospy-0.2.1-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
572ee87dafd7ac1eb1c37f1feae871c37dfcd38d394208f649d65ed876463130
BLAKE2b-256 checksum
How to use checksums
4a566d0be5f8c0fb184e8bb3ac588f2892ebd9fe8ea52ae64335721b2fe108f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page