PhotosetsGetList() public method

Gets a list of the currently authenticated users photosets.
public PhotosetsGetList ( ) : Photosets
return Photosets
Exemplo n.º 1
3
        public IPhoto UploadPhoto(Stream stream, string filename, string title, string description, string tags)
        {
            using (MiniProfiler.Current.Step("FlickrPhotoRepository.UploadPhoto"))
            {
                Flickr fl = new Flickr();

                string authToken = (ConfigurationManager.AppSettings["FlickrAuth"] ?? "").ToString();
                if (string.IsNullOrEmpty(authToken))
                    throw new ApplicationException("Missing Flickr Authorization");

                fl.AuthToken = authToken;
                string photoID = fl.UploadPicture(stream, filename, title, description, tags, true, true, false,
                    ContentType.Photo, SafetyLevel.Safe, HiddenFromSearch.Visible);
                var photo = fl.PhotosGetInfo(photoID);
                var allSets = fl.PhotosetsGetList();
                var blogSet = allSets
                                .FirstOrDefault(s => s.Description == "Blog Uploads");
                if (blogSet != null)
                    fl.PhotosetsAddPhoto(blogSet.PhotosetId, photo.PhotoId);

                FlickrPhoto fphoto = new FlickrPhoto();
                fphoto.Description = photo.Description;
                fphoto.WebUrl = photo.MediumUrl;
                fphoto.Title = photo.Title;
                fphoto.Description = photo.Description;

                return fphoto;
            }
        }
Exemplo n.º 2
1
        static void Main(string[] args)
        {
            Flickr flickr = new Flickr(FlickrKey.Key, FlickrKey.Secret);
            Auth auth = null;
            if (File.Exists("key.txt"))
            {
                using (var sr = new StreamReader("key.txt"))
                {
                    flickr.OAuthAccessToken = sr.ReadLine();
                    flickr.OAuthAccessTokenSecret = sr.ReadLine();
                }

            }

            if (!string.IsNullOrEmpty(flickr.OAuthAccessToken) &&
                 !string.IsNullOrEmpty(flickr.OAuthAccessTokenSecret))
            {
                auth = flickr.AuthOAuthCheckToken();
                int g = 56;
            }
            else
            {
                var requestToken = flickr.OAuthGetRequestToken("oob");
                var url = flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Delete);
                Process.Start(url);

                var verifier = Console.ReadLine();

                OAuthAccessToken accessToken = flickr.OAuthGetAccessToken(requestToken, verifier);
                flickr.OAuthAccessToken = accessToken.Token;
                flickr.OAuthAccessTokenSecret = accessToken.TokenSecret;

                using (var sw = new StreamWriter("key.txt", false))
                {
                    sw.WriteLine(flickr.OAuthAccessToken);
                    sw.WriteLine(flickr.OAuthAccessTokenSecret);
                }

                auth = flickr.AuthOAuthCheckToken();
                int y = 56;
            }

            var baseFolder = @"D:\MyData\Camera Dumps\";

            var ex = new PhotoSearchExtras();
            var p = flickr.PhotosSearch(new PhotoSearchOptions(auth.User.UserId){Extras = PhotoSearchExtras.DateTaken | PhotoSearchExtras.PathAlias, });
            var sets = flickr.PhotosetsGetList();
            foreach (var set in sets)
            {
                var setDir = Path.Combine(baseFolder, set.Title);
                if ( Directory.Exists(setDir) )
                {
                    var setPhotos = flickr.PhotosetsGetPhotos(set.PhotosetId, PhotoSearchExtras.DateTaken | PhotoSearchExtras.MachineTags | PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.DateUploaded);
                    foreach(var setPhoto in setPhotos)
                    {
                        if (Math.Abs((setPhoto.DateUploaded - setPhoto.DateTaken).TotalSeconds) < 60)
                        {
                            // Suspicious
                            int s = 56;
                        }

                        string ext = ".jpg";
                        if (setPhoto.OriginalFormat != "jpg")
                        {
                            int xxx = 56;
                        }
                        var filePath = Path.Combine(setDir, setPhoto.Title + ext);

                        if (!File.Exists(filePath))
                        {
                            // try mov
                            filePath = Path.Combine(setDir, setPhoto.Title + ".mov");

                            if (!File.Exists(filePath))
                            {
                                Console.WriteLine("not found " + filePath);
                            }
                        }

                        Console.WriteLine(filePath);
                        if ( File.Exists(filePath))
                        {
                            DateTime dateTaken;
                            if (!GetExifDateTaken(filePath, out dateTaken))
                            {
                                var fi = new FileInfo(filePath);
                                dateTaken = fi.LastWriteTime;
                            }

                            if (Math.Abs((dateTaken - setPhoto.DateTaken).TotalSeconds) > 10)
                            {
                                int hmmm = 56;
                            }
                        }
                    }
                }
            }
            //@"D:\MyData\Camera Dumps\"

            int z =  56;
        }
Exemplo n.º 3
0
        public string UploadPhotographToFlickr(string flickrAuth, string title, string description, string path, string tag)
        {
            try
            {
                flickr.AuthToken = flickrAuth;

                bool uploadAsPublic = true;

                string photoId = flickr.UploadPicture(ConfigurationManager.AppSettings["TempFileLocalPath"].ToString(), title, description, tag, uploadAsPublic, false, false);
                if (photoId != null && photoId != "")
                {
                    bool setFlag = false;

                    // Get list of users sets
                    PhotosetCollection sets = flickr.PhotosetsGetList();

                    //add photo to appropriate skichair photoset
                    foreach (Photoset set in sets)
                    {
                        if (set.Title.Equals(tag))
                        {
                            setFlag = true;
                            //add the photo to that set
                            AddPhotoToPhotoset(set.PhotosetId, photoId);
                            break;
                        }
                    }

                    //if photoset didn't exist create it
                    if (!setFlag)
                    {
                        //create photoset and add photo to it
                        CreateFlickrPhotoSet(tag, photoId);
                        flickr.GroupsPoolsAdd(photoId, Utility.FlickrGroupID);
                    }

                    return(photoId);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception ex)
            {
                System.IO.StreamWriter sw = System.IO.File.AppendText(ConfigurationManager.AppSettings["ErrorLogPath"].ToString() + "SkiChairErrorLogFile.txt");
                try
                {
                    string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, "Error: " + ex.Message);
                    sw.WriteLine(logLine);
                }
                finally
                {
                    sw.Close();
                }
                return("");
            }
        }
Exemplo n.º 4
0
        public IEnumerable <string> GetRoots()
        {
            yield return("/"); // for photos not in a set

            int page     = 1;
            int maxPages = 1;

            while (page <= maxPages)
            {
                // existing sources gives us a list of photoset ids
                PhotosetCollection photosets;
                try
                {
                    photosets = _flickr.PhotosetsGetList();
                    maxPages  = photosets.Pages;
                    page++;
                }
                catch
                {
                    photosets = new PhotosetCollection();
                }
                foreach (var root in photosets.Select(s => s.PhotosetId + "/"))
                {
                    yield return(root);
                }
            }
        }
Exemplo n.º 5
0
        public static PhotosetCollection GetPhotoSetsByUser(string userId)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
                ConfigurationManager.AppSettings["sharedSecret"]);

            return flickr.PhotosetsGetList(userId);
        }
Exemplo n.º 6
0
 public PhotoDetails(string path)
 {
     this.components = null;
     this.InitializeComponent();
     if (!File.Exists(path))
     {
         throw new Exception("Invalid ConfigFilePath: " + path);
     }
     this._settings    = new Settings(path);
     this.txtTags.Text = this._settings.Tags;
     FlickrNet.Flickr flickr1 = new FlickrNet.Flickr("ab782e182b4eb406d285211811d625ff", "b080496c05335c3d", this._settings.Token);
     try
     {
         Photosets photosets1 = flickr1.PhotosetsGetList();
         foreach (Photoset photoset1 in photosets1.PhotosetCollection)
         {
             PhotoSetItem item1 = new PhotoSetItem(photoset1.PhotosetId, photoset1.Title);
             this.cboPhotoSets.Items.Add(item1);
             if (photoset1.PhotosetId == this._settings.PhotoSet)
             {
                 this.cboPhotoSets.SelectedItem = item1;
             }
         }
     }
     catch (FlickrException exception1)
     {
         MessageBox.Show("There was a problem in communicating with Flickr via the Flickr API.  " + exception1.Message);
     }
 }
Exemplo n.º 7
0
        private void BGFindPhotosets(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            FlickrNet.Flickr f = FlickrManager.GetFlickrAuthInstance();
            if (f == null)
            {
                BGErrorMessage = "You must authenticate before you can download data from Flickr.";
                return;
            }

            try
            {
                int page    = 1;
                int perPage = 500;
                FlickrNet.PhotosetCollection photoSets      = new FlickrNet.PhotosetCollection();
                FlickrNet.PhotoSearchExtras  PhotosetExtras = 0;
                do
                {
                    photoSets = f.PhotosetsGetList(SearchAccountUser.UserId, page, perPage, PhotosetExtras);
                    foreach (FlickrNet.Photoset ps in photoSets)
                    {
                        PhotosetList.Add(new Photoset(ps));
                        int index = PhotosetList.Count - 1;
                        PhotosetList[index].OriginalSortOrder = index;
                    }
                    page = photoSets.Page + 1;
                }while (page <= photoSets.Pages);
            }
            catch (FlickrNet.FlickrException ex)
            {
                BGErrorMessage = "Album search failed. Error: " + ex.Message;
                return;
            }
        }
