
prototypef
By: a guest on
Mar 18th, 2009 | syntax:
None | size: 1.61 KB | hits: 258 | expires: Never
(*
Simple Applescript using CLI app isightcapture (http://www.intergalactic.de/pages/iSight.html)
to capture photo from built-in iSight camera and upload directly to TwitPic (http://twitpic.com/).
Contact info:
storagef -at- gmail -dot- com
http://twitter.com/prototypef
This work is licensed under the Creative Commons Attribution 3.0 Puerto Rico License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/pr/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
*)
-- Optional. comment/uncomment to toggle 3 seconds warning before taking picture.
(*
say "1"
delay 1
say "2"
delay 1
say "3"
delay 1
say "Cheese!"
*)
set username to "username"
set userpassword to "password"
set imageFile to "twitpic.jpg"
set twitpic to do shell script "~/path/to/isightcapture /tmp/" & imageFile
if twitpic = "" then
set imagePath to POSIX path of ("/tmp/")
display dialog "Enter a message to post to twitter OR Press Cancel to only upload picture." default answer "" buttons {"OK", "Cancel"} default button 1
copy the result as list to {text_returned, button_pressed}
if the button_pressed is "OK" then
set uploadScript to "curl -F \"username=" & username & "\" -F \"password=" & userpassword & "\" -F \"media=@" & imagePath & imageFile & "\" -F \"message=" & text_returned & "\" http://twitpic.com/api/uploadAndPost"
--display dialog uploadScript
do shell script uploadScript
set deleteFile to POSIX path of (imagePath & imageFile)
try
do shell script "rm " & deleteFile
end try
end if
end if