Archives the contents of your Google Photos library to disk
Project description
google-photos-archiver
What?
google-photos-archiver
aims to provide a simple, fast, extensible interface to be able to back up one's Google Photos to a location of their choosing.
I've drawn inspiration from projects such as: https://github.com/mholt/timeliner & https://github.com/gilesknap/gphotos-sync but wanted to cut my teeth in this domain and see what I could come up with myself.
Why?
I wanted a tool (of my own creation) which could easily provide a copy of mine and my partner's Google Photos libraries, and keep said copy up to date over time.
In reality I've mainly just needed a distraction from the vicious cycle of wake, work, Netflix, sleep, and I thought it was high time to do a little side project.
How?
Pre-reqs
docker
... Or
python==3.8
- poetry
>=1.0.0
Development Reqs
- pre-commit
- Run
pre-commit install
- Run
Getting Started
Google Oauth Setup
These instructions will help you set up Google OAuth2 client credentials so you can start using google-photos-archiver
- While logged into your Google account navigate to Create a New Project
- Create one, and switch to using it with the UI dropdown
- Navigate to
APIs & Services
click on+ Enable APIs and services
, and enable thePhotos Library API
- Navigate back to
APIs & Services
and click onCredentials
- Click on
+ Create Credentials > OAuth client ID
- Configure an OAuth consent screen. You can just fill out the required fields and hit Save.
- Click
Add Or Remove Scopes
and manually add scope:https://www.googleapis.com/auth/photoslibrary.readonly
- Accept remaining defaults, save through and return to
Credentials
- Click
- Click on
+ Create Credentials > OAuth client ID
- Make a
"Desktop App"
- Congrats!, you now have a Client ID and Client Secret
- Download the associated
client_secret.json
file and make note of its location as we'll be providing it's path togoogle-photos-archiver
First Run
A browser window will be opened during the initial OAuth flow. After successfully authenticating once, a refresh token will be stored for future use (See: --refresh-token-path
) and will omit the need to reauthenticate.
Usage
$ git clone git@github.com:scottx611x/google-photos-archiver.git
$ poetry install
$ poetry run google-photos-archiver --help
... with Docker
Note that some more Docker volume mounting will be warranted here if you want to specify a different path to download to etc. Ref: https://docs.docker.com/storage/volumes
$ docker build . -t google-photos-archiver
$ docker run -v $PWD:/app/ google-photos-archiver --help
Running tests
$ poetry run pytest
Examples
Specify a different download location
$ poetry run google-photos-archiver archive-media-items --download-path /Volumes/my-big-hdd/downloaded_media
Download from specific dates (with wildcard support)
$ poetry run google-photos-archiver archive-media-items --date-filter 2020/*/*,2021/8/22
$ poetry run google-photos-archiver archive-media-items --date-range-filter 2019/8/22-2020/8/22
--help
Usage: google-photos-archiver [OPTIONS] COMMAND [ARGS]...
Options:
--client-secret-json-path TEXT `client_secret.json` file acquired from http
s://developers.google.com/photos/library/gui
des/get-started#request-id [default:
./client_secret.json; required]
--refresh-token-path TEXT [default: ./refresh_token]
--help Show this message and exit.
Commands:
archive-media-items
archive-media-items --help
Usage: google-photos-archiver archive-media-items [OPTIONS]
Options:
--download-path TEXT Directory that MediaItems will be archived
to [default: ./downloaded_media]
--sqlite-db-path TEXT [default: ./media_items.db]
--max-threadpool-workers INTEGER
The maximum amount of workers to utilize for
the ThreadPoolExecutor [default: 100]
--max-media-items INTEGER The maximum amount of MediaItems to account
for and archive in a given execution
[default: 200]
--date-filter TEXT Up to 5 comma delimited Dates conforming to
the YYYY/MM/DD pattern. Any of YYYY/MM/DD
can be wildcarded (*) like so:
*/MM/DD,YYYY/*/DD,YYYY/MM/*
--date-range-filter TEXT Up to 5 comma delimited DateRanges
conforming to the YYYY/MM/DD-YYYY/MM/DD
(<start_date>-<end_date>) pattern.
--help Show this message and exit.
Download Path Hierarchy
$ tree /<download_path>/downloaded_media/ | head
/Volumes/2TB/google-photos/scott/downloaded_media/
├── 2021
│ └── 1
│ ├── 1
│ │ └── a.jpg
│ └── 2
│ └── b.mov
├── 2020
│ ├── 1
│ │ └── 2
│ │ └── c.jpg
│ └── 2
│ └── 3
│ └── d.jpg
...
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
Hashes for google-photos-archiver-0.1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a52daceac5596dcfc7f205333f9a3079bf92870f30bcd70b68dd8574226b617 |
|
MD5 | e25031d58abecbf14405a5f878295fb3 |
|
BLAKE2b-256 | b844c821a7fbd91badc575adea6d8febbc0bd5c0424eda0014654135b85bb6b9 |
Hashes for google_photos_archiver-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5031e8b34b4a940c2d49a10d43d347b50160852dd5dbff48b22b19baa85995 |
|
MD5 | 40b9515f3dd5d85c22f7275b9f21a1a0 |
|
BLAKE2b-256 | 217d5978a6eac2bb93c3c683fa55d72bd969193dbbb0bff1df1868f6d98b25e4 |