Exemplo n.º 1
0
        public ActionResult About()
        {
            string user = "******";

            PicasaService service = new PicasaService("PhotoBrowser");

            service.setUserCredentials(user, "**********");

            AlbumQuery query = new AlbumQuery();

            query.Uri = new Uri(PicasaQuery.CreatePicasaUri(user));

            PicasaFeed picasaFeed = service.Query(query);

            List <PicasaEntry> result = new List <PicasaEntry>();

            if (picasaFeed != null && picasaFeed.Entries.Count > 0)
            {
                foreach (PicasaEntry entry in picasaFeed.Entries)
                {
                    result.Add(entry);
                }
            }

            return(View(result));
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                if (Session["user"] != null && Request.QueryString["album"] != null)
                {
                    PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(((User)Session["user"]).Username, Request.QueryString["album"] as string));

                    PicasaService tmp  = Session["service"] as PicasaService;
                    PicasaFeed    feed = tmp.Query(query);

                    List <object> data = new List <object>(feed.Entries.Count);
                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        data.Add(new
                        {
                            name = entry.Title.Text,
                            url  = entry.Content.AbsoluteUri,
                        });
                    }
                    //this.Store1.T
                    this.Store1.DataSource = data;
                    this.Store1.DataBind();
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void PhotosAuthenticationTest()
        {
            Tracing.TraceMsg("Entering PhotosAuthenticationTest");

            PicasaQuery   query   = new PicasaQuery();
            PicasaService service = new PicasaService("unittests");

            query.KindParameter = "album,tag";

            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                query.Uri = new Uri(this.defaultPhotosUri);
                AtomFeed feed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("PhotoAuthTest"));

                if (feed != null && feed.Entries.Count > 0)
                {
                    Tracing.TraceMsg("Found a Feed " + feed.ToString());
                    DisplayExtensions(feed);

                    foreach (AtomEntry entry in feed.Entries)
                    {
                        Tracing.TraceMsg("Found an entry " + entry.ToString());
                        DisplayExtensions(entry);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public List <Photo> GetListFor(string albumId)
        {
            var service = new PicasaService("GPhotoSync");

            service.SetAuthenticationToken(_credentials.AccessToken);

            var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_credentials.User, albumId));

            query.ExtraParameters = "imgmax=d";
            var feed = service.Query(query);

            if (feed != null)
            {
                var list = feed.Entries
                           .OfType <PicasaEntry>()
                           .Select(x =>
                {
                    var accessor = new PhotoAccessor(x);

                    return(new Photo
                    {
                        Id = accessor.Id,
                        Title = accessor.PhotoTitle,
                        Path = x.Media.Content.Url
                    });
                });

                return(list.OfType <Photo>().ToList());
            }
            else
            {
                return(new List <Photo>());
            }
        }
Exemplo n.º 5
0
        public static IEnumerable <PicasaAlbum> GetAlbums()
        {
            var           albums  = new List <PicasaAlbum>();
            PicasaService service = new PicasaService("PicasaUnlistedAlbums");

            service.setUserCredentials(WebConfigurationManager.AppSettings["Username"], WebConfigurationManager.AppSettings["Password"]);
            AlbumQuery query           = new AlbumQuery(PicasaQuery.CreatePicasaUri("default"));
            PicasaFeed feed            = service.Query(query);
            var        albumsToExclude = WebConfigurationManager.AppSettings["AlbumsToExclude"].Split(',').ToList();

            foreach (var atomEntry in feed.Entries)
            {
                var entry = (PicasaEntry)atomEntry;
                if (albumsToExclude.Contains(entry.Title.Text) || entry.Title.Text.Contains("Hangout"))
                {
                    continue;
                }
                var album = new PicasaAlbum
                {
                    Title     = entry.Title.Text,
                    Thumbnail = entry.Media.Thumbnails[0].Url,
                    Link      = entry.AlternateUri.Content
                };
                albums.Add(album);
            }
            return(albums);
        }
Exemplo n.º 6
0
        public List <Album> GetList()
        {
            var service = new PicasaService("GPhotoSync");

            service.SetAuthenticationToken(_credentials.AccessToken);

            var query = new AlbumQuery();

            query.Thumbsize = "180";
            query.Uri       = new Uri(PicasaQuery.CreatePicasaUri(_credentials.User));

            var feed = service.Query(query);

            if (feed != null)
            {
                var list = feed.Entries
                           .OfType <PicasaEntry>()
                           .Where(x => !IsPostEntry(x))
                           .OrderBy(x => x.Title.Text)
                           .Select(x =>
                {
                    var accessor = new AlbumAccessor(x);

                    var thumb = x.Media.Thumbnails[0];
                    using (var stream = service.Query(new Uri(thumb.Attributes["url"] as string)))
                    {
                        var ms = new MemoryStream();
                        stream.CopyTo(ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        return(new Album
                        {
                            Id = accessor.Id,
                            Title = accessor.AlbumTitle,
                            ImageStream = ms,
                            PhotoCount = (int)accessor.NumPhotos
                        });
                    }
                })
                           .ToList();
                return(list);
            }
            else
            {
                return(new List <Album>());
            }
        }
Exemplo n.º 7
0
        private static PicasaFeed GetPicasaFeed(KindQuery query)
        {
            var service = new PicasaService(PicasaConfiguration.Settings.Application.Name);

            service.setUserCredentials(PicasaConfiguration.Settings.Authentication.Username, PicasaConfiguration.Settings.Authentication.Password);

            return(service.Query(query));
        }
Exemplo n.º 8
0
        private void buttonGetAlbumList_Click(object sender, EventArgs e)
        {
            authenticate();

            string userName = comboLogin.Text;

            disableItemsForRun();

            Thread thr = new Thread(new ThreadStart(delegate
            {
                try
                {
                    AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(userName));

                    PicasaFeed feed = service.Query(query);

                    Invoke(new MethodInvoker(delegate
                    {
                        listAlbums.Items.Clear();
                        albumMap.Clear();

                        foreach (PicasaEntry entry in feed.Entries)
                        {
                            AlbumAccessor ac = new AlbumAccessor(entry);
                            listAlbums.Items.Add(ac.AlbumTitle);
                            albumMap[ac.AlbumTitle] = ac;
                        }

                        if (feed.Entries.Count > 0)
                        {
                            listAlbums.SelectedIndex = 0;
                        }

                        buttonGetAlbumList.Enabled = true;

                        updateItems();
                    }));
                }
                catch (Exception ex)
                {
                    Invoke(new MethodInvoker(delegate
                    {
                        uploadLog.Text = "Album list upload failed: " + ex.Message + "\r\n";

                        listAlbums.Items.Clear();
                        albumMap.Clear();

                        updateItems();
                    }));
                }
            }));

            thr.Start();
        }
        /// <summary>
        /// Syncs a local folder to an online Picasa Web Album location
        /// </summary>
        /// <param name="folderPath">The source folder to sync.</param>
        public void SyncFolder(string folderPath)
        {
            ResetCounters();
            PicasaService session = new PicasaService("PicasaWebSync");

            session.setUserCredentials(this.PicasaUsername, this.PicasaPassword);
            AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername));

            try
            {
                WriteOutput("[Connecting to Picasa web service]");
                //fetch all albums
                PicasaFeed albumFeed = session.Query(query);

                WriteOutput("[Starting sync]");

                folderPath = folderPath.TrimEnd(new char[] { '\\' });
                DirectoryInfo sourceFolder = new DirectoryInfo(folderPath);
                m_baseDirectoryName = sourceFolder.Name;

                SyncFolder(sourceFolder, null, this.AlbumAccess, this.IncludeSubFolders, session, albumFeed);
            }
            catch (GDataRequestException gdrex)
            {
                if (gdrex.ResponseString.Contains(GDATA_RESPONSE_BADAUTH))
                {
                    throw new AuthenticationException("Picasa error - username and/or password is incorrect!  Check the config file values.");
                }
                else
                {
                    throw new Exception(string.Format("Picasa error - {0}", gdrex.ResponseString));
                }
            }

            WriteOutput("[Done]");
            WriteOutput(string.Empty);
            WriteOutput("Summary:");
            WriteOutput(string.Format("  Folders skipped: {0}", m_folderSkipCount.ToString()));
            WriteOutput(string.Format("   Albums created: {0}", m_albumCreateCount.ToString()));
            WriteOutput(string.Format("   Albums updated: {0}", m_albumUpdateCount.ToString()));
            WriteOutput(string.Format("   Albums deleted: {0}", m_albumDeleteCount.ToString()));
            WriteOutput(string.Format("   Files uploaded: {0}", m_fileCreateCount.ToString()));
            WriteOutput(string.Format("    Files removed: {0}", m_fileDeleteCount.ToString()));
            WriteOutput(string.Format("    Files skipped: {0}", m_fileSkipCount.ToString()));
            WriteOutput(string.Format("   Errors occured: {0}", m_errorsCount.ToString()));
            WriteOutput(string.Format("     Elapsed time: {0}", (DateTime.Now - m_startTime).ToString()));
        }
