Guest User

Bash Script for uploading videos to twitter via TWURL

a guest
Jul 20th, 2015
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. STATMSG="What happens when we apply the ripple effect to land instead of water? #gamedev"
  2. FILENAME="Segment_0001.mp4"
  3. FILESIZE=$(stat -f%z "$FILENAME")
  4.  
  5.  
  6. split -b 5m $FILENAME
  7.  
  8.  
  9. RESULT=$(twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=INIT&media_type=video/mp4&total_bytes=$FILESIZE")
  10.  
  11. RESULTID=$(echo "$RESULT" | grep -Po '(?<="media_id_string":")[^"]*')
  12.  
  13. echo "$STATMSG $FILENAME $FILESIZE $RESULT $RESULTID"
  14.  
  15. twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=$RESULTID&segment_index=0" --file ./xaa --file-field "media"
  16.  
  17. if [ "$FILESIZE" -gt "5242880" ];
  18. then twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=$RESULTID&segment_index=1" --file ./xab --file-field "media";
  19. fi
  20.  
  21. if [ "$FILESIZE" -gt "10485760" ];
  22. then twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=APPEND&media_id=$RESULTID&segment_index=2" --file ./xac --file-field "media";
  23. fi
  24.  
  25. twurl -H upload.twitter.com "/1.1/media/upload.json" -d "command=FINALIZE&media_id=$RESULTID"
  26.  
  27. twurl "/1.1/statuses/update.json" -d "status=$STATMSG&media_ids=$RESULTID"
Advertisement
Add Comment
Please, Sign In to add comment