Skip to content

alexk136/google-photo-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Google Photos Downloader

A Python script to download all photos and videos from your Google Photos library to a local directory.

Features

  • Downloads all photos and videos from Google Photos
  • Progress bar using tqdm
  • Detailed logging
  • Command-line arguments for configuration
  • Automatic token management
  • Skips already downloaded files
  • Robust error handling

Prerequisites

  • Python 3.6+
  • Google Cloud Console project with Google Photos API enabled
  • OAuth 2.0 credentials file

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/google-photos-downloader.git
cd google-photos-downloader
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up Google Photos API:
    • Create a project in Google Cloud Console
    • Enable the Google Photos Library API
    • Create OAuth 2.0 credentials
    • Download the credentials JSON file and save as credentials.json

📌 How to Get credentials.json for Google API

To authorize access to your Google Drive or Google Photos, you need to create OAuth 2.0 credentials:

Step-by-step instructions:

  1. Go to Google Cloud Console

  2. Click "Create Project" (if you don’t have one yet)

  3. Navigate to APIs & Services → Library

    • Search for and enable Google Drive API or Google Photos Library API, depending on your use case
  4. Go to APIs & Services → Credentials

  5. Click "+ Create Credentials" → OAuth client ID

  6. If prompted to configure the OAuth consent screen:

    • Select External
    • Set an App name (e.g., PhotoDownloader)
    • Save and continue — no need to publish
  7. Back on the Create OAuth client ID screen:

    • Choose Desktop App
    • Name it (e.g., MyDownloaderApp)
    • Click "Create", then "Download JSON"
  8. Rename the downloaded file to credentials.json and place it in your script directory.

⚠️ This file contains sensitive credentials — keep it private and secure.

Usage

Basic usage:

python download_photos.py

With custom options:

python download_photos.py --save-dir my_photos --credentials my_credentials.json --token my_token.pkl --page-size 50

Options:

  • --save-dir: Directory to save downloaded photos (default: photos_download)
  • --credentials: Path to Google API credentials file (default: credentials.json)
  • --token: Path to token file (default: token_photos.pkl)
  • --page-size: Number of photos to fetch per API call (default: 100)

First Run

  1. Run the script
  2. Browser will open for authentication
  3. Grant necessary permissions
  4. Token will be saved for future runs

Notes

  • Files are saved with their original names
  • Existing files with same names are skipped
  • Ensure sufficient disk space
  • Large libraries may take significant time to download
  • Google Photos API has rate limits; adjust --page-size if needed

License

MIT License - see LICENSE file for details

Contributing

Pull requests are welcome! Please open an issue first to discuss proposed changes.

About

A Python script to download all photos and videos from your Google Photos library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published