No project description provided
Project description
Photos-Drive-CLI-Client
Description
The Photos-Drive-CLI-Client is the cli client for Photos Drive. This CLI helps set up your infrastructure, syncs, adds, and delete your pictures and videos from your machine to Photos Drive.
This CLI will never delete content from your machine - it should only mirror the content from your machine to the cloud.
Table of Contents
Getting Started
Installation
-
First, install a tool called Exiftool
- It's a tool used to parse through exif metadata in your photos / videos.
-
Second, install torch and torchvision by running:
pip3 install torch torchvision
-
Second, install this Python package by running:
pip3 install photos_drive
Setting up your infrastructure
-
First, you need to have the following:
-
Next, to set up your infrastructure by running
photos_drive config init. -
It will ask you information on what the command will do.
Press
[enter]to continue. -
Next, the cli will prompt you to specify a place to store the configs. You can store it locally or on MongoDB.
For simplicity, select
2. It will then ask you to enter the file name of your config. -
Next, it will ask you to add a MongoDB database to store your pictures / videos metadata. It will prompt you to enter a name for your database, and its read-write connection string:
-
Finally, it will ask you to add your Google Photos account to store your pictures / videos. It will prompt you to enter a name for your first Google Photos account, and a Google Photos Client ID and Google Photos Client Secret.
-
After specifying the name, client ID, and client secret, it will return a URL to authenticate. Copy-paste the URL to your browser and follow the instructions on the browser:
-
It saves the config to
my-config.confto your current working directory.
Syncing your photos / videos
-
From the previous step, assume you have
config.confas your config file, and assume your current working directory looks like this:. ├── Archives │ ├── Photos │ │ ├── 2023 │ │ │ └── Wallpapers │ │ │ └── 2023-11a Wallpaper.DNG │ │ └── 2024 │ │ └── Wallpapers │ │ ├── 2024-01a Wallpaper.jpg │ │ ├── 2024-03-01 Wallpaper.jpg │ │ ├── 2024-04-02 Wallpaper.DNG │ │ └── 2024-05 Wallpaper.png │ └── Random.jpg └── my-config.conf
-
To sync your photos / videos to the system, run:
photos_drive_cli sync --local_dir_path . --config_file config.conf
-
It will then ask you to confirm if these are the contents that you want to upload to the system. Type in
yes: -
After a while, the contents should be uploaded and will output statistics on the upload.
-
If you want to sync your photos/videos in a particular path in the system, you can specify the
--remote_albums_pathfield, like:photos_drive_cli sync --local_dir_path ./Archives --remote_albums_path Archives --config_file config.conf
It will compare all contents under the local directory
./Archivesto all content under the albums pathArchives. -
You can also upload photos / videos in parallel with the
--parallelize_uploadsflag, like:photos_drive_cli sync --local_dir_path . --config_file config.conf --parallelize_uploads
though it is experimental right now.
Adding custom content to Photos Drive
-
Suppose your Photos Drive has the following content:
root └── Archives ├── Photos │ └── 2024 │ └── Wallpapers │ ├── 2024-01a Wallpaper.jpg │ ├── 2024-03-01 Wallpaper.jpg │ ├── 2024-04-02 Wallpaper.DNG │ └── 2024-05 Wallpaper.png └── Random.jpg
and you want to upload the current content in your working directory:
. └── Current └── Dog.jpg
-
You can run:
photos_drive_cli add ./Current --config_file my-config.conf
and your system will add all contents under
./Currentwithout deleting any existing content in your system. -
In other words, you will have these contents:
root ├── Archives │ ├── Photos │ │ └── 2024 │ │ └── Wallpapers │ │ ├── 2024-01a Wallpaper.jpg │ │ ├── 2024-03-01 Wallpaper.jpg │ │ ├── 2024-04-02 Wallpaper.DNG │ │ ├── 2024-05 Wallpaper.png │ └── Random.jpg └── Current └── Dog.jpg
Deleting content to Photos Drive
-
Similarly, if your system has this content:
root └── Archives ├── Photos │ └── 2024 │ └── Wallpapers │ ├── 2024-01a Wallpaper.jpg │ ├── 2024-03-01 Wallpaper.jpg │ ├── 2024-04-02 Wallpaper.DNG │ ├── 2024-05 Wallpaper.png └── Random.jpg
-
If you want to delete the
Archives/Random.jpgpicture, you can run:photos_drive_cli delete Archives/Random.jpg --config_file my-config.conf
and the photo
Archives/Random.jpgwill be deleted from the system. -
Similarly, if you want to delete everything under the
Archives/Photosalbum, you can run:photos_drive_cli delete Archives/Photos --config_file my-config.conf
and the system will have these new contents:
root └── Archives └── Random.jpg
Cleaning trailing Photos Drive
In case any of the sync, add, or delete commands fail, there are data that can be cleaned up. Moreover, when a photo / video is deleted, due to the limitations of the Google Photos API, it will remain in your Google Photos account.
Hence, the clean script is provided to clean up the system.
Running:
photos_drive_cli clean --config_file config.conf
will:
- Delete all media items from the metadata database that is not being used
- Delete all albums from the metadata database that is not being used
- Move photos / videos in Google Photos that are not used to a special album called
To deletewhere you can manually delete the content in your Google Photos account.
Deleting all content in Photos Drive
In case you want to delete everything, you can run:
photos_drive_cli teardown --config_file config.conf
It will delete all photos / videos from your system, and move all photos / videos in your Google Photo accounts to their To delete albums.
Getting Started to Contribute
-
Ensure Python3, Pip, and Poetry are installed on your machine
-
Install dependencies by running:
poetry install -
To lint your code, run:
poetry run mypy . && poetry run flake8 && poetry run isort . && poetry run black .
-
To run all tests and code coverage, run:
poetry run coverage run --source=photos_drive -m pytest tests/ && poetry run coverage report -m
-
To run tests and code coverage for a particular test file, run:
poetry run coverage run --source=photos_drive -m pytest <insert-file-path> && poetry run coverage report -m
For example,
poetry run coverage run --source=photos_drive -m pytest tests/backup/test_backup_photos.py && poetry run coverage report -m
-
To publish a new version of the app:
-
First, bump up the package version by running:
poetry version [patch|minor|major]
For instance, if the app is on 0.1.0 and you want to increment it to version 0.1.1, run:
poetry version patch
-
Then, create a pull request with the new version number.
-
Once the pull request is submitted, go to https://github.com/EKarton/photos-drive/actions/workflows/publish-cli-client.yaml, click on the
Run workflow, ensure that it's on themainbranch, and click onRun workflow: -
Once the action is complete, it will publish a new version of the app on https://pypi.org/project/photos_drive_cli_client/.
-
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.
CLI images were provided by https://ray.so/.
License
This project is protected under the GNU licence. Please refer to the root project's LICENSE.txt for more information.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file photos_drive-8.2.0.tar.gz.
File metadata
- Download URL: photos_drive-8.2.0.tar.gz
- Upload date:
- Size: 73.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.6 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baab9d7242ba017472f9b2881f660f15208b8e15b949c25215ed89bf0f48a456
|
|
| MD5 |
33a8f549368c2ee7a1f0b970e319a163
|
|
| BLAKE2b-256 |
2820b9d69b36ebe9d5f3f8604789a3ab623bb9d6e899631b637fd2f608e7fcc0
|
File details
Details for the file photos_drive-8.2.0-py3-none-any.whl.
File metadata
- Download URL: photos_drive-8.2.0-py3-none-any.whl
- Upload date:
- Size: 124.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.0 CPython/3.13.6 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57ef568e15133b20beeff2bd1033647008097044265383959abbf94d59fa3204
|
|
| MD5 |
19651924613f55880b6e65e23828210f
|
|
| BLAKE2b-256 |
2ca33e244767aa94a48647c55058cc1bae2c6b0f0813282587d38bd875e62e46
|