Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- [ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || :
- # firefox profile name from about:profiles
- ffprofile=default-default
- docker_registry=local
- sudo_user=user
- if ! sudo_id="$(id -u $sudo_user)"
- then
- exit 1
- fi
- # run as root so we can run docker containers
- if [ "$(id -u)" -ne 0 ]
- then
- echo "Please run me as root..."
- exit 1
- fi
- epoch="$EPOCHSECONDS"
- # filter for all posts greater than or equal to the current epoch date - 31 days
- since="$((epoch - $(($((3600*24))*31))))"
- cd /home/${sudo_user}/Downloads || exit 1
- busybox usleep $((RANDOM*$((SRANDOM%1000))))
- 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)"
- then
- exit 1
- fi
- json="$(printf "%s" "$json" | jq -r "[.[][] | select(. | type ==\"object\") | select((.date|strptime(\"%Y-%m-%d %H:%M:%S\")|mktime) >= $since) | .]")"
- printf "%s" "$json" | jq -r '.[].content' | grep -ohE 'https?://(www\.)?(youtube.com|youtu.be)[A-Za-z0-9._~?#@!$&'"'"'(\[)\(\)\*\+\;\%\=/-]+' | sort -u | while read -r url
- do
- printf "url: %s\n" "$url"
- ctr_name="$(printf "%s" "$url" | xxhsum | awk '{print $1}')"
- 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
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement