您查看的文章来源于http://www.oklinux.cn
picasup是一个python脚本,利用google的API来上传照片到picasa,仅仅41行。谢谢作者王元涛。
安装使用作者都已经说得很清楚(英文),这儿就不赘述了。
我使用后的感觉是还缺少多个目录上传的功能,所以就写了一个bash脚本来实现:
#! /bin/bash
# picasa_upload_multi_directory.sh
if [ "$#" -eq "0" ]
then
upload_dir="/path/to/upload_dir"?? #若无参数
else
upload_dir="$1"?????? #或有第一个参数
fi
# upload_dir下所有的子目录都会被上传
cd $upload_dir
albums=`ls -l | grep ^d | awk '{print $8}'`
# upload to picassa
for album in $albums
do
echo "--------------------"
echo "processing $album ..."
cd $album
python /path/to/picu.py
cd ..
done
不过要记得把picu.py中的
id = raw_input("Username:") "@gmail.com"
ps = getpass.getpass()
改成
id = "你的用户名"
ps = "你的密码"
就不会每次都询问密码了。这样可以使用Cron进行自动上传。另外为了安全起见,可以
chmod 700 picu.py