Exemplo n.º 10
0
        private static List <PhotoMessage> GetPhotos()
        {
            List <PhotoMessage> ans = new List <PhotoMessage>();

            try
            {
                string     fileName;
                Uri        uriPath;
                WebClient  HttpClient = new WebClient();
                PhotoQuery query      = new PhotoQuery();
                query.Uri = new Uri(PhotoQuery.CreatePicasaUri("hagit.oded", "5780002529047522017"));
                PicasaService service = new PicasaService("PicasaAlbumDownloader");
                PicasaFeed    feed    = (PicasaFeed)service.Query(query);
                Directory.SetCurrentDirectory("C:\\Photos\\");
                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);
                        ans.Add(new PhotoMessage("C:\\Photos\\" + fileName));
                    }
                    catch (WebException we)
                    {
                        try
                        {
                            HttpClient.DownloadFile(aentry.Content.Src.ToString(), fileName);
                            ans.Add(new PhotoMessage("C:\\Photos\\" + fileName));
                        }
                        catch (WebException we2)
                        {
                            Console.WriteLine(we2.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
                System.Diagnostics.EventLog.WriteEntry("WeddApp", ex.Message, System.Diagnostics.EventLogEntryType.Error, 626);
            }

            return(ans);
        }
Exemplo n.º 11
0
        private static string GetAlbum(string album)
        {
            string retVal;

            try
            {
                var service = new PicasaService("exampleCo-exampleApp-1");

                string usr = Settings.GetSingleValue("Account") + "@gmail.com";
                string pwd = Settings.GetSingleValue("Password");

                service.setUserCredentials(usr, pwd);

                var        query = new PhotoQuery(PicasaQuery.CreatePicasaUri(usr, album));
                PicasaFeed feed  = service.Query(query);

                retVal = "<ul id=\"AlbumList\">";
                foreach (PicasaEntry entry in feed.Entries)
                {
                    var    firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string;
                    string thumGrp       = "/s" + Settings.GetSingleValue("PicWidth") + "/";

                    if (firstThumbUrl != null)
                    {
                        firstThumbUrl = firstThumbUrl.Replace("/s72/", thumGrp);
                    }

                    var contentUrl = entry.Media.Content.Attributes["url"] as string;

                    if (contentUrl != null)
                    {
                        contentUrl = contentUrl.Substring(0, contentUrl.LastIndexOf("/"));
                    }

                    contentUrl += "/s640/" + entry.Title.Text;

                    retVal += string.Format(Img, firstThumbUrl, contentUrl);
                }
                retVal += "</ul>";
            }
            catch (Exception qex)
            {
                retVal = qex.Message;
            }
            return(retVal);
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>tries to insert a photo using MIME multipart</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void InsertMimePhotoTest()
        {
            Tracing.TraceMsg("Entering InsertMimePhotoTest");

            AlbumQuery    query   = new AlbumQuery();
            PicasaService service = new PicasaService("unittests");

            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                query.Uri = new Uri(this.defaultPhotosUri);

                PicasaFeed feed = service.Query(query);
                if (feed != null)
                {
                    Assert.IsTrue(feed.Entries != null, "the albumfeed needs entries");
                    Assert.IsTrue(feed.Entries[0] != null, "the albumfeed needs at least ONE entry");

                    PicasaEntry album = feed.Entries[0] as PicasaEntry;

                    PhotoEntry newPhoto = new PhotoEntry();
                    newPhoto.Title.Text   = "this is a title";
                    newPhoto.Summary.Text = "A lovely shot in the ocean";

                    newPhoto.MediaSource = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg");

                    Uri postUri = new Uri(album.FeedUri.ToString());

                    PicasaEntry entry = service.Insert(postUri, newPhoto) as PicasaEntry;

                    Assert.IsTrue(entry.IsPhoto, "the new entry should be a photo entry");

                    entry.Title.Text   = "This is a new Title";
                    entry.Summary.Text = "A lovely shot in the shade";
                    entry.MediaSource  = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg");
                    PicasaEntry updatedEntry = entry.Update() as PicasaEntry;
                    Assert.IsTrue(updatedEntry.IsPhoto, "the new entry should be a photo entry");
                    Assert.IsTrue(updatedEntry.Title.Text == "This is a new Title", "The titles should be identical");
                    Assert.IsTrue(updatedEntry.Summary.Text == "A lovely shot in the shade", "The summariesa should be identical");
                }
            }
        }
Exemplo n.º 13
0
        public static PicasaEntry RetrievePicasaEntry(string id)
        {
            PicasaService service = new PicasaService(Picasa_APPLICATION_NAME);

            service.setUserCredentials(config.Username, config.Password);

            PhotoQuery photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(config.Username, string.Empty, id));

            photoQuery.NumberToRetrieve = 1;
            PicasaFeed picasaFeed = service.Query(photoQuery);

            if (picasaFeed.Entries.Count > 0)
            {
                return((PicasaEntry)picasaFeed.Entries[0]);
            }

            return(null);
        }
