public void PhotosetsGetPhotosBasicTest()
        {
            PhotosetPhotoCollection set = Instance.PhotosetsGetPhotos("72157618515066456", PhotoSearchExtras.All, PrivacyFilter.None, 1, 10);

            Assert.AreEqual(8, set.Total, "NumberOfPhotos should be 8.");
            Assert.AreEqual(8, set.Count, "Should be 8 photos returned.");
        }
コード例 #2
0
        private void __loadGallery(string gallery)
        {
            string flickrKey    = "a0232444363301974055795c8f8f2457";
            string sharedSecret = "ae24c71aacfb57c9";
            //string tag = "lol";
            PhotoSearchOptions options = new PhotoSearchOptions();

            options.PerPage = 12;
            options.Page    = 1;
            //options.SortOrder = PhotoSearchSortOrder.DatePostedDescending;
            //options.MediaType = MediaType.Photos;
            //options.Extras = PhotoSearchExtras.All;
            //options.ga
            ////options.Tags = tag;
            options.Username     = "******";
            Flickr.CacheDisabled = true;
            Flickr flickr = new Flickr(flickrKey, sharedSecret);

            PhotosetPhotoCollection photos = flickr.PhotosetsGetPhotos(gallery, PhotoSearchExtras.All);

            // PhotoCollection photos = flickr.PhotosSearch(options);

            ThumbnailsList.DataSource = photos;
            ThumbnailsList.DataBind();
        }
コード例 #3
0
        /// <summary>
        /// Retrieves a list of photo identifiers for a specific photoset
        /// </summary>
        /// <param name="flickrContext">The flickr context</param>
        /// <param name="photoSetId">The flickr photoset</param>
        /// <param name="verbose">Verbosity is enabled</param>
        /// <returns>list of image identifiers in photoset</returns>
        private static List <string> GetAllPhotoIDsFromSet(Flickr flickrContext, string photoSetId, bool verbose)
        {
            List <string> output = new List <string>();

            Photoset photoSetInfo   = GetPhotoSet(flickrContext, photoSetId);
            int      perPage        = 500;
            int      totalPageCount = photoSetInfo.Total / perPage + 1;

            for (int currentPage = 1; currentPage < totalPageCount + 1; currentPage++)
            {
                if (verbose == true)
                {
                    Console.WriteLine($"  Processing '{photoSetInfo.Title}' page {currentPage} of {totalPageCount}");
                }

                PhotosetPhotoCollection setPhotoPage = flickrContext.PhotosetsGetPhotos(photoSetId, currentPage, perPage);

                if (verbose == true)
                {
                    Console.WriteLine($"    Got {setPhotoPage.Count}");
                }

                foreach (var photo in setPhotoPage)
                {
                    output.Add(photo.PhotoId);
                }
            }

            if (verbose == true)
            {
                Console.WriteLine($"  Finished Processing '{photoSetInfo.Title}'");
            }

            return(output);
        }
コード例 #4
0
ファイル: FlickrBLL.cs プロジェクト: ziakhan78/DD2020-21
        public static int GetPagedSetCount(string setId)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
                                       ConfigurationManager.AppSettings["shardSecret"]);
            //Photoset set = flickr.PhotosetsGetInfo(setId);
            //return set.NumberOfPhotos;
            PhotosetPhotoCollection set = flickr.PhotosetsGetPhotos(setId);

            return(set.Total);
        }
コード例 #5
0
ファイル: FlickrBLL.cs プロジェクト: ziakhan78/DD2020-21
        public static PhotosetPhotoCollection GetPagedSet(string setId,
                                                          int maximumRows, int startRowIndex)
        {
            Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
                                       ConfigurationManager.AppSettings["shardSecret"]);
            PhotosetPhotoCollection photos = flickr.PhotosetsGetPhotos(setId, GetPageIndex(
                                                                           startRowIndex, maximumRows) + 1, maximumRows);

            return(photos);
        }
コード例 #6
0
        public void PhotosetsGetPhotosWebUrlTest()
        {
            PhotosetPhotoCollection theset = f.PhotosetsGetPhotos("72157618515066456");

            foreach (Photo p in theset)
            {
                Assert.IsNotNull(p.UserId, "UserId should not be null.");
                Assert.AreNotEqual <String>(String.Empty, p.UserId, "UserId should not be an empty string.");
                string url = "http://www.flickr.com/photos/" + p.UserId + "/" + p.PhotoId + "/";
                Assert.AreEqual <string>(url, p.WebUrl);
            }
        }
コード例 #7
0
        public void PhotosetsGetPhotosMachineTagsTest()
        {
            PhotosetPhotoCollection set = f.PhotosetsGetPhotos("72157594218885767", PhotoSearchExtras.MachineTags, PrivacyFilter.None, 1, 10);

            bool machineTagsFound = false;

            foreach (Photo p in set)
            {
                if (!String.IsNullOrEmpty(p.MachineTags))
                {
                    machineTagsFound = true;
                    break;
                }
            }

            Assert.IsTrue(machineTagsFound, "No machine tags were found in the photoset");
        }
コード例 #8
0
        public DomainPhotos Convert(PhotosetPhotoCollection photosetPhotos)
        {
            if (photosetPhotos == null)
            {
                return(null);
            }

            var domainPhotos = photosetPhotos
                               .Select(photo => new DomainPhoto(
                                           photo.PhotoId, photo.UserId, photo.OwnerName, string.IsNullOrEmpty(photo.PathAlias) ? photo.UserId : photo.PathAlias,
                                           photo.Title, photo.WebUrl,
                                           photo.Medium640Url, photo.Medium640Width ?? 640, photo.Medium640Width ?? 640,
                                           photo.IsLicensed(), photo.DateTaken, photo.Views))
                               .ToList();


            return(new DomainPhotos(domainPhotos, photosetPhotos.Page, photosetPhotos.Pages));
        }
