Browse Source

WIP sftp-into-eye

master
Ivan Kozik 1 month ago
parent
commit
b397b12195
1 changed files with 9 additions and 4 deletions
  1. +9
    -4
      sftp-into-eye

+ 9
- 4
sftp-into-eye View File

@@ -5,16 +5,21 @@ set -eu -o pipefail
# e.g. ~/stash/YouTube/whitehouse
root=$1

es x find -- "$root" -t f | take-wanted-ids ~/dead-video-ids | rg '\.(mp4|webm|flv|video)$' | while read i; do
es x find -t f -- "$root" | take-wanted-ids ~/dead-video-ids | rg '\.(mp4|webm|flv|video)$' | while read i; do
echo $i
eye_path=$(path-to-eye-path "$i" | sed -r "s,$HOME/stash/,,g")
file_id=$(es x info -- "$i" | jq .id)
size=$(es x info -- "$i" | jq .size)

# If already in namedfiles i.e. the-eye, skip
es x info -- "$i" | rg -q -F '"type": "namedfiles"' && continue || true

(
es x get "$i" && \
rclone --inplace --size-only --progress copyto "i" "jeff:$eye_path" && \
rclone --inplace --size-only --progress copyto "$i" "jeff:$eye_path" && \
curl --fail-with-body -u "ya: ." -X POST -d "{\"file_id\": $file_id, \"location\": \"the-eye\", \"pathname\": \"$eye_path\"}" https://ya.borg.xyz/cgi-bin/new-namedfiles && \
curl -X POST -d "{\"the_eye_any_bytes_saved\": $size, \"the_eye_video_bytes_saved\": $size, \"the_eye_any_files_saved\": 1, \"the_eye_video_files_saved\": 1}" "http://127.0.0.1:31416/metrics" && \
sleep 0.1
) || true
) || true &

wait-until-jobs-below 9
done

Loading…
Cancel
Save