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); }
public IEnumerable<FlickrImage> GetImages(string tags) { Flickr.CacheDisabled = true; var flickr = new Flickr("340b341adedd9b2613d5c447c4541e0f"); flickr.InstanceCacheDisabled = true; var options = new PhotoSearchOptions { Tags = tags, PerPage = 2 }; var photos = flickr.PhotosSearch(options); return photos.Select(i => { using (var client = new WebClient()) { var data = client.DownloadData(i.Medium640Url); using (var memoryStream = new MemoryStream(data)) { var bitmap = new Bitmap(memoryStream); return new FlickrImage { Url = i.Medium640Url, Image = new Bitmap(bitmap), Encoded = Convert.ToBase64String(memoryStream.ToArray()) }; } } }); }
private void SearchButton_Click(object sender, RoutedEventArgs e) { Flickr f = FlickrManager.GetAuthInstance(); PhotoSearchOptions options = new PhotoSearchOptions(); options.Tags = SearchTextBox.Text; options.Extras = PhotoSearchExtras.LargeSquareUrl; f.PhotosSearchAsync(options, r => { if (r.Error != null) { Dispatcher.BeginInvoke(() => { MessageBox.Show("An error occurred talking to Flickr: " + r.Error.Message); }); return; } PhotoCollection photos = r.Result; Dispatcher.BeginInvoke(() => { ResultsListBox.ItemsSource = photos; }); }); }
public List<string[]> GetPhotos( string apiKey, string tags ) { FlickrNet.Flickr.CacheDisabled = true; FlickrNet.Flickr flickr = new FlickrNet.Flickr( apiKey ); FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions(); options.Tags = tags; options.Extras = FlickrNet.PhotoSearchExtras.All; options.PerPage = 343; options.Text = tags; options.TagMode = FlickrNet.TagMode.AllTags; List<string[]> photos = new List<string[]>(); foreach ( FlickrNet.Photo photo in flickr.PhotosSearch( options ).PhotoCollection ) { photos.Add( new string[] { photo.MediumUrl, photo.WebUrl, photo.Title, System.Xml.XmlConvert.ToString( photo.DateTaken, System.Xml.XmlDateTimeSerializationMode.Utc ), photo.OwnerName, photo.Latitude.ToString(), photo.Longitude.ToString() } ); // try { photos.Add( new Photo( photo, "{0}" ) ); } // catch { } } return photos; }
public List <string[]> GetPhotos(string apiKey, string tags) { FlickrNet.Flickr.CacheDisabled = true; FlickrNet.Flickr flickr = new FlickrNet.Flickr(apiKey); FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions(); options.Tags = tags; options.Extras = FlickrNet.PhotoSearchExtras.All; options.PerPage = 343; options.Text = tags; options.TagMode = FlickrNet.TagMode.AllTags; List <string[]> photos = new List <string[]>(); foreach (FlickrNet.Photo photo in flickr.PhotosSearch(options).PhotoCollection) { photos.Add(new string[] { photo.MediumUrl, photo.WebUrl, photo.Title, System.Xml.XmlConvert.ToString(photo.DateTaken, System.Xml.XmlDateTimeSerializationMode.Utc), photo.OwnerName, photo.Latitude.ToString(), photo.Longitude.ToString() }); // try { photos.Add( new Photo( photo, "{0}" ) ); } // catch { } } return(photos); }
public void PhotosGeoPhotosForLocationBasicTest() { var o = new PhotoSearchOptions { UserId = Data.UserId, HasGeo = true, PerPage = 1, Extras = PhotoSearchExtras.Geo }; var photos = AuthInstance.PhotosSearch(o); var photo = photos[0]; var photos2 = AuthInstance.PhotosGeoPhotosForLocation(photo.Latitude, photo.Longitude, photo.Accuracy, PhotoSearchExtras.All, 0, 0); Assert.IsNotNull(photos2, "PhotosGeoPhotosForLocation should not return null."); Assert.IsTrue(photos2.Count > 0, "Should return one or more photos."); foreach (var p in photos2) { Assert.IsNotNull(p.PhotoId); Assert.AreNotEqual(0, p.Longitude); Assert.AreNotEqual(0, p.Latitude); } }
public void Evaluate(int spreadMax) { FChanged = false; if (FUserIdInput.IsChanged || FTagsInput.IsChanged || FTagsInput.IsChanged || FPerPageInput.IsChanged) { FPhotoSearchOptions.Clear(); for (int i = 0; i < spreadMax; i++) { PhotoSearchOptions options = new PhotoSearchOptions(); string userId = FUserIdInput[i]; if(!string.IsNullOrEmpty(userId)) options.UserId = userId; if(!string.IsNullOrEmpty(FTagsInput[i])) { options.Tags = FTagsInput[i]; } options.PerPage = FPerPageInput[i]; options.TagMode = FTagModeInput[i]; FPhotoSearchOptions.Add(options); } FChanged = true; } FPhotoSearchOptionsOutput.AssignFrom(FPhotoSearchOptions); FOptionsChangedOutput[0] = FChanged; }
public void ShowPic() { if (CheckNetwork() == true) { MessageBox.Show("A network connection can not be established.\r\nPlease press refresh or check your network settings."); return; } else { picList.ItemsSource = ""; try { //to use Flickr go to Project-> Manage NuGet Packages-> Search "Flickr" -> install for windows phone 7 Flickr flickr = new Flickr("9a03824af501c318fec232146c6b1d05", "cd5cbd132cfbc60c"); // Authorise by api key and secret PhotoSearchOptions options = new PhotoSearchOptions(); options.Tags = App.selectedCountryDetails.CountryCapital.ToString(); //give a key word to search flickr.PhotosSearchAsync(options, (pictures) => { picList.Dispatcher.BeginInvoke(new Action(delegate() { picList.ItemsSource = pictures.Result; //binding source to listbox })); }); } catch (Exception e) { MessageBox.Show("An error occured. Please exit app and try again.\r\nError Details: " + e.Message.ToString()); } } }
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"); }
public void ExcessiveTagsShouldNotThrowUriFormatException() { var list = Enumerable.Range(1, 9000).Select(i => "reallybigtag" + i).ToList(); var options = new PhotoSearchOptions{ Tags = string.Join(",", list) }; var photos = Instance.PhotosSearch(options); }
public void PhotosSearchAuthRussianCharacters() { PhotoSearchOptions o = new PhotoSearchOptions(); o.Tags = "снег"; var photos = AuthInstance.PhotosSearch(o); Assert.AreNotEqual(0, photos.Count, "Search should return some results."); }
public IList<PictureInfo> ListPictures(string SearchString, string EventTag) { var retVal = new List<PictureInfo>(); PhotoSearchOptions options = new PhotoSearchOptions() { Tags = SearchString, TagMode= TagMode.AllTags, SortOrder = PhotoSearchSortOrder.Relevance, Extras = PhotoSearchExtras.Tags }; retVal = (from a in _flickr.PhotosSearch(options) where a.Tags.Contains(EventTag) select new PictureInfo() { ID = a.PhotoId, FullSizeURL = a.MediumUrl.RemoveProtocol(), ThumbnailURL = a.ThumbnailUrl.RemoveProtocol(), Title = a.Title, URL = a.WebUrl.RemoveProtocol(), MediumURL = a.MediumUrl.RemoveProtocol() }).ToList(); return retVal; }
private void FindUserButton_Click(object sender, EventArgs e) { // First page of the users photos // Sorted by interestingness Flickr flickr = new Flickr(ApiKey.Text); FoundUser user; try { user = flickr.PeopleFindByUserName(Username.Text); OutputTextbox.Text = "User Id = " + user.UserId + "\r\n" + "Username = "******"\r\n"; } catch (FlickrException ex) { OutputTextbox.Text = ex.Message; return; } PhotoSearchOptions userSearch = new PhotoSearchOptions(); userSearch.UserId = user.UserId; userSearch.SortOrder = PhotoSearchSortOrder.InterestingnessDescending; PhotoCollection usersPhotos = flickr.PhotosSearch(userSearch); // Get users contacts ContactCollection contacts = flickr.ContactsGetPublicList(user.UserId); // Get first page of a users favorites PhotoCollection usersFavoritePhotos = flickr.FavoritesGetPublicList(user.UserId); // Get a list of the users groups //PublicGroupInfoCollection usersGroups = flickr.PeopleGetPublicGroups(user.UserId); int i = 0; foreach (Contact contact in contacts) { OutputTextbox.Text += "Contact " + contact.UserName + "\r\n"; if (i++ > 10) break; // only list the first 10 } i = 0; //foreach (PublicGroupInfo group in usersGroups) //{ // OutputTextbox.Text += "Group " + group.GroupName + "\r\n"; // if (i++ > 10) break; // only list the first 10 //} i = 0; foreach (Photo photo in usersPhotos) { OutputTextbox.Text += "Interesting photo title is " + photo.Title + " " + photo.WebUrl + "\r\n"; if (i++ > 10) break; // only list the first 10 } i = 0; foreach (Photo photo in usersFavoritePhotos) { OutputTextbox.Text += "Favourite photo title is " + photo.Title + " " + photo.WebUrl + "\r\n"; if (i++ > 10) break; // only list the first 10 } }
public IEnumerable<Image> GetImages(string tags) { // Well yeah, this should probably be somewhere else ;) var options = new PhotoSearchOptions("61283045@N03", tags); var photos = new Flickr("abc92b454fb23ccc2e4615df6cf780fa").PhotosSearch(options); return photos .Select(p => new Image(p.Small320Url, p.Medium640Url, p.Title)) .OrderBy(r => r.Title); }
public void GetPhoto() { Auth auth = flickr.AuthCheckToken(AuthToken); PhotoSearchOptions options = new PhotoSearchOptions(); options.UserId = "1234567@N01"; // Your NSID options.PerPage = 100; // 100 is the default anyway FlickrNet.PhotoCollection photos = flickr.PhotosSearch(options); doBackup(photos); }
/// <summary> /// Search for a set of photos, based on the value of the <see cref="PhotoSearchOptions"/> parameters. /// </summary> /// <param name="options">The parameters to search for.</param> /// <returns>A collection of photos contained within a <see cref="PhotoCollection"/> object.</returns> public PhotoCollection PhotosSearch(PhotoSearchOptions options) { var parameters = new Dictionary <string, string>(); parameters.Add("method", "flickr.photos.search"); options.AddToDictionary(parameters); return(GetResponseCache <PhotoCollection>(parameters)); }
internal PartialSearchOptions(PhotoSearchOptions options) { Extras = options.Extras; MaxTakenDate = options.MaxTakenDate; MinTakenDate = options.MinTakenDate; MaxUploadDate = options.MaxUploadDate; MinUploadDate = options.MinUploadDate; Page = options.Page; PerPage = options.PerPage; PrivacyFilter = options.PrivacyFilter; }
public PhotoCollection GetPhotoCollectionByName(string name) { FoundUser user = Flickr.PeopleFindByUserName(name); FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions(); options.UserId = user.UserId; options.PerPage = 20; options.Page = 1; return(Flickr.PhotosSearch(options)); }
private void search_Click(object sender, EventArgs e) { string str = text.Text; if (str != "") { PhotoSearchOptions opt = new PhotoSearchOptions(null, null, FlickrNet.TagMode.AnyTag, str); result = flickr.PhotosSearch(opt); this.DialogResult = System.Windows.Forms.DialogResult.OK; name = str; } }
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); }
private PhotoSearchOptions GetPhotoSearchOptions() { PhotoSearchOptions options = new PhotoSearchOptions(); options.PerPage = 12; options.SortOrder = PhotoSearchSortOrder.DatePostedDescending; options.MediaType = MediaType.Photos; options.Extras = PhotoSearchExtras.All; options.UserId = userID; return options; }
internal PartialSearchOptions(PhotoSearchOptions options) { this.Extras = options.Extras; this.MaxTakenDate = options.MaxTakenDate; this.MinTakenDate = options.MinTakenDate; this.MaxUploadDate = options.MaxUploadDate; this.MinUploadDate = options.MinUploadDate; this.Page = options.Page; this.PerPage = options.PerPage; this.PrivacyFilter = options.PrivacyFilter; }
public void PhotoSearchExtrasViews() { var o = new PhotoSearchOptions {Tags = "kittens", Extras = PhotoSearchExtras.Views}; var photos = Instance.PhotosSearch(o); foreach (var photo in photos) { Assert.IsTrue(photo.Views.HasValue); } }
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); }
public void PhotosSearchAsyncBasicTest() { var o = new PhotoSearchOptions(); o.Tags = "microsoft"; var w = new AsyncSubject<FlickrResult<PhotoCollection>>(); Instance.PhotosSearchAsync(o, r => { w.OnNext(r); w.OnCompleted(); }); var result = w.Next().First(); Assert.IsTrue(result.Result.Total > 0); }
public void PhotoSearchOptionsCalculateSlideshowUrlBasicTest() { var o = new PhotoSearchOptions {Text = "kittens", InGallery = true}; var url = o.CalculateSlideshowUrl(); Assert.IsNotNull(url); const string expected = "https://www.flickr.com/show.gne?api_method=flickr.photos.search&method_params=text|kittens;in_gallery|1"; Assert.AreEqual(expected, url); }
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); }
public void PhotosSearchDateTakenGranualityTest() { PhotoSearchOptions o = new PhotoSearchOptions { UserId = "8748614@N05", Tags = "primavera", PerPage = 500, Extras = PhotoSearchExtras.DateTaken }; Instance.PhotosSearch(o); }
public PartialViewResult FlickrImg(string text) { if (string.IsNullOrWhiteSpace(text)) { return this.PartialView("_flickrPartial", new List<string>()); } var options = new PhotoSearchOptions { Text = text, PerPage = 10, TagMode = TagMode.AllTags }; var photos = this.flickr.PhotosSearch(options); return this.PartialView("_flickrPartial", photos.Select(photo => photo.Small320Url).ToList()); }
public void PhotosSearchBasicSearch() { var o = new PhotoSearchOptions {Tags = "Test"}; var photos = Instance.PhotosSearch(o); Assert.IsTrue(photos.Total > 0, "Total Photos should be greater than zero."); Assert.IsTrue(photos.Pages > 0, "Pages should be greaters than zero."); Assert.AreEqual(100, photos.PerPage, "PhotosPerPage should be 100."); Assert.AreEqual(1, photos.Page, "Page should be 1."); Assert.IsTrue(photos.Count > 0, "Photos.Count should be greater than 0."); Assert.AreEqual(photos.PerPage, photos.Count); }
public async void SearchForTagShouldReturnResults() { var o = new PhotoSearchOptions {Tags = "colorful", Extras = PhotoSearchExtras.All}; var result = await Instance.PhotosSearchAsync(o); Assert.NotNull(result); Assert.AreNotEqual(0, result.Count); foreach(var photo in result) { Console.WriteLine("Photo {0}, {1}, {2}", photo.PhotoId, photo.Title, photo.DateTaken); } }
public void CountFavesAndCountComments() { var options = new PhotoSearchOptions { Extras = PhotoSearchExtras.CountFaves | PhotoSearchExtras.CountComments, Tags = "colorful" }; var photos = Instance.PhotosSearch(options); Assert.IsFalse(photos.Any(p => p.CountFaves == null), "Should not have any null CountFaves"); Assert.IsFalse(photos.Any(p => p.CountComments == null), "Should not have any null CountComments"); }
public void PhotosSearchAuthRussianCharacters() { Flickr f = TestData.GetAuthInstance(); PhotoSearchOptions o = new PhotoSearchOptions(); o.Tags = "снег"; var photos = f.PhotosSearch(o); Console.WriteLine(f.LastRequest); Assert.AreNotEqual(0, photos.Count, "Search should return some results."); }
public void PhotoSearchExtrasViews() { PhotoSearchOptions o = new PhotoSearchOptions(); o.Tags = "kittens"; o.Extras = PhotoSearchExtras.Views; var photos = TestData.GetInstance().PhotosSearch(o); foreach (var photo in photos) { Assert.IsTrue(photo.Views.HasValue); } }
private void BGDownloadAllPhotos(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; PhotoList = new SortableBindingList <Photo>(); worker.ReportProgress(0, "Searching all photos"); FlickrNet.Flickr f = FlickrManager.GetFlickrAuthInstance(); if (f == null) { BGErrorMessage = "You must authenticate before you can download data from Flickr."; return; } try { FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions(); options.Extras = SearchExtras; options.SortOrder = FlickrNet.PhotoSearchSortOrder.DateTakenAscending; if (Settings.FilterByDate) { options.MinTakenDate = Settings.StartDate.Date; options.MaxTakenDate = Settings.StopDate.Date + new TimeSpan(23, 59, 59); } options.UserId = SearchAccountUser.UserId; options.Page = 1; options.PerPage = 500; FlickrNet.PhotoCollection photoCollection; do { if (worker.CancellationPending) // See if cancel button was pressed. { return; } photoCollection = f.PhotosSearch(options); if (photoCollection.Total > 3999) { BGErrorMessage = $"Too many photos: {photoCollection.Total}"; return; } foreach (FlickrNet.Photo flickrPhoto in photoCollection) { AddPhotoToList(f, flickrPhoto, null); } // Calculate percent complete based on how many pages we have completed. int percent = (options.Page * 100 / photoCollection.Pages); worker.ReportProgress(percent, "Searching all photos"); options.Page = photoCollection.Page + 1; }while (options.Page <= photoCollection.Pages); } catch (FlickrNet.FlickrException ex) { BGErrorMessage = "Download failed. Error: " + ex.Message; return; } DownloadFiles(worker, e); }
public PhotoCollection PhotosGetWithGeoData(PhotoSearchOptions options) { PartialSearchOptions newOptions = new PartialSearchOptions(options); return(PhotosGetWithGeoData(newOptions)); }