switch to use immich-go toolkit
This commit is contained in:
parent
cd186314cc
commit
beaeecc5f2
9 changed files with 37 additions and 62 deletions
|
|
@ -22,7 +22,6 @@
|
||||||
Credentials.enable = true;
|
Credentials.enable = true;
|
||||||
Documents.enable = true;
|
Documents.enable = true;
|
||||||
Media.enable = true;
|
Media.enable = true;
|
||||||
Consume.enable = true;
|
|
||||||
Archive.enable = true;
|
Archive.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
screencapture = {
|
screencapture = {
|
||||||
disable-shadow = true;
|
disable-shadow = true;
|
||||||
location = "~/Consume/dcim";
|
location = "~/Downloads";
|
||||||
type = "png";
|
type = "png";
|
||||||
show-thumbnail = true;
|
show-thumbnail = true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@ in
|
||||||
|
|
||||||
volumes = [
|
volumes = [
|
||||||
"/var/lib/immich/config:/config"
|
"/var/lib/immich/config:/config"
|
||||||
"/var/lib/immich/photos:/photos"
|
"/mnt/storage/photos:/photos"
|
||||||
"/mnt/storage/DCIM:/library:ro"
|
|
||||||
"${immichConfigFile}:/config/immich.json:ro"
|
"${immichConfigFile}:/config/immich.json:ro"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
../home-default.nix
|
../home-default.nix
|
||||||
../../../modules/syncthing.nix
|
../../../modules/syncthing.nix
|
||||||
../../../modules/media/tool.nix
|
../../../modules/media/tool.nix
|
||||||
../../../modules/schedule.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
syncthing-custom.folders = {
|
syncthing-custom.folders = {
|
||||||
|
|
@ -13,16 +12,6 @@
|
||||||
Documents = { enable = true; maxAgeDays = 30; };
|
Documents = { enable = true; maxAgeDays = 30; };
|
||||||
Media = { enable = true; maxAgeDays = 7; };
|
Media = { enable = true; maxAgeDays = 7; };
|
||||||
Archive = { enable = true; maxAgeDays = 30; };
|
Archive = { enable = true; maxAgeDays = 30; };
|
||||||
Consume = { enable = true; maxAgeDays = 7; };
|
|
||||||
};
|
|
||||||
|
|
||||||
services.scheduled-commands.dcim-consume = {
|
|
||||||
enable = true;
|
|
||||||
description = "Move files in dcim consume folder to DCIM";
|
|
||||||
interval = "*-*-* *:00/15:00";
|
|
||||||
commands = [
|
|
||||||
"photo-move -d /home/yanlin/Consume/dcim /mnt/storage/DCIM"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,17 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
photo = {
|
||||||
|
rule = "Host(`photo.home.yanlincs.com`)";
|
||||||
|
service = "photo";
|
||||||
|
tls = {
|
||||||
|
certResolver = "cloudflare";
|
||||||
|
domains = [{
|
||||||
|
main = "*.home.yanlincs.com";
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
|
@ -39,6 +50,15 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
photo = {
|
||||||
|
loadBalancer = {
|
||||||
|
serversTransport = "longTimeout";
|
||||||
|
servers = [{
|
||||||
|
url = "http://127.0.0.1:8080";
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
services.samba-custom.shares = {
|
services.samba-custom.shares = {
|
||||||
DCIM = "/mnt/storage/DCIM";
|
|
||||||
Downloads = "/home/yanlin/Downloads";
|
Downloads = "/home/yanlin/Downloads";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -153,7 +152,7 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
repositoryUrl = "ssh://helsinki-box/./nfss";
|
repositoryUrl = "ssh://helsinki-box/./nfss";
|
||||||
backupPaths = [
|
backupPaths = [
|
||||||
"/mnt/storage/DCIM"
|
"/mnt/storage/photos/library"
|
||||||
];
|
];
|
||||||
backupFrequency = "*-*-* 01:00:00";
|
backupFrequency = "*-*-* 01:00:00";
|
||||||
retention = {
|
retention = {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@
|
||||||
Documents = { enable = true; maxAgeDays = 30; };
|
Documents = { enable = true; maxAgeDays = 30; };
|
||||||
Media = { enable = true; maxAgeDays = 7; };
|
Media = { enable = true; maxAgeDays = 7; };
|
||||||
Archive = { enable = true; maxAgeDays = 30; };
|
Archive = { enable = true; maxAgeDays = 30; };
|
||||||
Consume = { enable = true; maxAgeDays = 7; };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.scheduled-commands.aicloud-backup = {
|
services.scheduled-commands.aicloud-backup = {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# NOTE: Immich credentials file at: `~/.config/immich-env` with IMMICH_URL and IMMICH_APIKEY
|
||||||
|
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -11,6 +13,7 @@
|
||||||
p7zip
|
p7zip
|
||||||
imagemagick
|
imagemagick
|
||||||
exiftool
|
exiftool
|
||||||
|
immich-go
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.zsh.initContent = ''
|
programs.zsh.initContent = ''
|
||||||
|
|
@ -118,56 +121,24 @@
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function photo-move() {
|
function photo-upload() {
|
||||||
local mode=copy
|
local envfile="$HOME/.config/immich-env"
|
||||||
if [[ "$1" == "-d" || "$1" == "--delete" ]]; then
|
if [[ ! -f "$envfile" ]]; then
|
||||||
mode=move; shift
|
echo "Missing $envfile" >&2
|
||||||
elif [[ "$1" == "-l" || "$1" == "--link" ]]; then
|
return 1
|
||||||
mode=link; shift
|
|
||||||
fi
|
fi
|
||||||
|
source "$envfile"
|
||||||
if [[ $# -ne 2 ]]; then
|
if [[ -z "$IMMICH_URL" || -z "$IMMICH_APIKEY" ]]; then
|
||||||
echo "Usage: photo-move [-d|--delete|-l|--link] <source_dir> <destination>"
|
echo "IMMICH_URL and IMMICH_APIKEY must be set in $envfile" >&2
|
||||||
echo " -d, --delete Move files instead of copying"
|
|
||||||
echo " -l, --link Hardlink instead of copying"
|
|
||||||
echo " photo-move /Volumes/CAMERA/DCIM ~/DCIM"
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local src="$1" dest="$2"
|
if [[ $# -eq 0 ]]; then
|
||||||
|
echo "Usage: photo-upload <source_dir>" >&2
|
||||||
if [[ ! -d "$src" ]]; then
|
|
||||||
echo "Source not found: $src" >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local name raw_date target
|
immich-go upload from-folder --server="$IMMICH_URL" --api-key="$IMMICH_APIKEY" "$1"
|
||||||
while IFS= read -r -d "" file; do
|
|
||||||
name=$(basename "$file")
|
|
||||||
[[ "$name" == .* ]] && continue
|
|
||||||
|
|
||||||
raw_date=$(${pkgs.exiftool}/bin/exiftool -s3 -d '%Y-%m-%d' \
|
|
||||||
-DateTimeOriginal -CreateDate -MediaCreateDate "$file" 2>/dev/null | head -1)
|
|
||||||
|
|
||||||
if [[ ! "$raw_date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ || "$raw_date" == "0000-00-00" ]]; then
|
|
||||||
raw_date=$(${pkgs.coreutils}/bin/date -d "@$(${pkgs.coreutils}/bin/stat -c '%Y' "$file")" +%Y-%m-%d)
|
|
||||||
fi
|
|
||||||
|
|
||||||
target="$dest/''${raw_date:0:4}/$raw_date"
|
|
||||||
mkdir -p "$target"
|
|
||||||
|
|
||||||
[[ -e "$target/$name" ]] && continue
|
|
||||||
|
|
||||||
case $mode in
|
|
||||||
move) mv "$file" "$target/$name" ;;
|
|
||||||
link) ln "$file" "$target/$name" ;;
|
|
||||||
*) cp -a "$file" "$target/$name" ;;
|
|
||||||
esac
|
|
||||||
done < <(find "$src" -type f \( \
|
|
||||||
-iname "*.mp4" -o -iname "*.mov" -o -iname "*.mts" -o -iname "*.m2ts" -o -iname "*.avi" \
|
|
||||||
-o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.heic" -o -iname "*.heif" \
|
|
||||||
-o -iname "*.cr2" -o -iname "*.cr3" -o -iname "*.nef" -o -iname "*.arw" -o -iname "*.dng" -o -iname "*.raf" -o -iname "*.orf" -o -iname "*.rw2" \
|
|
||||||
\) -print0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function extract() {
|
function extract() {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ in
|
||||||
Documents = mkFolderOptions "Documents" { devices = pcDevices ++ serverDevices; };
|
Documents = mkFolderOptions "Documents" { devices = pcDevices ++ serverDevices; };
|
||||||
Media = mkFolderOptions "Media" { devices = lib.filter (d: d != "iphone") allDevices; };
|
Media = mkFolderOptions "Media" { devices = lib.filter (d: d != "iphone") allDevices; };
|
||||||
Archive = mkFolderOptions "Archive" {};
|
Archive = mkFolderOptions "Archive" {};
|
||||||
Consume = mkFolderOptions "Consume" {};
|
|
||||||
};
|
};
|
||||||
enableGui = lib.mkOption {
|
enableGui = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue