private void ExportAlbum(Album album)
        {
            var path = Path.Combine(OutputDirectory, CleanPathName(album.Title));
            Directory.CreateDirectory(path);
            album.Path = path;
            var page = 1;

            var xml = new XDocument();
            var rootNode = new XElement("Album",
                new XAttribute("id", album.Id),
                new XAttribute("date", album.Date),
                new XAttribute("url", album.Url),
                new XAttribute("title", album.Title)
            );
            xml.Add(rootNode);

            // Loops until no more pages are left
            while (true)
            {
                var albumPage = GetAlbumPage(album, page);

                // Try to find the list of photos on this page
                var photoList = albumPage.GetElementbyId("photoList");
                // Process photos in background threads
                var photos = new ConcurrentQueue<Photo>();
                Parallel.ForEach(photoList.Descendants("a"), node => ExportAlbumPhoto(node, photos, path));
                album.Photos = photos.ToList();

                // Stop looping if there's no photos left.
                if (photos.Count == 0)
                    break;

                foreach (var photo in photos)
                {
                    rootNode.Add(new XElement("Photo",
                        new XAttribute("url", photo.Url),
                        new XAttribute("filename", photo.Filename),
                        photo.Caption
                    ));
                }

                page++;
            }

            xml.Save(Path.Combine(path, "index.xml"));
        }
        private HtmlDocument GetAlbumPage(Album album, int page)
        {
            var client = new WebClient();
            //var albumPage = new HtmlDocument();
            //albumPage.LoadHtml(client.DownloadString(album.Url));

            // TODO: No clue what this is - This seems to work though (taken from logging requests on MySpace)
            client.Headers.Add("Hash", "MIGuBgkrBgEEAYI3WAOggaAwgZ0GCisGAQQBgjdYAwGggY4wgYsCAwIAAQICZgMCAgDABAjxk%2fqvtBqGGwQQUc%2fM6FamnbvPgW07TDo%2bGARgibOOx9JuS4eVLj6D6xHR2UJE5uheOK%2brQBfJQOxXreYejDJC%2fa5G3nBJRCpCRZA%2byyQfYNSwGwxipWNrEkIGCrcdDsiKTDeuE6sXGVvrM2iP5XtjGDGTjXhry6Q8Lc6%2f");

            NameValueCollection formValues = new NameValueCollection();
            formValues.Add("PageNo", page.ToString());
            formValues.Add("typeid", "11003");
            formValues.Add("albumId", album.Id.ToString());

            var response = client.UploadValues(ALBUM_PAGE_URL, "POST", formValues);
            var doc = new HtmlDocument();
            doc.LoadHtml(Encoding.UTF8.GetString(response));
            return doc;
        }