Due to recent changes to the Google Photos API, forcing users to choose which albums will be accessible, this project is no longer of much interest.
I am forced to archive it!
Remove all empty albums from a Google Photos account.
To retrieve the Google libraries needed to use the Google Photos REST API, follow these steps:
You can create your virtual environment with Python:
Under Linux or macOD:
python3 -m venv .venvUnder Windows:
python -m venv .venvUnder Linux or macOS:
source .venv/bin/activateUnder Windows:
-
In PowerShell:
.\.venv\Scripts\Activate.ps1
-
In Command Prompt:
.venv\Scripts\activate.bat
You will need the Google Auth libraries. You can install them using pip:
pip install --requirement requirements.txt
- Go to the Google Cloud console.
- Create a new project or select an existing one.
- Activate the Google Photos Library API for your project.
- Configure the OAuth 2.0 consent screen.
- Create OAuth 2.0 credentials and download the
credentials.jsonfile.
The script use the Selenium WebDriver to control your browser.
It only works with Google Chrome and Chromium browsers.
First, you need to be connected to your Google Account in the browser you will use.
usage: DeleteEmptyAlbums.py [-h] [-l LOCATION] [-p PROFILE]
Delete empty albums from Google Photos.
options:
-h, --help show this help message and exit
-l LOCATION, --location LOCATION
Path to the browser location to use. Work only with Google Chrome or Chromium.
-p PROFILE, --profile PROFILE
Path to the user profile to use.
With Google Chrome and the default user profile:
python3 DeleteEmptyAlbums.py
- The default user profile paths are:
- Under Windows:
%LOCALAPPDATA%\Google\Chrome\User Data\ - Under macOS:
$HOME/Library/Application Support/Google/Chrome/Profile/ - Under Linux:
$HOME/.config/google-chrome/Profile/
- Under Windows:
With Chromium and the default user profile under Windows PowerShell, if only Chromium is installed:
python .\DeleteEmptyAlbums.py --profile "$ENV:LOCALAPPDATA\Chromium\User Data"With Chromium under Windows PowerShell with the specific path to Chromium:
python .\DeleteEmptyAlbums.py --location "$ENV:ProgramFiles\Chromium\Application\chrome.exe" --profile "$ENV:LOCALAPPDATA\Chromium\User Data"With Chromium under the Windows Command Prompt:
python DeleteEmptyAlbums.py --location "%ProgramFiles%\Chromium\Application\chrome.exe" --profile "%LOCALAPPDATA%\Chromium\User Data"