This project was an evening endeavor aimed at organizing a personal Google Photos library. However, due to limitations in the Google Photos API, the project's functionality is severely restricted and is no longer being actively developed.
Google Photos API has restrictions on how third-party applications can interact with user data:
- Applications can only add media items that they have uploaded to albums they have created.
- Existing media items in a user's library cannot be added to new albums created by third-party applications.
These limitations effectively prevent this application from organizing existing photos into new albums, which was the primary goal of this project.
Due to these API limitations, the current script can only:
- Authenticate with Google Photos
- Fetch existing media items for a specified year
- Create a new album
However, it cannot add the fetched media items to the newly created album.
This situation highlights the challenges users face when trying to gain more control over their personal data stored in cloud services. While Google Photos provides a great service for storing and viewing photos, the restrictions on the API make it difficult for users to organize their libraries in ways that best suit their needs using third-party tools.
The limitations of the Google Photos API raise several concerns:
-
Data Portability: The inability to easily organize or export photos limits users' ability to manage their data effectively or migrate to other services.
-
Vendor Lock-in: These restrictions can create a form of vendor lock-in, making it challenging for users to switch to alternative services or create local backups.
-
Long-standing Issues: The API limitations have been a point of discussion since at least 2019, with no significant changes made to address these concerns [1].
-
Uncertain Future: Given Google's history of sunsetting products (e.g., Google Music), users may feel uncertain about the long-term availability of their data [2].
-
Pricing and Terms Changes: Without easy data portability, users are more vulnerable to potential changes in pricing or terms of service.
While it's understandable that Google needs to balance user privacy, security, and business interests, greater flexibility in the API could significantly benefit users without compromising these aspects. As consumers increasingly value data ownership and portability, addressing these limitations could enhance user trust and satisfaction with the Google Photos service.
For more details on the API limitations, see this issue tracker discussion.
This project aimed to organize existing media items in a user's Google Photos library into albums based on the year they were taken.
-
Set up Google Cloud project and enable the Photos Library API.
-
Install required dependencies:
pip install google-auth-oauthlib google-auth-httplib2 google-api-python-client -
Run the script:
python photo_album_creator.py <year> [--no-dryrun] [-v] [--include-archived]Options:
<year>: The year for which to create the album (required)--no-dryrun: Perform actual write operations (default is dry run)-v: Increase output verbosity--include-archived: Include archived media items
-
Create a Google Cloud Project:
- Go to the Google Cloud Console.
- Click on the project dropdown at the top and select "New Project".
- Give your project a name and click "Create".
-
Enable the Google Photos Library API:
- In the Google Cloud Console, go to the API Library.
- Search for "Google Photos Library API" or use this direct link.
- Click the "Enable" button.
-
Create OAuth 2.0 credentials:
- Go to the Credentials page.
- Click "Create Credentials" and select "OAuth client ID".
- If prompted, configure the OAuth consent screen:
- Choose "External" as the user type.
- Fill in the required fields.
- Add "localhost" to "Authorized domains" for testing.
- Add the scope:
https://www.googleapis.com/auth/photoslibrary.readonly - Save and continue.
- Choose "Desktop app" as the application type.
- Give your OAuth 2.0 client a name and click "Create".
-
Download the client configuration:
- After creating the OAuth client ID, download the client configuration file.
- Rename it to
client_secret.jsonand place it in the project directory.
-
Set up the Python environment:
- Ensure Python 3.7+ is installed.
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
- Windows:
- Install required packages:
pip install -r requirements.txt
-
Add yourself as a test user:
- Go to the Google Cloud Console.
- Select your project.
- Navigate to "APIs & Services" > "OAuth consent screen".
- Scroll down to the "Test users" section.
- Click "Add Users".
- Add your Google email address.
- Save the changes.
-
Run the script:
python photo_album_creator.py <year> [--no-dryrun] [-v] [--include-archived]The script will provide a URL and a code. You need to:
- Visit the URL on a device with a web browser.
- You may see a warning about the app being unverified. Click "Continue" to proceed.
- Enter the code provided by the script.
- Complete the authentication process in the browser.
- Return to the CLI, where the script will continue execution once authentication is complete.
-
Subsequent runs will use saved credentials in
token.pickle.
photo_album_creator.py: Main script for the application.requirements.txt: List of Python package dependencies..gitignore: Specifies intentionally untracked files to ignore.README.md: This file, containing setup instructions and project overview.
Keep your client_secret.json file secure and never share it publicly. The .gitignore file is set up to prevent accidental commitment of sensitive files.
[1] Google Issue Tracker. (2019). "Allow adding existing media items to albums." https://issuetracker.google.com/issues/132274769
[2] Welch, C. (2020). "Google is shutting down its Play Music service in September." The Verge. https://www.theverge.com/2020/8/4/21354136/google-play-music-shutdown-youtube-music-transfer-date