Posted By

matpolster on 07/16/09


Tagged

upload picasa


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

sidneydekoning
esritter


upload to picasa


 / Published in: Bash
 

  1. #!/bin/bash
  2. #returns source image location and thumbnail location
  3. #Usage: picasa.sh /path/to/pic [Pic Name Shown In Album]
  4.  
  5. my_pic="$1"
  6. [ -z "$2" ] &&
  7. pic_title=`basename $"my_pic"` ||
  8. pic_title="$2"
  9. pic_type=`file -b --mime-type "$my_pic"`
  10.  
  11. #Your google account and password
  12. username=
  13. password=
  14.  
  15. auth_key=$( curl -s https://www.google.com/accounts/ClientLogin -d Email="$username"@gmail.com -d Passwd="$password" -d accountType=GOOGLE -d source=Google-cURL-Example -d service=lh2 | awk -F\= '/^Auth=/{print $2}' )
  16.  
  17. album_xml=$( curl -s --header "Authorization: GoogleLogin auth=$auth_key" "http://picasaweb.google.com/data/feed/api/user/default" | sed 's/.*<link rel='"'"'self'"'"' type='"'"'application\/atom+xml'"'"' href='"'"'\([^'"'"']*\).*/\1/' | sed 's/entry/feed/' )
  18.  
  19. curl -s --request POST --data-binary "@$my_pic" --header "Slug: $pic_title" --header "Content-Type: $pic_type" --header "Authorization: GoogleLogin auth=$auth_key" "$album_xml" |
  20. sed 's/.*media:content url='"'"'\([^'"'"']*\).*media:thumbnail url='"'"'\([^'"'"']*\).*/\1\n\2/'

Report this snippet  

You need to login to post a comment.