Exemplo n.º 8
0
        private void UpdatePhotoButton_Click(object sender, EventArgs e)
        {
            Flickr flickr = new Flickr(ApiKey.Text, SharedSecret.Text, AuthToken.Text);

            flickr.PhotosSetMeta(PhotoId.Text, NewTitle.Text, null);

            OutputTextbox.Text += "Photo title updated";

            PhotosetCollection sets = flickr.PhotosetsGetList();
            Photoset set = sets[0];

            flickr.PhotosetsAddPhoto(set.PhotosetId, PhotoId.Text);
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Refresh the list of photosets from the Flickr service.
        /// </summary>
        private void LoadPhotosets(bool circumventCache)
        {
            var c = this.Cursor;

            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

                this.cboPhotosets.Items.Clear();
                var item = new PhotoSetItem("-none-", "-none-");
                this.cboPhotosets.Items.Add(item);
                this.cboPhotosets.SelectedItem = item;

                // add in the explicit photosets
                if (circumventCache)
                {
                    _flickr.PhotosetsGetList();
                    FlickrNet.Flickr.FlushCache(_flickr.LastRequest);
                }
                var psc = _flickr.PhotosetsGetList();
                Tracing.Trace("PhotoDetails::ctor psc {0} items", psc.Count);
                foreach (var photoset in psc)
                {
                    Tracing.Trace("PhotoDetails::ctor item {0}", photoset.PhotosetId);
                    item = new PhotoSetItem(photoset.PhotosetId, photoset.Title);
                    this.cboPhotosets.Items.Add(item);
                    if (photoset.PhotosetId == this._settings.MostRecentPhotosetId)
                    {
                        this.cboPhotosets.SelectedItem = item;
                    }
                }
            }
            catch (FlickrException exception1)
            {
                MessageBox.Show("There was a problem in communicating with Flickr via the Flickr API.  " + exception1.Message);
            }

            this.Cursor = c;
        }
Exemplo n.º 10
0
        public RemoteInfo()
        {
            try
            {
                f = new Flickr(Properties.Settings.Default.FlickrApiKey, Properties.Settings.Default.FlickrShared, Properties.Settings.Default.FlickrToken);
                f.Proxy = FlickrSync.GetProxy(true);
                f.OnUploadProgress += new Flickr.UploadProgressHandler(Flickr_OnUploadProgress);
                sets = f.PhotosetsGetList().PhotosetCollection;
                if (sets == null)
                    sets = new Photoset[0];

                string user = User();  //force access to check connection
            }
            catch (Exception ex)
            {
                FlickrSync.Error("Error connecting to flickr", ex, FlickrSync.ErrorType.Connect);
            }
        }
