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;
|
||||
Documents.enable = true;
|
||||
Media.enable = true;
|
||||
Consume.enable = true;
|
||||
Archive.enable = true;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@
|
|||
|
||||
screencapture = {
|
||||
disable-shadow = true;
|
||||
location = "~/Consume/dcim";
|
||||
location = "~/Downloads";
|
||||
type = "png";
|
||||
show-thumbnail = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ in
|
|||
|
||||
volumes = [
|
||||
"/var/lib/immich/config:/config"
|
||||
"/var/lib/immich/photos:/photos"
|
||||
"/mnt/storage/DCIM:/library:ro"
|
||||
"/mnt/storage/photos:/photos"
|
||||
"${immichConfigFile}:/config/immich.json:ro"
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
../home-default.nix
|
||||
../../../modules/syncthing.nix
|
||||
../../../modules/media/tool.nix
|
||||
../../../modules/schedule.nix
|
||||
];
|
||||
|
||||
syncthing-custom.folders = {
|
||||
|
|
@ -13,16 +12,6 @@
|
|||
Documents = { enable = true; maxAgeDays = 30; };
|
||||
Media = { enable = true; maxAgeDays = 7; };
|
||||
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 = {
|
||||
|
|
@ -39,6 +50,15 @@
|
|||
};
|
||||
};
|
||||
|
||||
photo = {
|
||||
loadBalancer = {
|
||||
serversTransport = "longTimeout";
|
||||
servers = [{
|
||||
url = "http://127.0.0.1:8080";
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -144,7 +144,6 @@
|
|||
};
|
||||
|
||||
services.samba-custom.shares = {
|
||||
DCIM = "/mnt/storage/DCIM";
|
||||
Downloads = "/home/yanlin/Downloads";
|
||||
};
|
||||
|
||||
|
|
@ -153,7 +152,7 @@
|
|||
enable = true;
|
||||
repositoryUrl = "ssh://helsinki-box/./nfss";
|
||||
backupPaths = [
|
||||
"/mnt/storage/DCIM"
|
||||
"/mnt/storage/photos/library"
|
||||
];
|
||||
backupFrequency = "*-*-* 01:00:00";
|
||||
retention = {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
Documents = { enable = true; maxAgeDays = 30; };
|
||||
Media = { enable = true; maxAgeDays = 7; };
|
||||
Archive = { enable = true; maxAgeDays = 30; };
|
||||
Consume = { enable = true; maxAgeDays = 7; };
|
||||
};
|
||||
|
||||
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, ... }:
|
||||
|
||||
{
|
||||
|
|
@ -11,6 +13,7 @@
|
|||
p7zip
|
||||
imagemagick
|
||||
exiftool
|
||||
immich-go
|
||||
];
|
||||
|
||||
programs.zsh.initContent = ''
|
||||
|
|
@ -118,56 +121,24 @@
|
|||
done
|
||||
}
|
||||
|
||||
function photo-move() {
|
||||
local mode=copy
|
||||
if [[ "$1" == "-d" || "$1" == "--delete" ]]; then
|
||||
mode=move; shift
|
||||
elif [[ "$1" == "-l" || "$1" == "--link" ]]; then
|
||||
mode=link; shift
|
||||
function photo-upload() {
|
||||
local envfile="$HOME/.config/immich-env"
|
||||
if [[ ! -f "$envfile" ]]; then
|
||||
echo "Missing $envfile" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: photo-move [-d|--delete|-l|--link] <source_dir> <destination>"
|
||||
echo " -d, --delete Move files instead of copying"
|
||||
echo " -l, --link Hardlink instead of copying"
|
||||
echo " photo-move /Volumes/CAMERA/DCIM ~/DCIM"
|
||||
source "$envfile"
|
||||
if [[ -z "$IMMICH_URL" || -z "$IMMICH_APIKEY" ]]; then
|
||||
echo "IMMICH_URL and IMMICH_APIKEY must be set in $envfile" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local src="$1" dest="$2"
|
||||
|
||||
if [[ ! -d "$src" ]]; then
|
||||
echo "Source not found: $src" >&2
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: photo-upload <source_dir>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local name raw_date target
|
||||
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)
|
||||
immich-go upload from-folder --server="$IMMICH_URL" --api-key="$IMMICH_APIKEY" "$1"
|
||||
}
|
||||
|
||||
function extract() {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ in
|
|||
Documents = mkFolderOptions "Documents" { devices = pcDevices ++ serverDevices; };
|
||||
Media = mkFolderOptions "Media" { devices = lib.filter (d: d != "iphone") allDevices; };
|
||||
Archive = mkFolderOptions "Archive" {};
|
||||
Consume = mkFolderOptions "Consume" {};
|
||||
};
|
||||
enableGui = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue