Exemplo n.º 1
0
        public void ExcessiveTagsShouldNotThrowUriFormatException()
        {
            var list    = Enumerable.Range(1, 9000).Select(i => "reallybigtag" + i).ToList();
            var options = new PhotoSearchOptions {
                Tags = string.Join(",", list)
            };

            Should.Throw <FlickrApiException>(() => Instance.PhotosSearch(options));
        }
Exemplo n.º 2
0
        public void PhotosSearchGalleryPhotos()
        {
            var o = new PhotoSearchOptions {
                UserId = TestData.TestUserId, InGallery = true, Tags = "art"
            };
            var photos = Instance.PhotosSearch(o);

            Assert.AreEqual(1, photos.Count, "Only one photo should have been returned.");
        }
 public static void FormatSearchOptions(PhotoSearchOptions photoSearchOptions)
 {
     Console.WriteLine("---- PhotoSearch Options ----");
     Console.WriteLine("UserId:" + photoSearchOptions.UserId);
     Console.WriteLine("Machine Tags:" + photoSearchOptions.MachineTags);
     Console.WriteLine("Extras:" + photoSearchOptions.Extras);
     Console.WriteLine("HasGeo:" + photoSearchOptions.HasGeo);
     Console.WriteLine("PerPage:" + photoSearchOptions.PerPage);
     Console.WriteLine("----------------------------");
 }
Exemplo n.º 4
0
        public async System.Threading.Tasks.Task searchPhotoAsync(PhotoSearchOptions options)
        {
            PhotoCollection photos = await flickr.PhotosSearchAsync(options);

            GalleryList.Clear();
            foreach (var photo in photos)
            {
                GalleryList.Add(new flickr_photos(photo.Small320Url));
            }
        }
Exemplo n.º 5
0
        public async void SearchDataFromFlickr(string query)
        {
            ImagesUrls = new ObservableCollection <ThumbnailImage>();
            var o = new PhotoSearchOptions {
                Tags = query, Extras = PhotoSearchExtras.All
            };
            var results = await FlickrBase.Instance.PhotosSearchAsync(o);

            handleResults(results, ImagesUrls);
        }
Exemplo n.º 6
0
        public void PhotosSearchPageTest()
        {
            var o = new PhotoSearchOptions {
                Tags = "colorful", PerPage = 10, Page = 3
            };

            PhotoCollection photos = Instance.PhotosSearch(o);

            Assert.AreEqual(3, photos.Page);
        }
Exemplo n.º 7
0
        public void PhotosSearchAuthRussianCharacters()
        {
            var o = new PhotoSearchOptions();

            o.Tags = "снег";

            var photos = AuthInstance.PhotosSearch(o);

            Assert.AreNotEqual(0, photos.Count, "Search should return some results.");
        }
Exemplo n.º 8
0
        public void PhotosSearchSignedTest()
        {
            Flickr f = TestData.GetSignedInstance();
            var    o = new PhotoSearchOptions {
                Tags = "Test", PerPage = 5
            };
            PhotoCollection photos = f.PhotosSearch(o);

            Assert.AreEqual(5, photos.PerPage, "PerPage should equal 5.");
        }
        public async Task <string> GetLastUploadedPhotoUrl(string apiKey, string apiSecret, string userId, PhotoSize size = PhotoSize.Large)
        {
            if (apiKey == null)
            {
                throw new ArgumentNullException(nameof(apiKey));
            }
            if (apiSecret == null)
            {
                throw new ArgumentNullException(nameof(apiSecret));
            }
            if (userId == null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            var service = new Flickr(apiKey, apiSecret);

            var options = new PhotoSearchOptions(userId)
            {
                PerPage = 1,
                Extras  = PhotoSearchExtras.DateUploaded
            };

            _logger.LogDebug(() => $"Using Flickr user id: '{userId}'");
            _logger.Log($"Searching for latest photo ...");
            var photos = await service.PhotosSearchAsync(options);

            _logger.Log($"{photos.Count} photos found.");

            if (photos.Any())
            {
                var photo = photos[0];
                _logger.Log("Photo Id={0} Title=\"{1}\", Uploaded on {2}, URL={3}", photo.PhotoId, photo.Title,
                            photo.DateUploaded, photo.Medium640Url);

                switch (size)
                {
                case PhotoSize.Original:
                    return(photo.OriginalUrl);

                case PhotoSize.Medium:
                    return(photo.MediumUrl);

                case PhotoSize.Small:
                    return(photo.SmallUrl);

                default:
                    // you may not be able to access the original version of another user's photo
                    return(photo.LargeUrl);
                }
            }

            _logger.Log("No photos found.");
            return(null);
        }
        public void PhotosSearchRussianTagsReturned()
        {
            var o = new PhotoSearchOptions {
                UserId = "31828860@N08", Extras = PhotoSearchExtras.Tags
            };

            var photos = Instance.PhotosSearch(o);


            Assert.IsTrue(photos.Any(p => p.Title.Contains("роддоме")));
        }
Exemplo n.º 11
0
        public void PhotosSearchGalleryPhotos()
        {
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.UserId    = TestData.TestUserId;
            o.InGallery = true;
            o.Tags      = "art";
            PhotoCollection photos = TestData.GetInstance().PhotosSearch(o);

            Assert.AreEqual(1, photos.Count, "Only one photo should have been returned.");
        }
Exemplo n.º 12
0
        public void PhotosSearchFavorites()
        {
            var o = new PhotoSearchOptions {
                UserId = "me", Faves = true, Tags = "cat"
            };

            PhotoCollection p = AuthInstance.PhotosSearch(o);

            Assert.IsTrue(p.Count > 5, "Should have returned more than 5 result returned. Count = " + p.Count);
            Assert.IsTrue(p.Count < 100, "Should be less than 100 results returned. Count = " + p.Count);
        }
Exemplo n.º 13
0
        public async void ShouldReturnSimpleSearchResultsAsync()
        {
            var o = new PhotoSearchOptions {
                Tags = "colorful"
            };

            var photos = await Instance.PhotosSearchAsync(o);

            Assert.IsNotNull(photos, "Photos should not be null");
            Assert.IsNotEmpty(photos, "Photos should not be empty");
        }
Exemplo n.º 14
0
        public void RecuperationDePhotos()
        {
            var options = new PhotoSearchOptions
            {
                Tags    = "Pokemon",
                PerPage = 20,
                Page    = 1
            };

            searchPhotoAsync(options);
        }
Exemplo n.º 15
0
        public void StylesNotAddedToParameters_WhenItIsEmpty()
        {
            var o = new PhotoSearchOptions {
                Styles = new List <Style>()
            };
            var parameters = new Dictionary <string, string>();

            o.AddToDictionary(parameters);

            Assert.IsFalse(parameters.ContainsKey("styles"));
        }
Exemplo n.º 16
0
        public void StylesAddedToParameters_WhenItIsNotNullOrEmpty(params Style[] styles)
        {
            var o = new PhotoSearchOptions {
                Styles = new List <Style>(styles)
            };
            var parameters = new Dictionary <string, string>();

            o.AddToDictionary(parameters);

            Assert.IsTrue(parameters.ContainsKey("styles"));
        }
Exemplo n.º 17
0
        public PhotoCollection GetData()
        {
            Flickr flickr = new Flickr("43299afdd8dd4f0d915c524507aff544", "d3793728e72cb582");
            //var options = new PhotoSearchOptions { Tags = "sunset", PerPage = 20, Page = 1 };
            var options = new PhotoSearchOptions {
                Tags = "sunset", Extras = PhotoSearchExtras.Large2048Url
            };
            PhotoCollection photos = flickr.PhotosSearch(options);

            return(photos);
        }
Exemplo n.º 18
0
        public void PhotosSearchRussianTagsReturned()
        {
            var o = new PhotoSearchOptions {
                PerPage = 200, Extras = PhotoSearchExtras.Tags, Tags = "фото"
            };

            var photos = Instance.PhotosSearch(o);

            photos.Count.ShouldNotBe(0);
            photos.ShouldContain(p => p.Tags.Any(t => t == "фото"));
        }
        public async void Can_Search_Photos_by_MachineTag_Namespace(string namespaceQuery)
        {
            var photoSearchOptions = new PhotoSearchOptions()
            {
                MachineTags = namespaceQuery,
                Extras      = PhotoSearchExtras.All,
            };

            var photoCollection = await _searchService.SearchPhotosAsync(photoSearchOptions);

            Assert.NotNull(photoCollection);
        }
Exemplo n.º 20
0
        public void PhotosSearchDateTakenGranualityTest()
        {
            var o = new PhotoSearchOptions
            {
                UserId  = "8748614@N05",
                Tags    = "primavera",
                PerPage = 500,
                Extras  = PhotoSearchExtras.DateTaken
            };

            Instance.PhotosSearch(o);
        }
Exemplo n.º 21
0
        public void PhotosSearchOwnerNameTest()
        {
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.UserId  = Data.UserId;
            o.PerPage = 10;
            o.Extras  = PhotoSearchExtras.OwnerName;

            PhotoCollection photos = Instance.PhotosSearch(o);

            Assert.IsNotNull(photos[0].OwnerName);
        }
Exemplo n.º 22
0
        private PhotoSearchOptions GetSearchOption(double longitude, double latitude)
        {
            PhotoSearchOptions options = new PhotoSearchOptions
            {
                Extras    = PhotoSearchExtras.AllUrls | PhotoSearchExtras.Description | PhotoSearchExtras.OwnerName,
                SortOrder = PhotoSearchSortOrder.Relevance,
                Longitude = longitude,
                Latitude  = latitude
            };

            return(options);
        }
Exemplo n.º 23
0
        private void button1_Click(object sender, EventArgs e)
        {
            Flickr f = FlickrManager.GetInstance();

            PhotoSearchOptions o = new PhotoSearchOptions();

            o.Extras    = PhotoSearchExtras.AllUrls | PhotoSearchExtras.Description | PhotoSearchExtras.OwnerName;
            o.SortOrder = PhotoSearchSortOrder.Relevance;
            o.Tags      = textBox1.Text;

            bindingSource1.DataSource = f.PhotosSearch(o);
        }
Exemplo n.º 24
0
        public void PhotosSearchPageTest()
        {
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.Tags    = "colorful";
            o.PerPage = 10;
            o.Page    = 3;

            PhotoCollection photos = f.PhotosSearch(o);

            Assert.AreEqual(3, photos.Page);
        }
Exemplo n.º 25
0
        public void PhotosSearchDateTakenGranualityTest()
        {
            Flickr             f = TestData.GetInstance();
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.UserId  = "8748614@N05";
            o.Tags    = "primavera";
            o.PerPage = 500;
            o.Extras  = PhotoSearchExtras.DateTaken;

            PhotoCollection photos = f.PhotosSearch(o);
        }
        public void PhotosSearchLarge2048ImageSize()
        {
            var o = new PhotoSearchOptions {
                Extras = PhotoSearchExtras.Large2048Url, Tags = "colorful", MinUploadDate = DateTime.UtcNow.AddDays(-1)
            };

            var photos = Instance.PhotosSearch(o);

            Assert.IsNotNull(photos, "PhotosSearch should not return a null instance.");
            Assert.IsTrue(photos.Any(), "PhotoSearch should have returned some photos.");
            Assert.IsTrue(photos.Any(p => !String.IsNullOrEmpty(p.Large2048Url) && p.Large2048Height.HasValue && p.Large2048Width.HasValue));
        }
Exemplo n.º 27
0
        public PhotoCollection GetPhoto_ByHashCode(string hashCode)
        {
            Flickr flickr = new Flickr();

            var op = new PhotoSearchOptions();

            op.Tags = string.Format("MD5:{0}", hashCode);

            var l = flickr.PhotosSearch(op);

            return(l);
        }
Exemplo n.º 28
0
        private IEnumerable <ResponseMessage> FlickrHandler(IncomingMessage message, IValidHandle matchedHandle)
        {
            string searchTerm = message.TargetedText.Substring(matchedHandle.HandleHelpText.Length).Trim();

            if (string.IsNullOrEmpty(searchTerm))
            {
                yield return(message.ReplyToChannel($"Please give me something to search, e.g. {matchedHandle} trains"));
            }
            else
            {
                yield return(message.IndicateTypingOnChannel());

                string apiKey = _configReader.GetConfigEntry <string>("flickr:apiKey");

                if (string.IsNullOrEmpty(apiKey))
                {
                    _statsPlugin.IncrementState("Flickr:Failed");
                    yield return(message.ReplyToChannel("Woops, looks like a Flickr API Key has not been entered. Please ask the admin to fix this"));
                }
                else
                {
                    var flickr = new Flickr(apiKey);

                    var options = new PhotoSearchOptions {
                        Tags = searchTerm, PerPage = 50, Page = 1
                    };
                    PhotoCollection photos = flickr.PhotosSearch(options);

                    if (photos.Any())
                    {
                        _statsPlugin.IncrementState("Flickr:Sent");

                        int   i          = new Random().Next(0, photos.Count);
                        Photo photo      = photos[i];
                        var   attachment = new Attachment
                        {
                            AuthorName = photo.OwnerName,
                            Fallback   = photo.Description,
                            ImageUrl   = photo.LargeUrl,
                            ThumbUrl   = photo.ThumbnailUrl
                        };

                        yield return(message.ReplyToChannel($"Here is your picture about '{searchTerm}'", attachment));
                    }
                    else
                    {
                        _statsPlugin.IncrementState("Flickr:Failed");
                        yield return(message.ReplyToChannel($"Sorry @{message.Username}, I couldn't find anything about {searchTerm}"));
                    }
                }
            }
        }
Exemplo n.º 29
0
        // A region for simmiWorker
        #region
        // This method takes care of the process heavy stuff. It can report progress and I will use that
        // to load each image.
        private void simmiWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            Console.WriteLine("Async backgroundworker started");

            if ((worker.CancellationPending == true))
            {
                Console.WriteLine("if");
                e.Cancel = true;
                // breaks out of the loop, if there is a loop.
                // break;
            }
            else
            {
                Flickr    flickr = new Flickr("59c64644ddddc2a52a089131c8ca0933", "b080535e26aa05df");
                FoundUser user   = flickr.PeopleFindByUserName("simmisj");
                //FoundUser user = flickr.PeopleFindByUserName("simmisj");

                //PeoplePhotoCollection people = new PeoplePhotoCollection();

                //people = flickr.PeopleGetPhotosOf(user.UserId);

                PhotoSearchOptions options = new PhotoSearchOptions();
                options.UserId  = user.UserId; // Your NSID
                options.PerPage = 4;           // 100 is the default anyway
                PhotoCollection photos;

                try
                {
                    photos      = flickr.PhotosSearch(options);
                    photos.Page = 1;
                }
                catch (Exception ea)
                {
                    //e.Result = "Exception: " + ea;
                    return;
                }

                for (int i = 0; i < photos.Count; i++)
                {
                    // Report progress and pass the picture to the progresschanged method
                    // for the progresschanged method to update the observablecollection.
                    worker.ReportProgress(100, photos[i].Medium640Url);
                    //pictures.Add(photos[i].Medium640Url);

                    // Add the picture to the ObservableCollection.
                    //pictures.Add(photos[i].Medium640Url);
                    //scatterView1.Items.Add(photos[i].ThumbnailUrl);
                }
            }
        }
Exemplo n.º 30
0
        public void PhotosGetInfoCanBlogTest()
        {
            PhotoSearchOptions o = new PhotoSearchOptions();

            o.UserId  = Data.UserId;
            o.PerPage = 5;

            PhotoCollection photos = Instance.PhotosSearch(o);
            PhotoInfo       info   = Instance.PhotosGetInfo(photos[0].PhotoId);

            Assert.AreEqual(false, info.CanBlog);
            Assert.AreEqual(true, info.CanDownload);
        }