Created
August 24, 2013 19:53
-
-
Save hrpunio/6330102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#returns source image location and thumbnail location | |
#Usage: picasa.sh /path/to/pic [Pic Name Shown In Album] | |
# One have to declare ALBUM_ID USER_ID username and password | |
ALBUM_ID=???????????????????? | |
USER_ID=116390720146821374745 | |
my_pic="$1" | |
[ -z "$2" ] && | |
pic_title=`basename $"my_pic"` || | |
pic_title="$2" | |
pic_type=`file -b --mime-type "$my_pic"` | |
echo "Content type: $pic_type" | |
#Your google account and password | |
username=???USER??? | |
password='???PASSWD???' | |
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}' ) | |
# http://picasaweb.google.com/data/feed/api/user/116390720146821374745/albumid/5548646603600183921?authkey=Gv1sRgCKv42MPfoua3UQ | |
album_xml="http://picasaweb.google.com/data/feed/api/user/$USER_ID/albumid/$ALBUM_ID?authkey=$auth_key" | |
# | |
#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/' ) | |
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" | | |
sed 's/.*media:content url='"'"'\([^'"'"']*\).*media:thumbnail url='"'"'\([^'"'"']*\).*/\1\n\2/' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment