2 Commits

Author SHA1 Message Date
  Ivan Kozik b397b12195 WIP sftp-into-eye 1 month ago
  Ivan Kozik 3229ffe5ba Add sftp-into-eye 1 month ago
1 changed files with 25 additions and 0 deletions
Split View
  1. +25
    -0
      sftp-into-eye

+ 25
- 0
sftp-into-eye View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eu -o pipefail

# e.g. ~/stash/YouTube/whitehouse
root=$1

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" && \
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" && \
) || true &

wait-until-jobs-below 9
done

Loading…
Cancel
Save