Skip to main content

A tool to shard photos across multiple Google Photo accounts

Project description

Sharded-Google-Photos

Description

Running out of space in your Google Photos account? Wish you can upload your photos to multiple Google Accounts? Now you can! With this Python library, you can upload your photos to multiple Google Photo Accounts and then share those albums to your main Google Photos account. That way, you get to see all of your photos on one main Google Photos account.

Getting Started

It works like this:

  1. Let's say you have three Google Accounts. Follow this doc to create your own OAuth2 Google Client ID to interact with Google Photos and Google Drive.

  2. Install libmagic

  3. Install the package by running pip install sharded-google-photos.

  4. Import the following code in your main.py app:

    from sharded_google_photos.backup.gphotos_backup import GPhotosBackup
    from sharded_google_photos.shared.gphotos_client import GPhotosClient
    
    clients = [
        GPhotosClient(name="bob@gmail.com", creds_file = "credentials-1.json", client_secret="client_secret.json"),
        GPhotosClient(name="alice@gmail.com", creds_file = "credentials-2.json", client_secret="client_secret.json"),
        GPhotosClient(name="jerry@gmail.com", creds_file = "credentials-3.json", client_secret="client_secret.json"),
    ]
    for client in clients:
        client.authenticate()
    
    backup_client = GPhotosBackup(clients)
    

    Run this script and follow the instructions from the cli.

  5. To upload four photos from two folders, run the following:

    new_album_uris = backup_client.backup(
        [
            { "modifier": "+", "file_path": "./Archives/Photos/2022/Trip to California/1.jpg" },
            { "modifier": "+", "file_path": "./Archives/Photos/2022/Trip to California/2.jpg" },
            { "modifier": "+", "file_path": "./Archives/Photos/2022/Trip to Toronto/3.jpg" },
            { "modifier": "+", "file_path": "./Archives/Photos/2022/Trip to Toronto/4.jpg" },
        ]
    )
    print(new_album_uris)
    

    What will happen is that it will:

    1. A shared read-only album Archives/Photos/2022/Trip to California will be made in some Google Photos account with the most amount of space available.

    2. A shared read-only album Archives/Photos/2022/Trip to Toronto will be made in some Google Photos account with the second most amount of space available.

    3. Photos 1.jpg, and 2.jpg will be in the Archives/Photos/2022/Trip to California album.

    4. Photos 3.jpg, and 4.jpg will be in the Archives/Photos/2022/Trip to Toronto album.

    5. The url to those new albums will be in new_album_uris that you can share to.

  6. To update a file in a folder, run the following:

    backup_client.backup(
        [
            { "modifier": "-", "file_path": "./Archives/Photos/2022/Trip to California/1.jpg" },
            { "modifier": "+", "file_path": "./Archives/Photos/2022/Trip to California/1.jpg" },
        ]
    )
    
  7. To delete a file in a folder, run the following:

    backup_client.backup(
        [
            {
                "modifier": "-", "file_path": "./Archives/Photos/2022/Trip to California/1.jpg",
            }
        ]
    )
    

    Note: it is not possible for the Google Photos API to actually delete a photo from Google Photos. Instead, you can clean your Google Photo accounts by putting all album-less photos into a "Trash" album by running the following script:

    from sharded_google_photos.cleanup.gphotos_cleaner import GPhotosCleaner
    
    for client in clients:
        cleaner = GPhotosCleaner(client)
        cleaner.cleanup()
    

    After running that script, it will put all of the albumless photos into an album called "Trash", and you can log into Google Photos and delete those photos from your account manually.

Getting Started to Contribute

  1. Ensure Python3, Pip, and Poetry are installed on your machine

  2. Install dependencies by running:

    poetry install
    
  3. Run the app in CLI mode by running:

    poetry run python sharded_google_photos/main.py
    
  4. To lint your code, run:

    poetry run flake8 && poetry run black .
    
  5. To run tests and code coverage, run:

    poetry run coverage run -m pytest && poetry run coverage report -m
    
  6. To publish your app:

    1. First, set your PyPI api token to Poetry

      poetry config pypi-token.pypi <YOUR_API_TOKEN>
      
    2. Then, build the app by running:

      poetry build
      
    3. Finally, publish the app by running:

      poetry publish
      

Usage

Please note that this project is used for educational purposes and is not intended to be used commercially. We are not liable for any damages/changes done by this project.

Credits

Emilio Kartono, who made the entire project.

License

This project is protected under the GNU licence. Please refer to the LICENSE.txt for more information.

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

sharded_google_photos-0.2.3.tar.gz (27.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharded_google_photos-0.2.3-py3-none-any.whl (32.6 kB view details)

Uploaded Python 3

File details

Details for the file sharded_google_photos-0.2.3.tar.gz.

File metadata

  • Download URL: sharded_google_photos-0.2.3.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for sharded_google_photos-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f5c17e37b7ba952a1a683b297130164d3fb0a54be6048a22712a0334b4bb2fb7
MD5 68a714e52ab0b5e65a819033c369c404
BLAKE2b-256 414913b0e2f0d8f6b7e18a7adda4b4c7488df1615e3677a942505a3d95f44299

See more details on using hashes here.

File details

Details for the file sharded_google_photos-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sharded_google_photos-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a14c9b9c7af90384baab038e1d064c64b258a00763f919e5ac1880d1187f107b
MD5 b47037ca791ea56413693f9207b226bd
BLAKE2b-256 1db529a96d8b7bda8cedf22cf8f1651defbf2a791a72d403328d0cf84330bccd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page