public PhotosetsGetPhotos ( string photosetId ) : Photo[] | ||
photosetId | string | The ID of the photoset to return photos for. |
return | Photo[] |
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; }
public static PhotosetPhotoCollection GetPagedSet(string setId, int maximumRows, int startRowIndex) { Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"], ConfigurationManager.AppSettings["sharedSecret"]); PhotosetPhotoCollection photos = flickr.PhotosetsGetPhotos(setId, GetPageIndex( startRowIndex, maximumRows) + 1, maximumRows); return photos; }
private PhotosetPhotoCollection GetPhotosetPhotos(string photosetID, Flickr flickr, int page, int perPage) { PhotosetPhotoCollection photos = new PhotosetPhotoCollection(); PhotoSearchOptions options = GetPhotoSearchOptions(); Flickr.CacheDisabled = true; photos = flickr.PhotosetsGetPhotos(photosetID, page, perPage); return photos; }
/// <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); } }
public Result <GetPhotosFromPhotoset> GetPhotoset(string photosetId) { var photoset = _flickr.PhotosetsGetPhotos(photosetId, PhotoSearchExtras.All, PrivacyFilter.None, 1, 50); return(Result <GetPhotosFromPhotoset> .Of(new GetPhotosFromPhotoset { Id = photoset.PhotosetId, Title = photoset.Title, Total = photoset.Total, PerPage = photoset.PerPage, Photos = photoset.ConvertAll(x => new GetPhotosFromPhotoset.Photo { Id = x.PhotoId, Title = x.Title, TakenAt = x.DateTaken, Latitude = x.Latitude, Longitude = x.Longitude }) })); }
public IEnumerable <DiscoveredFile> Discover(string path, HashSet <string> existingSources) { string photosetId = path.Replace("/", ""); int page = 1; int maxPages = 1; while (page <= maxPages) { // existing sources gives us a list of photoset ids PagedPhotoCollection photos; try { if (photosetId == "") { photos = _flickr.PhotosGetNotInSet(page, 100, PhotoSearchExtras.OriginalUrl | PhotoSearchExtras.Media | PhotoSearchExtras.LargeUrl); } else { photos = _flickr.PhotosetsGetPhotos(photosetId, PhotoSearchExtras.OriginalUrl | PhotoSearchExtras.Media | PhotoSearchExtras.LargeUrl, page, 100); } maxPages = photos.Pages; page++; } catch { photos = new PhotoCollection(); } foreach (var photo in photos) { if (!existingSources.Contains(path + photo.PhotoId)) { if (photo.MediaStatus == "failed") { continue; } string url = photo.OriginalUrl; if (url == null) { url = photo.LargeUrl; } if (url == null) { url = photo.MediumUrl; } string extension = System.IO.Path.GetExtension(url); if (photo.Media == "video") { url = $"http://www.flickr.com/video_download.gne?id={photo.PhotoId}"; try { if (!photo.IsPublic) { _flickr.PhotosSetPerms(photo.PhotoId, true, photo.IsFriend, photo.IsFamily, PermissionComment.Nobody, PermissionAddMeta.Owner); } string fileName = GetHeaderFileName(url); extension = System.IO.Path.GetExtension(fileName); if (!photo.IsPublic) { _flickr.PhotosSetPerms(photo.PhotoId, photo.IsPublic, photo.IsFriend, photo.IsFamily, PermissionComment.Nobody, PermissionAddMeta.Owner); } } catch (Exception ex) { } } yield return (new DiscoveredFile { Name = photo.Title, Path = path + photo.PhotoId, Extension = extension, Url = url }); } } } }
private void SimpleSearchButton1_Click(object sender, EventArgs e) { OutputTextbox.Text = ""; // Example 1 //string apikey = ApiKey.Text; string apikey ="deaba23a63d9b3c34b63f1a04548a3f4"; Flickr flickr = new Flickr(apikey); // Example 2 PhotoSearchOptions searchOptions = new PhotoSearchOptions(); searchOptions.UserId = "70831453@N00"; //searchOptions.Tags = "kanas"; searchOptions.PerPage = 500; PhotoCollection microsoftPhotos = flickr.PhotosSearch(searchOptions); PhotosetPhotoCollection myset = flickr.PhotosetsGetPhotos("72157636689533194"); //PhotoCollection myset = flickr.PhotosSearch(searchOptions); //Photoset myset = flickr.PhotosetsGetInfo("72157594398087814"); // Example 3 //searchOptions.Page = 2; //PhotoCollection microsoftPhotos2 = flickr.PhotosSearch(searchOptions); //searchOptions.Page = 3; //PhotoCollection microsoftPhotos3 = flickr.PhotosSearch(searchOptions); // Eample 4 List<Photo> allPhotos = new List<Photo>(); allPhotos.AddRange(myset); //allPhotos.AddRange(microsoftPhotos2); //allPhotos.AddRange(microsoftPhotos3); WebClient webClient = new WebClient(); String s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); foreach (Photo photo in allPhotos) { OutputTextbox.Text += "Photos title is " + photo.Title + " " + photo.ThumbnailUrl+ "\r\n"; if (photo.DoesLargeExist){ webClient.DownloadFile(photo.LargeUrl, s + @"\ssr\" + photo.PhotoId +searchOptions.Tags+ @".jpg"); } else if(photo.DoesMediumExist){ webClient.DownloadFile(photo.MediumUrl, s+@"\ssr\"+photo.PhotoId+searchOptions.Tags+@".jpg"); } //else if (photo.OriginalUrl) //{ //webClient.DownloadFile(photo.MediumUrl, s + @"\temp\" + photo.PhotoId + searchOptions.Tags + @".jpg"); //} else { webClient.DownloadFile(photo.Medium640Url , s + @"\ssr\" + photo.PhotoId + searchOptions.Tags+@".jpg"); } } }
// Background worker task to search selected photosets. private void BGDownloadPhotosets(object sender, DoWorkEventArgs e) { BackgroundWorker worker = (BackgroundWorker)sender; worker.ReportProgress(0, "Connecting"); PhotoList = new SortableBindingList <Photo>(); // Count the number of enabled photosets, so we can do an estimate of percent complete; int enabledPhotosets = 0; foreach (Photoset photoset in PhotosetList) { if (photoset.EnableSearch) { enabledPhotosets++; } } if (enabledPhotosets == 0) { // No photosets are enabled. We are done. return; } try { int indexPhotoset = 0; FlickrNet.Flickr f = FlickrManager.GetFlickrAuthInstance(); if (f == null) { BGErrorMessage = "You must authenticate before you can download data from Flickr."; return; } // Iterate over the photosets and get the photos from each set. FlickrNet.PhotosetPhotoCollection photoCollection = new FlickrNet.PhotosetPhotoCollection(); foreach (Photoset photoset in PhotosetList) { if (worker.CancellationPending) { e.Cancel = true; return; } if (photoset.EnableSearch) { int percent = indexPhotoset * 100 / enabledPhotosets; string description = "Searching Album " + photoset.Title; worker.ReportProgress(percent, description); int page = 1; int perpage = 500; do { if (worker.CancellationPending) // See if cancel button was pressed. { e.Cancel = true; return; } photoCollection = f.PhotosetsGetPhotos(photoset.PhotosetId, SearchExtras, page, perpage); #if false // It is not clear from the documentation whether the limit of 4000 photos per search applies // to album searches. If an album has more than 4000 photos, is the result of GetPhotos // accurate? I'm going to assume for now that it is. If not, you can enable this code. if (photoCollection.Total > 3999) { BGErrorMessage = $"Too many photos: {photoCollection.Total}"; return; } #endif foreach (FlickrNet.Photo flickrPhoto in photoCollection) { AddPhotoToList(f, flickrPhoto, photoset); } // Calculate percent complete based on both how many photo sets we have completed, // plus how many pages we have read percent = (indexPhotoset * 100 + page * 100 / photoCollection.Pages) / enabledPhotosets; worker.ReportProgress(percent, description); page = photoCollection.Page + 1; }while (page <= photoCollection.Pages); indexPhotoset++; } } } catch (FlickrNet.FlickrException ex) { BGErrorMessage = "Search failed. Error: " + ex.Message; return; } DownloadFiles(sender, e); }