Giter Club home page Giter Club logo

google-photos-sync-check's Introduction

Google Photos Sync Check

CircleCI

Google Photos Sync Check is a utility to check that the albums you have in Google Photos (GP) are in sync with the albums you have locally on disk.

This utility is part of my personal workflow for how I use GP. GP is my primary storage for all of my photos/videos whereas my home server is my backup storage.

Absolutely all of my photos/videos go into albums. Periodically I download all new albums I've uploaded to GP from my phone and other devices using Google Takeout. I use this utility to make sure I haven't missed anything and that it's all in sync. ๐Ÿ”

Enable the API

In order to use this utility, follow the instructions in Enable the Google Photos Library API.

Authenticate

Follow the instructions to Request an OAuth 2.0 client ID for the Google Photos API.

As part of that process you'll download a client_secret_xxxxx.json file. Name it client_secret.json and save it to this dir.

HttpAccessTokenRefreshError

If you get a oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Bad Request error when executing the script, delete the client_token.json file and execute the script again.

Run

pipenv install --dev --ignore-pipfile
pipenv shell
python google-photos-sync-check.py --verbose refresh_db
python google-photos-sync-check.py --verbose sync_check ~/Pictures

Test

pipenv shell
python -m pytest --cov=.

Notable

Development:

Python:

  • Python 3
  • Pyenv
  • Pipenv

Python lang features:

  • f strings
  • list comprehensions
  • generators
  • argparse
  • sets
  • context manager
  • glob
  • lambda
  • logging
  • signal handler
  • TODO: global exception handler
  • TODO: types
  • memoize

Database:

  • SQLite
  • SQLiteOnline
  • SQLAlchemy
    • indexes
    • relationships
    • collection_class
    • sessions

Testing:

  • PyTest
  • PyTest-Cov
  • PyLint
  • CircleCI
  • TODO: Memory profile

Library:

  • Pipfile
  • Google API Python Client
  • Jinja

Websites:

Related work:

Clean

Post Google Takeout cleanup.

pipenv shell
python scripts/google-takeout-cleanup.py --dry-run ~/Pictures

google-photos-sync-check's People

Contributors

dependabot[bot] avatar etoews avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

imbian

google-photos-sync-check's Issues

Automatically initiate reauth if token expires

If you have an expired token, you get the exception

(google-photos-sync-check) bash-3.2$ python google-photos-sync-check.py --verbose rebuild_db
Traceback (most recent call last):
  File "google-photos-sync-check.py", line 224, in <module>
    args.func(args)
  File "google-photos-sync-check.py", line 153, in rebuild_db
    for album_page in album_pages:
  File "google-photos-sync-check.py", line 33, in get_album_pages
    albums_response = photoslibrary.albums().list().execute()
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/googleapiclient/http.py", line 883, in execute
    resp, content = _retry_request(
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/googleapiclient/http.py", line 172, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/oauth2client/transport.py", line 186, in new_request
    credentials._refresh(orig_request_method)
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/oauth2client/client.py", line 761, in _refresh
    self._do_refresh_request(http)
  File "/Users/etoews/.local/share/virtualenvs/google-photos-sync-check-9wSNJ860/lib/python3.8/site-packages/oauth2client/client.py", line 819, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Bad Request

The client_token.json should be automatically deleted and the auth process retried.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.