コード例 #9
0
        public void PhotosetsGetPhotosFilterMediaTest()
        {
            // http://www.flickr.com/photos/sgoralnick/sets/72157600283870192/
            // Set contains videos and photos
            PhotosetPhotoCollection theset = f.PhotosetsGetPhotos("72157600283870192", PhotoSearchExtras.Media, PrivacyFilter.None, 1, 100, MediaType.Videos);

            foreach (Photo p in theset)
            {
                Assert.AreEqual("video", p.Media, "Should be video.");
            }

            PhotosetPhotoCollection theset2 = f.PhotosetsGetPhotos("72157600283870192", PhotoSearchExtras.Media, PrivacyFilter.None, 1, 100, MediaType.Photos);

            foreach (Photo p in theset2)
            {
                Assert.AreEqual("photo", p.Media, "Should be photo.");
            }
        }
コード例 #10
0
ファイル: FlickrService.cs プロジェクト: cmeigs/SkiChair
        /// <summary>
        /// this method will get all photos belonging to a particular set given its unique set ID
        /// </summary>
        /// <param name="setID">ID of the photo set</param>
        /// <returns>Generic list of type Photograph</returns>
        public List <Photograph> GetPhotoSetPhotoListBySetID(string setID)
        {
            try
            {
                List <Photograph>       photoList = new List <Photograph>();
                PhotosetPhotoCollection photos    = flickr.PhotosetsGetPhotos(setID);

                foreach (Photo photo in photos)
                {
                    photoList.Add(new Photograph(photo.PhotoId, photo.ThumbnailUrl, photo.MediumUrl, photo.Title));
                }

                return(photoList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
コード例 #11
0
        public void PhotosetsGetPhotosPrimaryPhotoTest()
        {
            PhotosetPhotoCollection theset = f.PhotosetsGetPhotos("72157618515066456", 1, 100);

            Assert.IsNotNull(theset.PrimaryPhotoId, "PrimaryPhotoId should not be null.");

            if (theset.Total < theset.PerPage)
            {
                Photo primary = null;
                foreach (Photo p in theset)
                {
                    if (p.PhotoId == theset.PrimaryPhotoId)
                    {
                        primary = p;
                        break;
                    }
                }

                Assert.IsNotNull(primary, "Primary photo should have been found.");
            }
        }
コード例 #12
0
        public IEnumerable <CollectionFlickr> GetSchema()
        {
            string cFlickrschemaTxt = FlickrSchemaCacheFilePath();

            if (File.Exists(cFlickrschemaTxt) && _reloadFromFlickr == false)
            {
                string readAllText = File.ReadAllText(cFlickrschemaTxt);
                List <CollectionFlickr> deserializeObject = JsonConvert.DeserializeObject <List <CollectionFlickr> >(readAllText);

                return(deserializeObject);
            }

            CollectionCollection collectionsGetTree = _flickr.CollectionsGetTree();

            List <CollectionFlickr> collections = new List <CollectionFlickr>(collectionsGetTree.Count);

            foreach (Collection collectionFlickr in collectionsGetTree)
            {
                CollectionFlickr flickr = new CollectionFlickr
                {
                    Id           = collectionFlickr.CollectionId,
                    Title        = collectionFlickr.Title,
                    AlbumsFlickr = new BindingList <AlbumFlickr>()
                };

                foreach (CollectionSet collectionSet in collectionFlickr.Sets)
                {
                    AlbumFlickr albumFlickr = new AlbumFlickr
                    {
                        Id    = collectionSet.SetId,
                        Title = collectionSet.Title
                    };
                    flickr.AlbumsFlickr.Add(albumFlickr);

                    _log.DebugFormat("Getting photos from album: [{0}]", albumFlickr.Title);
                    int page = 1;
                    PhotosetPhotoCollection photosetPhotoCollection = new PhotosetPhotoCollection();
                    int numberOfPhotos = _flickr.PhotosetsGetInfo(albumFlickr.Id).NumberOfPhotos;

                    while (true)
                    {
                        int count = 0;

                        if (numberOfPhotos >= 100)
                        {
                            count           = 100;
                            numberOfPhotos -= 100;
                        }
                        else
                        {
                            count          = numberOfPhotos;
                            numberOfPhotos = 0;
                        }

                        PhotosetPhotoCollection getPhotosetPhotoCollection = _flickr.PhotosetsGetPhotos(albumFlickr.Id, page, count);

                        foreach (Photo getPhoto in getPhotosetPhotoCollection)
                        {
                            photosetPhotoCollection.Add(getPhoto);
                        }

                        if (numberOfPhotos == 0)
                        {
                            break;
                        }

                        page++;
                    }

                    albumFlickr.PhotoList = new BindingList <PhotoFlickr>();

                    foreach (Photo photoFromSet in photosetPhotoCollection)
                    {
                        albumFlickr.PhotoList.Add(new PhotoFlickr
                        {
                            Id    = photoFromSet.PhotoId,
                            Title = photoFromSet.Title,
                            Tags  = photoFromSet.Tags.ToList()
                        });
                    }
                }

                collections.Add(flickr);
            }

            string serializeObject = JsonConvert.SerializeObject(collections);

            File.WriteAllText(cFlickrschemaTxt, serializeObject);

            return(collections);
        }