#synology #command-line-application #web-interface #content #synology-nas #synology-photos

bin+lib syno-photos-util

Helper for a number of tasks unavailable in Synology Photos web interface

2 unstable releases

new 0.2.0 May 4, 2024
0.1.2 May 3, 2024
0.1.1 Apr 29, 2024
0.1.0 Apr 29, 2024

#126 in Images

Download history 269/week @ 2024-04-26

269 downloads per month

GPL-3.0-or-later

66KB
1.5K SLoC

syno-photos-util

Crates.io Version build and release

Helper for Synology Photos maintenance.

  • List folders containing photos in a Synology Photos album
  • Copy album contents into a Synology Photos folder

If you like the project, give it a star ⭐, or consider becoming a :)

Why?

This is a console app that queries the Synology Photos API to deduce locations (folder paths) of photos added to a Synology Photos album or copy photos from an album to a folder.

I used it while doing some spring-cleaning of photos on my Synology NAS (and as a programming exercise in Rust). Maybe someone will find it handy as well.

Usage

Download the binary file for your platform from Releases.

The following command examples omit the version and platform suffix from binary name.

Display the help message:

./syno-photos-util --help
Usage: syno-photos-util [OPTIONS] <COMMAND>

Commands:
  login   Sign in to Synology DSM
  list    List file locations (folders) of photos in an album
  export  Export (accessible) album photos to a folder in the user's personal space
  status  Check DSM sign-in status
  logout  Sign out of DSM
  help    Print this message or the help of the given subcommand(s)

Options:
      --timeout <TIMEOUT_SECONDS>
          HTTP request timeout in seconds
          
          Must be greater or equal to 5. When Synology Photos does not respond within the timeout, an
          error is displayed. Try to increase the value for slow connections
          
          [default: 30]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Each command supports the --help option for a detailed description.

Login to Synology DSM

Before you can use any of the other commands, you need to sign in to DSM:

./syno-photos-util login https://your.nas.address/

You can provide your DSM user credentials as arguments (see login --help), or you will be asked to type them in. If multi-factor authentication (MFA) is enabled, you can use the --remember option to not be asked for an OTP code next time you use the login command.

The address value should be the same as the one you use to open DSM in your browser. Unless you use non-standard ports (5000 for HTTP and 5001 for HTTPS), you can omit the port - otherwise it needs to be specified, e.g., https://your.nas.address:5042.

On successful login, the session id is saved into $HOME/.syno-photos-util file (in the user profile directory on Windows, e.g., C:\Users\Alice\.syno-photos-util), similarly to a web browser saving a cookie. Do not share this file with anyone, as it gives access to your DSM.

List files in an album

After signing in successfully, you can list the contents of an album, printing their file-system paths on your NAS:

./syno-photos-util list "My Album"

The album can either be a normal album or a person's name in the People albums.

The output may look like this, for example:

'/var/services/homes/alice/Photos/PhotoLibrary/2022/11/mountain.jpg'
'/var/services/photo/beach.jpeg'
Error: no access (owned by bob) 'forest.jpg'

In this example, My Album contains 3 photos:

  • The mountain.jpg photo is in one of the signed-in user's (alice in this case) Personal Space folders (located in the user's home directory).
  • The beach.jpeg photo is in Shared Space (located in the photo shared folder).
  • In the case of forest.jpg, the physical location of the file is inaccessible to alice. This happens, e.g., when there are other NAS users (bob in this example) having provider access to My Album, and they added photos from their Personal Space. Another possibility is that My Album is owned by bob and shared with alice - depending on permissions, some or all of the photo locations may be inaccessible.

Export an album to a folder

./syno-photos-util export "My Album" "/my folder/my album dump"

Note that currently the target folder needs to already exist in the user's Personal Space.

The command schedules a background task to copy the photos from an album to a folder in Personal Space. Photos inaccessible due to permissions will not be copied. If there are identically named photos in the target folder already, they will not get overwritten. You can also inspect the task status in Synology Photos web UI.

Because the login session is saved, it is possible to schedule this command, e.g., with CRON, to export files added to an album periodically.

Logout

You may want to logout from DSM when done:

./syno-photos-util logout

This will remove the session information from $HOME/.syno-photos-util. You may optionally add the --forget option to enforce OTP code verification on the next login (usable only when MFA is enabled). Alternatively, just deleting the $HOME/.syno-photos-util file has the same effect.

Building from source

  1. Install Rust if you have not already.

  2. Install the app from crates.io (you can use the same command to update the app when a new version gets published):

    cargo install syno-photos-util
    

When building is finished, the binary is then located at $HOME/.cargo/bin/syno-photos-util and should be available on your $PATH.

Alternatively, clone this git repository and build the project with (in the cloned directory):

cargo build --release

The binary is then located at target/release/syno-photos-util.

TODO

  • Add support for "Places" albums
  • Add an option for the export command to create the target folder

Credits

Dependencies

~10–24MB
~392K SLoC