Ver código fonte

Add sftp-into-eye

master
Ivan Kozik 1 mês atrás
pai
commit
3229ffe5ba
1 arquivos alterados com 20 adições e 0 exclusões
  1. +20
    -0
      sftp-into-eye

+ 20
- 0
sftp-into-eye Ver arquivo

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

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
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)
(
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" && \
sleep 0.1
) || true
done

Carregando…
Cancelar
Salvar