In this post we will use Googe Data API i.e. GData to read some more attributes of Picasa Web Albums. We will enquiry how many photos are stored in each of the Web Album, who is the author of album and what is the data size for each of the album.
For a change I converted my listbox to list view as I want to display information in a tabular format.
The .NET code snippet are following to read the Number of photos stored in each of the album and data size of each of the album. The Data size are in Bytes. So if you want to convert this to MB, you can do so.
private void button1_Click(object sender, EventArgs e)
{
listView1.Columns.Add("Album_Title");
listView1.Columns.Add("`NoOfPhoto");
listView1.Columns.Add("`Author");
listView1.Columns.Add("`Data_Size");
PicasaService myPicasa = new PicasaService("Vikash-Test-Picasa");
myPicasa.setUserCredentials("abc@gmail.com", "abc");
AlbumQuery myAlbumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("abc"));
PicasaFeed myPicasaFeed=myPicasa.Query(myAlbumQuery);
foreach (PicasaEntry p in myPicasaFeed.Entries)
{
AlbumAccessor myAlbum = new AlbumAccessor(p);
listView1.Items.Add((new ListViewItem(new string[] { myAlbum.AlbumTitle.ToString(), myAlbum.NumPhotos.ToString(), myAlbum.AlbumAuthor.ToString(), myAlbum.BytesUsed.ToString() })));
}
}
The NumPhotos, AlbumAuthor and BytesUsed property of AlbumAccessor class returns the number of photos, Album author and Album data size. After running the code in Ms-Visual Studio 2010 my output looks like this. I got number of photos, author and the album data size for each of the album
Also, I discovered a very fine pice of .NET samples which google has provided us with the client library. The sample is rich and contain examples of reading, writing or modifying information from various Google services.
Thanks for reading till this point.
If you want to explore more with the Source code of this post; please visit Download Zone.