You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
989 B

  1. #!/usr/bin/env bash
  2. set -eu -o pipefail
  3. # e.g. ~/stash/YouTube/whitehouse
  4. root=$1
  5. es x find -t f -- "$root" | take-wanted-ids ~/dead-video-ids | rg '\.(mp4|webm|flv|video)$' | while read i; do
  6. echo $i
  7. eye_path=$(path-to-eye-path "$i" | sed -r "s,$HOME/stash/,,g")
  8. file_id=$(es x info -- "$i" | jq .id)
  9. size=$(es x info -- "$i" | jq .size)
  10. # If already in namedfiles i.e. the-eye, skip
  11. es x info -- "$i" | rg -q -F '"type": "namedfiles"' && continue || true
  12. (
  13. es x get "$i" && \
  14. rclone --inplace --size-only --progress copyto "$i" "jeff:$eye_path" && \
  15. 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 && \
  16. 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" && \
  17. ) || true &
  18. wait-until-jobs-below 9
  19. done