Exemplo n.º 14
0
        public void UploadPhotoTo(string albumId, string filename)
        {
            var service = new PicasaService("GPhotoSync");

            service.SetAuthenticationToken(_credentials.AccessToken);

            var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_credentials.User, albumId));
            var feed  = service.Query(query);

            var media = new MediaFileSource(filename, MimeTypes.GetMimeType(Path.GetExtension(filename)));
            var photo = new PhotoEntry();

            photo.Title = new AtomTextConstruct {
                Text = Path.GetFileNameWithoutExtension(filename)
            };
            photo.MediaSource = media;

            service.Insert(feed, photo);
        }
Exemplo n.º 15
0
    protected string GetAlbumsTable()
    {
        if (string.IsNullOrEmpty(Settings.GetSingleValue("Account")))
        {
            return(string.Empty);
        }

        var service = new PicasaService("exampleCo-exampleApp-1");

        string usr = Settings.GetSingleValue("Account") + "@gmail.com";
        string pwd = Settings.GetSingleValue("Password");

        service.setUserCredentials(usr, pwd);

        var sb = new StringBuilder("<table class=\"beTable\">");

        var        query = new AlbumQuery(PicasaQuery.CreatePicasaUri(usr));
        PicasaFeed feed  = service.Query(query);

        sb.Append(GetHeader());

        var cnt = 0;

        foreach (PicasaEntry entry in feed.Entries)
        {
            var          ac   = new AlbumAccessor(entry);
            const string cell = "<td>{0}</td>";

            sb.Append(cnt % 2 == 0 ? "<tr>" : "<tr class=\"alt\">");

            // thumbnail
            string albumUri      = ((Google.GData.Client.AtomEntry)(entry)).AlternateUri.ToString();
            string firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string;
            string thumbAncr     = string.Format("<a href=\"{2}\"><img src=\"{0}\" alt=\"{1}\" width=\"40\" /></a>",
                                                 firstThumbUrl, entry.Title.Text, albumUri);
            sb.Append(string.Format(cell, thumbAncr));

            // title
            sb.Append(string.Format(cell, ac.AlbumTitle));

            // description
            sb.Append(string.Format(cell, ac.AlbumSummary + "&nbsp;"));

            // number of photos
            sb.Append(string.Format(cell, ac.NumPhotos));

            // access
            sb.Append(string.Format(cell, ac.Access));

            // extension tag
            string       feedUri = entry.FeedUri;
            const string showTag = "[PicasaShow:{0}]";
            const string albmTag = "[PicasaAlbum:{0}]";

            if (ac.Access.ToLower() == "protected")
            {
                sb.Append(string.Format(cell, "&nbsp;"));
                sb.Append(string.Format(cell, "&nbsp;"));
            }
            else
            {
                sb.Append(string.Format(cell, string.Format(showTag, ac.AlbumTitle)));
                sb.Append(string.Format(cell, string.Format(albmTag, ac.AlbumTitle)));
            }


            sb.Append("</tr>");
            cnt++;
        }

        return(sb + "</table>");
    }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test, iterates all entries</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void QueryPhotosTest()
        {
            Tracing.TraceMsg("Entering PhotosQueryPhotosTest");

            PhotoQuery    query   = new PhotoQuery();
            PicasaService service = new PicasaService("unittests");

            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory)this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.defaultPhotosUri);
                PicasaFeed feed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("PhotoAuthTest"));

                if (feed != null && feed.Entries.Count > 0)
                {
                    Tracing.TraceMsg("Found a Feed " + feed.ToString());
                    DisplayExtensions(feed);

                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        Tracing.TraceMsg("Found an entry " + entry.ToString());
                        DisplayExtensions(entry);

                        GeoRssWhere w = entry.Location;
                        if (w != null)
                        {
                            Tracing.TraceMsg("Found an location " + w.Latitude + w.Longitude);
                        }

                        ExifTags tags = entry.Exif;
                        if (tags != null)
                        {
                            Tracing.TraceMsg("Found an exif block ");
                        }

                        MediaGroup group = entry.Media;
                        if (group != null)
                        {
                            Tracing.TraceMsg("Found a media Group");
                            if (group.Title != null)
                            {
                                Tracing.TraceMsg(group.Title.Value);
                            }
                            if (group.Keywords != null)
                            {
                                Tracing.TraceMsg(group.Keywords.Value);
                            }
                            if (group.Credit != null)
                            {
                                Tracing.TraceMsg(group.Credit.Value);
                            }
                            if (group.Description != null)
                            {
                                Tracing.TraceMsg(group.Description.Value);
                            }
                        }


                        PhotoAccessor photo = new PhotoAccessor(entry);

                        Assert.IsTrue(entry.IsPhoto, "this is a photo entry, it should have the kind set");
                        Assert.IsTrue(photo != null, "this is a photo entry, it should convert to PhotoEntry");

                        Assert.IsTrue(photo.AlbumId != null);
                        Assert.IsTrue(photo.Height > 0);
                        Assert.IsTrue(photo.Width > 0);
                    }
                }

                factory.MethodOverride = false;
            }
        }
        /// <summary>
        /// Syncs a local folder to an online Picasa Web Album location
        /// </summary>
        /// <param name="sourceFolder">The source folder to sync.</param>
        /// <param name="albumNamePrefix">A prefix to prepend to the album name.</param>
        /// <param name="includeSubFolders">Indicated whether to sync all subfolders recursively.</param>
        /// <param name="session">The current authenticated Picasa session.</param>
        /// <param name="albumFeed">A feed listing all existing Picass Web Albums in the Picasa account.</param>
        private void SyncFolder(DirectoryInfo sourceFolder, string albumNamePrefix, AlbumAccessEnum targetAlbumAccess, bool includeSubFolders, PicasaService session, PicasaFeed albumFeed)
        {
            if (!sourceFolder.Exists)
            {
                throw new DirectoryNotFoundException(string.Format("Folder '{0}' cannot be located.", sourceFolder.FullName));
            }

            string targetAlbumName = GetTargetAlbumName(sourceFolder, albumNamePrefix);
            Dictionary <string, FileInfo> sourceFiles = GetSourceFiles(sourceFolder);
            bool        excludeFolder      = ShouldExcludeFolder(sourceFolder, sourceFiles);
            PicasaEntry existingAlbumEntry = albumFeed.Entries.FirstOrDefault(a => a.Title.Text == targetAlbumName) as PicasaEntry;

            if (excludeFolder)
            {
                if (existingAlbumEntry != null && !this.AddOnly)
                {
                    //album needs to be removed
                    WriteOutput(string.Format("Removing Album: {0} (excluded but already exists)", targetAlbumName));
                    existingAlbumEntry.Delete();
                    existingAlbumEntry.Summary.Text = ENTRY_DELETED_SUMMARY;
                    m_albumDeleteCount++;
                }
                else
                {
                    m_folderSkipCount++;
                }
            }
            else
            {
                WriteOutput(string.Format("Syncing Folder: {0} to Album: {1}", sourceFolder.FullName, targetAlbumName), true);

                try
                {
                    targetAlbumAccess = DetermineAlbumAccess(sourceFolder, targetAlbumAccess);

                    if (sourceFiles.Count > 0)
                    {
                        Album targetAlbum = new Album();
                        if (existingAlbumEntry != null)
                        {
                            targetAlbum.AtomEntry = existingAlbumEntry;
                            if (targetAlbum.Access != targetAlbumAccess.ToString().ToLower())
                            {
                                UpdateAlbumAccess(session, targetAlbum, targetAlbumAccess);
                            }
                        }
                        else
                        {
                            targetAlbum = CreateAlbum(session, albumFeed, targetAlbumName, targetAlbumAccess);
                        }

                        PhotoQuery existingAlbumPhotosQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername, targetAlbum.Id));
                        PicasaFeed existingAlbumPhotosFeed  = session.Query(existingAlbumPhotosQuery);

                        //sync folder files
                        DeleteFilesFromAlbum(sourceFiles, existingAlbumPhotosFeed);

                        foreach (KeyValuePair <string, FileInfo> file in sourceFiles.OrderBy(f => f.Value.LastWriteTime))
                        {
                            AddFileToAlbum(file.Value, targetAlbum, existingAlbumPhotosFeed, session);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteOutput(string.Format("Skipping Folder: {0} (Error - {1})", sourceFolder.Name, ex.Message), true);
                }

                if (includeSubFolders)
                {
                    DirectoryInfo[] subfolders = sourceFolder.GetDirectories().OrderBy(d => d.CreationTime).ToArray();
                    if (subfolders.Length > 0)
                    {
                        foreach (DirectoryInfo folder in subfolders)
                        {
                            SyncFolder(folder, targetAlbumName, targetAlbumAccess, includeSubFolders, session, albumFeed);
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        private static string GetSlideShow(string albumId)
        {
            string s;

            try
            {
                var    service = new PicasaService("exampleCo-exampleApp-1");
                string usr     = Settings.GetSingleValue("Account") + "@gmail.com";
                string pwd     = Settings.GetSingleValue("Password");
                service.setUserCredentials(usr, pwd);

                var        query = new AlbumQuery(PicasaQuery.CreatePicasaUri(usr));
                PicasaFeed feed  = service.Query(query);

                string id  = "";
                string key = "";

                foreach (PicasaEntry entry in feed.Entries)
                {
                    var ac = new AlbumAccessor(entry);

                    if (ac.Name == albumId)
                    {
                        id = ac.Id;
                        string feedUri = entry.FeedUri;
                        if (feedUri.Contains("authkey="))
                        {
                            string authKey = feedUri.Substring(feedUri.IndexOf("authkey=")).Substring(8);
                            key = authKey;
                        }
                    }
                }

                if (key.Length > 0)
                {
                    key = "authkey%3D" + key;
                }

                string user = Settings.GetSingleValue("Account");

                string auto = "";
                if (bool.Parse(Settings.GetSingleValue("AutoPlay")) == false)
                {
                    auto = "&noautoplay=1";
                }

                string width  = Settings.GetSingleValue("ShowWidth");
                string height = "96";

                if (int.Parse(width) > 0)
                {
                    height = (int.Parse(width) * 0.74).ToString();
                }
                s = string.Format(Tag, id, key, user, auto, width, height);
            }
            catch (Exception exp)
            {
                s = exp.Message;
            }
            return(s);
        }