Skip to content

Instantly share code, notes, and snippets.

@dpgettings
Created October 28, 2016 06:35
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 dpgettings/1b28e2efc0ade6bf54aa41200f872c40 to your computer and use it in GitHub Desktop.
Save dpgettings/1b28e2efc0ade6bf54aa41200f872c40 to your computer and use it in GitHub Desktop.
#!/bin/bash
# single vine tweet no replies
echo "[single vine tweet no replies]"
echo "------------------------------"
bash vine_dl.sh https://twitter.com/PAPPADEMAS/status/791841723869605888
echo "---------"
echo "EXPECTED:"
echo "https://v.cdn.vine.co/r/videos/CE5DC8F9B71171654998891827200_3e673f8096e.1.5.14155013907193044834.mp4?versionId=29Q5Sdr1sY1OewhC42OL8ZZgJDdTElAy"
echo "*****************************"
# vine tweet + reply tweets no reply vines
echo "[vine tweet + reply tweets no reply vines]"
echo "------------------------------"
bash vine_dl.sh https://mobile.twitter.com/TravisSBN/status/791674834589773825
echo "---------"
echo "EXPECTED:"
echo "https://v.cdn.vine.co/r/videos/41F7C8AE291169941491867623424_39cf7b17308.1.5.12146776021527191979.mp4?versionId=130MrzHGlJTg2QTPKDuO32ZtErPrctAK"
echo "*****************************"
# vine tweet + reply vines
echo "[vine tweet with reply vines]"
echo "------------------------------"
bash vine_dl.sh https://mobile.twitter.com/Babylonian/status/791688305427435521
echo "---------"
echo "EXPECTED:"
echo "https://mtc.cdn.vine.co/r/videos/BA9C9BF96B1306043956408549376_4e2ea6d9ec0.5.1.11244858332223689844.mp4?versionId=jRIwIVvbLJYZGE9ZOyEngRLvDlEZ.TvT"
echo "*****************************"
#!/bin/bash
UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
# parse tweet url
tu_in="$1"
tu="$(echo $tu_in | sed 's/mobile.//g')"
echo "Tweet URL: "$tu
# download tweet
thtml=t.html
curl -s -k -A "'${UA}'" -o $thtml $tu
# parse tweet page html for vine url
vu="$(grep -E 'TweetTextSize[[:space:]]+TweetTextSize' $thtml | grep -Eo 'https://vine.co/v/[[:alnum:]]+' | sed -n '1p')"
# get vine id
vid=$(echo $vu | sed -n 's|\(https://vine.co/v/\)\([a-zA-Z0-9]*\)|\2|p')
echo "Vine.co URL: "$vu
echo "Vine ID: "$vid
# download vine page
vhtml=v.html
curl -s -k -A "'${UA}'" -o $vhtml $vu
# parse vine page html for mp4 url
mu="$(grep -Eo 'https://[a-z.]+\.cdn\.vine\.co/r/[A-Za-z0-9_]+/[A-Za-z0-9_.]+\.mp4\?versionId=[A-Za-z0-9_.]+' $vhtml | sed -n '1p')"
echo "mp4 URL: "
echo $mu
## download video
of="vine-${vid}.mp4"
curl -s -k -A "'${UA}'" -o $of $mu
echo "Output File: $of"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment