Skip to content

Instantly share code, notes, and snippets.

@yekm
Created March 17, 2022 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yekm/de1785faf21f805c177034acc687872c to your computer and use it in GitHub Desktop.
Save yekm/de1785faf21f805c177034acc687872c to your computer and use it in GitHub Desktop.
backup best videos from coub
set -vx
# docker run -v /mnt/archive:/mnt --rm -it --entrypoint bash node
# apt install jq ffmpeg
# npm i -g coub-dl
# 2021 : 58
#url="https://coub.com/api/v2/best/58/coubs?type=coubs&"
# 2020 : 52
#url="https://coub.com/api/v2/best/52/coubs?type=coubs&"
# 2019 : 13
#url="https://coub.com/api/v2/best/13/coubs?type=coubs&"
# 2018 :
#url="https://coub.com/api/v2/best/2018/likes?"
# 2017 :
#url="https://coub.com/api/v2/best/2017/likes?"
# etc...
for y in $(seq 2012 2018 | tac); do
mkdir -p best$y
cd best$y
url="https://coub.com/api/v2/best/$y/likes?"
pages=$(curl "$url" | jq -r '.total_pages')
echo "$pages pages"
sleep 1
for i in $(seq 1 $pages); do
curl --silent "${url}page=$i" | \
jq -r '.coubs[] | .permalink, .views_count, .published_at' | \
while read pl; read vc; read pa; do
ls *-$pl-* || coub-dl -i $pl --loop 999 --time 300 \
-o $(printf "%0.9d" $vc)-$(echo $pa | cut -f1 -dT | tr - _)-$pl-:name:.mp4
done
done
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment