Created
November 7, 2020 05:20
-
-
Save McFlat/de3db14caebee8511e7eec4a68f2c107 to your computer and use it in GitHub Desktop.
Download peertube videos incrementally using a video id to access at the found videos to get all data json and mp4 from the website
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# created by Alex Goretoy | |
# download videos from any peertube site, troo.tube by default | |
# creates a directory named after the domain where to download all videos | |
PEERTUBE_URL="${1:-https://troo.tube}"; | |
DOMAIN_NAME=$(echo "${PEERTUBE_URL}" | awk -F[/:] '{print $4}'); | |
START="${2:-0}"; | |
FINISH="${3:-99999}" | |
[ ! -d $DOMAIN_NAME ] && mkdir $DOMAIN_NAME | |
for i in $(seq $START $FINISH); do | |
data=$(wget -q "${PEERTUBE_URL}/api/v1/videos/${i}" -O -); | |
if [ "$data" != "" ]; then | |
ID=$(echo $data | jq .uuid | sed 's/"//g'); | |
NA=$(echo $data | jq .name | sed 's/"//g'); | |
RE=$(echo $data | jq .files[0].resolution.id | sed 's/"//g'); | |
echo $data > "$DOMAIN_NAME/$NA-$RE-$ID.data.json"; # subsequent writes will just update the existing json data file | |
if [ ! -f "$DOMAIN_NAME/$NA-$RE-$ID.mp4" ]; then # only download video if it hasn't already been downloaded | |
url=$(echo $data | jq .files[0].fileDownloadUrl | sed 's/"//g'); | |
curl -s $url > "$DOMAIN_NAME/$NA-$RE-$ID.mp4" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment