Skip to content

Instantly share code, notes, and snippets.

@laurencestokes
Last active February 21, 2019 12:03
Show Gist options
  • Save laurencestokes/04cb4c77969fc0f748c03d115ba04f8b to your computer and use it in GitHub Desktop.
Save laurencestokes/04cb4c77969fc0f748c03d115ba04f8b to your computer and use it in GitHub Desktop.
Get Video File From Twitter
# Takes a string argument to the twitter video m3u8 url and gets each of the .ts segments, then creates an mpeg. Very crude, based on
# http://zeroonelabs.com/how-i-downloaded-a-video-from-twitter-using-curl/
## To get the m3u8 url just check the network tab on the page with the video in your console.
FILE1=$1
declare -a fileArray
fileArray=$(curl --silent $FILE1 | grep -vE "^#" | sed -e 's_^_https://video.twimg.com_g')
mkdir ~/TS_files
# Change to that directory
cd ~/TS_files
rm final.ts
# Establish a variable
theCount=1
# Run a loop through each line of the array
for theTSURL in $fileArray[@];do
curl -g -o $theCount.ts $theTSURL
# increment the variable by 1
theCount=$((theCount + 1))
done
for i in {1..$theCount};do
cat * >> final.ts
done
mv final.ts test.mpeg
@laurencestokes
Copy link
Author

// TODO - clear all existing .ts files use file name as dir name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment