Advertisement
Guest User

Quicksilver action for screen capture and upload to Imgur

a guest
Mar 25th, 2012
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using terms from application "Quicksilver"
  2. on process text _text
  3. try
  4. -- get POSIX path
  5. set _location to (POSIX path of (path to temporary items from user domain))
  6. set _filename_unquoted to (_location & _text & ".png")
  7. -- quoted form for use in shell command
  8. set _filename to quoted form of _filename_unquoted
  9. set _command to "screencapture -i " & _filename
  10. do shell script _command
  11.  
  12. set _quoted_text to quoted form of _text
  13. set _command to "~/bin/imgur.sh " & _filename & " " & _quoted_text
  14. -- capture output of shell command in variable
  15. set _url to do shell script _command
  16.  
  17. -- copy variable to clipboard
  18. set the clipboard to _url
  19. set _file_to_delete to (POSIX file _filename_unquoted) as string
  20. -- delete image file
  21. tell application "Finder" to delete _file_to_delete as alias
  22.  
  23. tell application "Quicksilver" to show notification "Imgur image uploaded and " & _url & " is on the clipboard"
  24.  
  25. -- open in firefox
  26. tell application "Firefox"
  27. open location _url
  28. end tell
  29. on error a number b
  30. tell application "Quicksilver"
  31. activate
  32. display dialog a
  33. end tell
  34. end try
  35. end process text
  36. end using terms from
  37.  
  38.  
  39. #!/opt/local/bin/bash
  40. key="1913b4ac473c692372d108209958fd15"
  41. file=$1
  42. if [ "x$file" == "x" ]; then
  43. echo "Must supply file as first argument"
  44. exit 1
  45. fi
  46. title=$2
  47. if [ "x$title" == "x" ]; then
  48. echo "Must supply title as second argument"
  49. exit 1
  50. fi
  51. curl -s -F "image=@-" -F "key=${key}" \
  52. -F "title=${title}" \
  53. http://api.imgur.com/2/upload.xml < "$file" | \
  54. grep -Eo "<imgur_page>(.)*</imgur_page>" | \
  55. grep -Eo "http://imgur.com/[^<]*"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement