Package: gphotospy
gPhotoSpyInteract with Google Photos in PythonNOTE: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 (SeeIssue#12).InstallationYou can use Pypi distribution (recommended method):pipinstallgphotospyOtherwise clone this repo and use the modules ingphotospydirectly (not recommended).Usage examplesThis library is unofficial; most of the API is covered, however no proper test coverage has been implemented so far.Please refer toGoogle'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 agphoto_oauth.jsonfile).fromgphotospyimportauthorizefromgphotospy.albumimportAlbum# 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 objectservice=authorize.init(CLIENT_SECRET_FILE)# Init the album manageralbum_manager=Album(service)# Create a new albumnew_album=album_manager.create('test album')# Get the album id and share itid_album=new_album.get("id")album_manager.share(id_album)ExamplesCheck theexamplesfolder for more examples of use.TutorialsCheck thewikifor tutorialsAPI CoverageOAuth authorizationGoogle server uploadSimple uploaderResumable uploaderAlbumsaddEnrichmentbatchAddMediaItemsbatchRemoveMediaItemscreategetlistshareunshareMediaItemsbatchCreatebatchGetgetlistsearchSharedAlbumsgetjoinleavelistTest CoverageNot 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.DocumentationDocstringsExamples[-] Tutorials (See the wiki)API docs (must be improved though)Near future plansThese are the next steps:Finish DocumentationMock testsResumable UploadsObjects representationsMediaAlbum...Accepting ideas, so don't be shy and put them forth!Set up authorizationBrowse throughGoogle's authorization guideQuick recap:Go toGoogle Cloud Console.
Set up a new project, then on the menu select:Api & Services>Library.
In the library, search for "photos", selectPhoto Library APIand click on theENABLEbutton.
On theAPI & Services, Photo Library APIselectCredentials, and select the+CREDENTIALSand select in the dropdownOAuth 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.jsonfile 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 useContributingPlease give me some heads up if you are working on an interesting feature to add togphotospybefore 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 RequestLicenseMIT, see theLICENSEfile.ChangelogV. 0.1.2: Added media item object representationV. 0.1.1: Added documentationV. 0.1.0: Fisrt usable versionAbout meToo shy to talk about it (not true). This project though has been a relief during COVID lockdown.