Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.62 KB | None | 0 0
  1. #!/bin/bash
  2. [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || :
  3.  
  4. # firefox profile name from about:profiles
  5. ffprofile=default-default
  6. docker_registry=local
  7.  
  8. sudo_user=user
  9. if ! sudo_id="$(id -u $sudo_user)"
  10. then
  11.     exit 1
  12. fi
  13.  
  14. # run as root so we can run docker containers
  15. if [ "$(id -u)" -ne 0 ]
  16. then
  17.     echo "Please run me as root..."
  18.     exit 1
  19. fi
  20.  
  21. epoch="$EPOCHSECONDS"
  22.  
  23. # filter for all posts greater than or equal to the current epoch date - 31 days
  24. since="$((epoch - $(($((3600*24))*31))))"
  25.  
  26. cd /home/${sudo_user}/Downloads || exit 1
  27.  
  28. busybox usleep $((RANDOM*$((SRANDOM%1000))))
  29.  
  30. if ! json="$(sudo -u $sudo_user -- gallery-dl --cookies-from-browser firefox/patreon.com:${ffprofile} --sleep-extractor $(bash -c 'exec python3 -c "print($((RANDOM*$((SRANDOM%1000))))/1_000_000)"') -A 5 -j https://www.patreon.com/namirin/posts)"
  31. then
  32.     exit 1
  33. fi
  34. json="$(printf "%s" "$json" | jq -r "[.[][] | select(. | type ==\"object\") | select((.date|strptime(\"%Y-%m-%d %H:%M:%S\")|mktime) >= $since) | .]")"
  35.  
  36. printf "%s" "$json" | jq -r '.[].content' | grep -ohE 'https?://(www\.)?(youtube.com|youtu.be)[A-Za-z0-9._~?#@!$&'"'"'(\[)\(\)\*\+\;\%\=/-]+' | sort -u | while read -r url
  37. do
  38.     printf "url: %s\n" "$url"
  39.     ctr_name="$(printf "%s" "$url" | xxhsum | awk '{print $1}')"
  40.     docker run -d --user 1000 -d --name "ytarchive${ctr_name}" --restart=on-failure -v "$PWD:$PWD" -w "$PWD" ${docker_registry}/ytarchive -w -o '[%(upload_date)s]_%(title)s(%(id)s)/[%(upload_date)s]_%(title)s(%(id)s)' --separate-audio --add-metadata --threads 20 -t --write-description --write-thumbnail -r 15 -merge "${url}" best
  41. done
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement