README for photoprismpull
This is a basic python lib for interacting with the API of a PhotoPrism instance.
Upstream
This project's upstream is at https://bgstack15.ddns.net/cgit/photoprismpull and https://gitlab.com/bgstack15/photoprismpull.
Alternatives
A library written in Go is advertised by Photoprism.
Related
For a shell interaction with the API to trigger imports, see https://bgstack15.ddns.net/cgit/photoprism-autoimport/.
For a script to create albums from a Google Photos Takeout in PhotoPrism see https://github.com/inthreedee/photoprism-transfer-album.
Reason for existing
I do not know Go, but I am comfortable in python. My two original goals for this library were:
- Download album to directory (with optional limitation such as "only the last 60 days"
- Add photos to album based on sha1sums
Using
There is a small front-end, pp.py
. Run its --help
option.
I tend to use this library in an interactive python shell. One task included fetching a Google Photos album as a zip, extracting, and generating a sha1sums file. I had used that related photoprism-transfer-album tool, but my Takeout failed to include a few albums for no reason. Since I already had all the photos in PhotoPrism, I just needed to find them and add them to the correct album.
sha1sum -- * > input.album5
And then in a python shell:
import importlib, pplib
# as needed after changes:
importlib.reload(pplib)
a = pplib.get_session("https://pp.example.com","admin","password")
c = add_hashes_to_album(a, "Pretty Album Name", "/mnt/public/Images/photoprism/Named albums/Pretty Album Name/input.album5",apply=True)
The simpler example is downloading an album to a subdirectory.
import pplib
a = pplib.get_session("https://pp.example.com","admin","password")
c = download_album_to_directory("Pretty Album Name",directory="/mnt/public/Images/photoprism",extraparams="&after=2020-02-08",session=a)
This will make a new directory, /mnt/public/Images/photoprism/Pretty Album Name/
and populate it with the images from this named album in PhotoPrism. Note that the get_album_by_title()
function explicitly excludes "albums" autogenerated from existing directories in your originals directory. It only searches through actual "album" albums. This is trivial to change for yourself as needed.
Dependencies
A chart for distros, or maybe just a simple package list.
Building
If applicable, or more complicated than make && make install
.