Last active
February 21, 2019 12:03
-
-
Save laurencestokes/04cb4c77969fc0f748c03d115ba04f8b to your computer and use it in GitHub Desktop.
Get Video File From Twitter
This file contains 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// TODO - clear all existing .ts files use file name as dir name.