Exemplo n.º 11
0
        private void ButtonSets_Click(object sender, EventArgs e)
        {
            var flickr = new Flickr(Program.ApiKey, Program.SharedSecret, Program.AuthToken);
            // Liste des albums
            var sets = flickr.PhotosetsGetList();
            string setlist = "";
            foreach (Photoset pset in sets) setlist += pset.Title + "\n";
            MessageBox.Show("Liste des albums\n" + setlist, "Liste des albums",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            // Statistiques
            var statfile = new System.IO.StreamWriter("albums_stats.csv");
            var reffile = new System.IO.StreamWriter("albums_referrers.csv");
            DateTime day = DateTime.Today;
            statfile.WriteLine("Date;Album;Vues;Favoris;Commentaires");
            reffile.WriteLine("Date;Album;Domain;Views");
            while (day > Program.LastUpdate)
            {
                foreach (Photoset pset in sets)
                {
                    StatusLabel.Text = "Stats de l'album " +
                        pset.Title + " pour le " + day.ToShortDateString();
                    Application.DoEvents();
                    try
                    {
                        var s = flickr.StatsGetPhotosetStats(day, pset.PhotosetId);
                        statfile.WriteLine(day.ToShortDateString() + ";" +
                            pset.Title + ";" + Utility.toCSV(s));
                        var r = flickr.StatsGetPhotosetDomains(day, pset.PhotosetId, 1, 100);
                        reffile.WriteLine(Utility.toCSV(r, day.ToShortDateString() + ";" + pset.Title));
                    }
                    catch(FlickrApiException ex)
                    { }
                }

                day -= TimeSpan.FromDays(1);
            }
            statfile.Close(); reffile.Close();
        }
Exemplo n.º 12
0
    public Result <GetPhotosetsResponse> GetPhotosets()
    {
        var photosets = _flickr.PhotosetsGetList();

        return(Result <GetPhotosetsResponse> .Of(new GetPhotosetsResponse
        {
            Total = photosets.Total,
            PageSize = photosets.PerPage,
            Photosets = photosets.ConvertAll(x => new GetPhotosetsResponse.Photoset
            {
                Id = x.PhotosetId,
                Title = x.Title,
                Description = x.Description,
                CreatedAt = x.DateCreated,
                PhotoCount = x.NumberOfPhotos,
                PrimaryPhoto = new GetPhotosetsResponse.PrimaryPhoto
                {
                    Latitude = x.PrimaryPhoto.Latitude,
                    Longitude = x.PrimaryPhoto.Longitude,
                    ImageUrlSmall = x.PrimaryPhoto.SmallUrl
                }
            })
        }));
    }
Exemplo n.º 13
0
        // GET: /Gallery/
        public ActionResult Gallery()
        {
            Flickr flickr = new Flickr(myApiKey);

            /*IOrderedEnumerable<FlickrNet.Photoset> photoCollection = flickr.PhotosetsGetList(myId, PhotoSearchExtras.DateTaken).OrderByDescending(d => d.PrimaryPhoto.DateTaken);
            IOrderedEnumerable<FlickrNet.Photo> photoList;

            foreach (Photoset ps in photoCollection)
            {
                ps.PrimaryPhoto.
            }*/

            ViewBag.albumList = flickr.PhotosetsGetList(myId, PhotoSearchExtras.DateTaken | PhotoSearchExtras.MediumUrl).OrderByDescending(d => d.PrimaryPhoto.DateTaken);

            return View();
        }
Exemplo n.º 14
0
        //public ActionResult LoadContent(string dirName, string pageName)
        //{
        //    var page = ContentService.GetPage(dirName, pageName);
        //    if (page == null) page = new Content();
        //    if (pageName == "index") return View("Index");
        //    else return View("Content", page);
        //}
        public ActionResult LoadContent(string pageName)
        {
            pageName = pageName.ToLower();

            if (pageName == "index")
            {
                var im = new IndexModel();
                var blm = new BlogListModel();
                var posts = BlogService.GetLatestPosts(5);

                blm.ListTitle = "NEWSFLASH";
                blm.Posts = posts;

                im.BlogList = blm;

                return View(pageName, im);
            }
            else if (pageName == "juniors")
            {
                var jm = new JuniorsModel();
                var blm = new BlogListModel();
                var posts = BlogService.GetPostsByCategory("juniors");

                blm.ListTitle = "JUNIORS UPDATES";
                blm.Posts = posts;

                jm.BlogList = blm;

                return View(pageName, jm);
            }
            else if (pageName == "adults")
            {
                var am = new AdultsModel();
                var blm = new BlogListModel();
                var posts = BlogService.GetPostsByCategory("adults");

                blm.ListTitle = "ADULTS UPDATES";
                blm.Posts = posts;

                am.BlogList = blm;

                return View(pageName, am);
            }
            else if (pageName == "construction")
            {
                var cm = new ConstructionModel();
                var blm = new BlogListModel();
                var posts = BlogService.GetPostsByCategory("construction");

                blm.ListTitle = "CONSTRUCTION UPDATES";
                blm.Posts = posts;

                cm.BlogList = blm;

                return View(pageName, cm);
            }
            else if (pageName == "about-us")
            {
                var am = new AboutUsModel();
                var blm = new BlogListModel();
                var posts = BlogService.GetPostsByCategory("general");

                blm.ListTitle = "CLUB NEWS";
                blm.Posts = posts;

                am.BlogList = blm;

                return View(pageName, am);

            }
            else if (pageName == "gallery")
            {
                Flickr flickr = new Flickr(ConfigurationManager.AppSettings["FlickrKey"], ConfigurationManager.AppSettings["FlickrSecret"]);

                FoundUser user = flickr.PeopleFindByEmail("*****@*****.**");

                var photos = flickr.PhotosetsGetList(user.UserId);

                foreach (var set in photos)
                {
                    Response.Write(set.Title + "<br>");
                }

                return View(pageName);
            }
            else
            {
                return View(pageName);
            }
        }