Note: We have previously written a beginner guide to using GoogleCL, and this article is an add-on to that article with more detailed examples. Google offers many different services, several of which are available from your terminal with the Python program GoogleCL:
Blogger Calendar Contacts Docs Picasa YouTube
Installation
It’s more than likely that your nix package manager offers GoogleCL in one of its repositories. If it doesn’t, or if you’re running Windows, you can download GoogleCL here or grab the latest source code like this (note that Google Docs are broken in the latest .tar.gz packages from the first link, so I strongly recommend using the Subversion command below): GoogleCL requires the dependencies Python 2.5, 2.6, or 2.7 and gdata. To see all the different ways you can install GoogleCL, visit the official Install page. Here’s how to install it from the Subversion sources: If your default version of Python is not 2. (you can check with the command python –version), you’ll have to specify a version when you run setup.py. For example, if your Python version is 2.7, run: Once you’ve installed GoogleCL, you’ll be able to run these commands: Before you can actually use these services, you must authorize GoogleCL. The first time you run a GoogleCL command for a particular service, you’ll be automatically taken to the authorization page in your browser. For example, I ran: GoogleCL asked me to specify the user (usually yourusername@gmail.com, unless you’re using Google services for a different domain name), and then it took me here:
Once I pressed “Grant access,” I went back into my terminal and hit Enter. GoogleCL then listed my Picasa albums along with their URLs:
Usage
You can view a complete list of GoogleCL commands by entering man google in your terminal. I’ll now show a few examples of what you can do.
Blogger
First configure your blog. In Linux, Mac OS X, or a BSD system, edit “~/.config/googlecl/config”; in Windows 7+, edit “C:\Users\USERNAME.googlecl”, and in Windows XP edit “C:\Documents and Settings\USERNAME.googlecl”. Scroll down to the end of the document, where there is a section labeled [BLOGGER], and add your blog’s information: Now you can: List your posts: Make a new post with tags: Make a new post from a text file and give it a title: Delete a post:
Calendar
Add an event to your calendar: List all events: List events in a particular date range: Delete an event on a particular calendar:
Contacts
For Contacts, you’ll have to provide an authorization token in addition to authorizing GoogleCL in your browser. GoogleCL will walk you through this. Once authorized, you can perform these common tasks: Add a new contact: List contact information for anyone with a particular string in their name: Add a new contacts group: List your contacts groups: Delete a contact:
Docs
Remember that if you installed the stable version of GoogleCL, Google Docs is likely to be broken. Use the Subversion command described in the “Installation” section of this article to get Docs working. Once you’ve provided your authorization key, you can perform these actions and more: Upload a document: List all of your documents: Edit a document by name in an editor of your choice: Download a document:
Picasa
Create an album: Delete an album: Add a new photo to an album: Tag photos in an album: List photos with a particular tag: Download an album to your Pictures folder:
YouTube
In the next installment of this article series, we’ll discuss ways to view and download YouTube videos. If you have your own YouTube account, you can manage it with GoogleCL: List your videos: Post a new video: Tag all videos with a certain string in the title: Delete a video: GoogleCL lets you add many additional parameters to your tasks that I haven’t described here. See this section of the GoogleCL manual to read about them. Stay tuned for next time, when we’ll talk about using Tumblr, Flickr, and YouTube from the command line!