Giter Club home page Giter Club logo

photostream-album-sync's Introduction

Photostream-album-sync

Microservice to sync image files from a photoprism album into a folder which then can be used as content for photo-stream

This is how I use it: https://riess.dev/photostream/

Docker

Just use the docker-compose.yaml file from this repo. You can either build the image yourself using the Dockerfile or use the image on Docker Hub valentinriess/photostream-album-sync

Setup Triggers

Immich

Connect to your immich postgres and create a function and trigger for changes on the albums table. The service will listen on the albums channel.

Create function

CREATE OR REPLACE FUNCTION notify_albums_change() RETURNS trigger AS $trigger$
DECLARE
  rec albums;
  dat albums;
  payload TEXT;
BEGIN

  -- Set record row depending on operation
  CASE TG_OP
  WHEN 'UPDATE' THEN
     rec := NEW;
     dat := OLD;
  WHEN 'INSERT' THEN
     rec := NEW;
  WHEN 'DELETE' THEN
     rec := OLD;
  ELSE
     RAISE EXCEPTION 'Unknown TG_OP: "%". Should not occur!', TG_OP;
  END CASE;

  -- Build the payload
  payload := json_build_object('timestamp',CURRENT_TIMESTAMP,'action',LOWER(TG_OP),'db_schema',TG_TABLE_SCHEMA,'table',TG_TABLE_NAME,'record',row_to_json(rec), 'old',row_to_json(dat));

  -- Notify the channel
  PERFORM pg_notify('albums', payload);

  RETURN rec;
END;
$trigger$ LANGUAGE plpgsql;

Create trigger

CREATE TRIGGER albums_notify AFTER INSERT OR UPDATE OR DELETE 
ON albums
FOR EACH ROW EXECUTE PROCEDURE notify_albums_change();

Photoprism

Find the folder where photoprism stores your album sidecar yaml file. It should be located in storage/albums/album. Mount it into the docker container and configure the PHOTOPRISM_SYNC_ALBUM_PATH environment variable accordingly.

Example: PHOTOPRISM_ALBUM_PATH=/app/data/arqp4pz1fwptx4oq.yml

The service will watch this file for changes.

photostream-album-sync's People

Contributors

v411e avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

photostream-album-sync's Issues

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.