Unofficial Google Photos Python library
Project description
gPhotoSpy
Interact with Gooogle Photos in Python
Usage
This library is experimental.
However, most of the API is covered, and it could be used for personal expriments at least.
Example working with albums; 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
CLIENT_SECRET_FILE = "gphoto_oauth.json"
# 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)
Check the examples folder for more examples of use.
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 (coming up soon)
- 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
Quick guide:
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).
- Fork it (https://github.com/davidedelpapa/gphotospy/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
License
MIT, see the LICENSE file.
About me
Too shy to talk about it (not true). THis project though has been a relief during COVID lockdown.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gphotospy-0.1.0.tar.gz
.
File metadata
- Download URL: gphotospy-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6770fd1223190ec5f93304107d147b3cb289d17bcf5ec30608c571dae0f0b868 |
|
MD5 | 51f68a90f699dddce045dc92bc266478 |
|
BLAKE2b-256 | 500cb3f5cb27616bcd2f5376b6c730610f04f3ab411b72bbd019cd2630873aa5 |
File details
Details for the file gphotospy-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: gphotospy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d987db1867aceee728c3dc7a67e0e1b5d045ed0511ac777dcc4955b9cb442969 |
|
MD5 | 82ff7e66f70bf2444ddc788fb2de7f29 |
|
BLAKE2b-256 | 0db565b2d92dae73abe91725f8045485646446de7a8ef516bbb9f880608af7a8 |