Don't like ads? PRO users don't see any ads ;-)
Guest

prototypef

By: a guest on Mar 18th, 2009  |  syntax: None  |  size: 1.61 KB  |  hits: 258  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (*
  2. Simple Applescript using CLI app isightcapture (http://www.intergalactic.de/pages/iSight.html)
  3. to capture photo from built-in iSight camera and upload directly to TwitPic (http://twitpic.com/).
  4.  
  5. Contact info:
  6. storagef -at- gmail -dot- com
  7. http://twitter.com/prototypef
  8.  
  9. 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.
  10.  
  11. *)
  12.  
  13. -- Optional. comment/uncomment to toggle 3 seconds warning before taking picture.
  14. (*
  15. say "1"
  16. delay 1
  17. say "2"
  18. delay 1
  19. say "3"
  20. delay 1
  21. say "Cheese!"
  22. *)
  23.  
  24. set username to "username"
  25. set userpassword to "password"
  26. set imageFile to "twitpic.jpg"
  27. set twitpic to do shell script "~/path/to/isightcapture /tmp/" & imageFile
  28. if twitpic = "" then
  29.         set imagePath to POSIX path of ("/tmp/")
  30.        
  31.         display dialog "Enter a message to post to twitter OR Press Cancel to only upload picture." default answer "" buttons {"OK", "Cancel"} default button 1
  32.         copy the result as list to {text_returned, button_pressed}
  33.        
  34.         if the button_pressed is "OK" then
  35.                 set uploadScript to "curl -F \"username=" & username & "\" -F \"password=" & userpassword & "\" -F \"media=@" & imagePath & imageFile & "\" -F \"message=" & text_returned & "\" http://twitpic.com/api/uploadAndPost"
  36.                
  37.                 --display dialog uploadScript
  38.                 do shell script uploadScript
  39.                
  40.                 set deleteFile to POSIX path of (imagePath & imageFile)
  41.                 try
  42.                         do shell script "rm " & deleteFile
  43.                 end try
  44.         end if
  45. end if