Download albums/images from Picasa

Picasa is an online photo sharing portal from Google. Users from around the globe use Picasa for storing and sharing their photos online. We can view and download images from the album, but only if it is public. We cannot view private albums and also cannot download images from any of the public albums if the owner of the album has denied the access for other users to download the images.

But there is a way from which you can download the images. We are here going to use Google API to achieve this. You can download the Google API for .NET here.

To get started we have to first import the namespaces.

using Google.GData.Photos;
using Google.GData.Client;
using System.IO;
using System.Net;

Now here is the method which we are going to use to download the images. The methods takes in two parameters username and the album name. To get the username for the album, check the url of the user profile. For e.g.: http://picasaweb.google.com/prashantmx. Here the username is prashantmx, so the first parameter, username will be prashantmx and the albumname will be superbikes. Point to be noted is that there cannot be a white space between the username and albumname.

private static void DownAlbum(string UserN, string AlbumN)
{
    string fileName;
    Uri uriPath;
    WebClient HttpClient = new WebClient(); 
    PhotoQuery query = new PhotoQuery(); 
    query.Uri = new Uri(PhotoQuery.CreatePicasaUri(UserN, AlbumN)); 
    PicasaService service = new PicasaService("PicasaAlbumDownloader"); 
    PicasaFeed feed = (PicasaFeed)service.Query(query); 
    Directory.SetCurrentDirectory(Application.StartupPath+"\\Downloads"); 
 
    foreach (AtomEntry aentry in feed.Entries) 
    {
        uriPath = new Uri(aentry.Content.Src.ToString()); 
        fileName = uriPath.LocalPath.Substring(uriPath.LocalPath.LastIndexOf('/') + 1);
        try
        {
            Console.WriteLine("Downloading: " + fileName); 
            HttpClient.DownloadFile(aentry.Content.Src.ToString(), fileName); 
        }
        catch (WebException we)
        {
            Console.WriteLine(we.Message); 
        }
    }
         
    Console.WriteLine("Download Complete!");  
}

Output:

Picasa web album downloader

Download: PicasaAlbumDownloader_COMMAND.zip (128.78 kb)

comments powered by Disqus