How to get at Creative Commons, etc., info for photo

Topics: Developer Forum
Apr 5, 2009 at 2:08 AM
For a given photo, how can I determine if it has been marked as Creative Commons or is All rights reserved, etc.?  The various License and Permissions properties I can find are always null or 0, if these are even relevant to this.
Coordinator
Apr 6, 2009 at 11:03 AM
You need to call the PhotoGetInfo call, or alternatively ask for the license information to be returned from a search call (by setting the PhotosSearchOption.Extras property to include PhotoSearchExtras.License flag).

PhotoSearchOptions o = new PhotoSearchOptions;
o.Extras |= PhotoSearchExtras.License

Hope that helps.
Apr 6, 2009 at 7:12 PM
Edited Apr 6, 2009 at 7:23 PM
Thanks!  FYI, when I try search for "PhotoGetInfo" in Documentation.chm, it comes up dry.

Never mind - it's PhotosGetInfo.
Apr 6, 2009 at 8:47 PM
As you may have gathered I am currently I am trying to implement "download Creative Commons only" functionality in my app.  I have noticed that Flickr.PhotoInfo.License is an int that appears to be 0 when the photo is "All rights reserved" (no permissions) and is 1 when, at least in one case, a photo allows "noncommercial, Share alike" permissions (there is a third tiny symbol on the Flickr page that doesn't seem to match any of the larger CC symbols listed on another page).  It appears that 1 is an index into FlickrNet.Licenses.LicenseCollection with the LicenseName of "Attribution-NonCommercial-ShareAlike License".

Given all of the different licenses in the list, should merely checking this value for non-0 be sufficient for determining if a photo is considered CC, as far as Flickr is concerned?

There is a FlickrNet.Photo.License property, but it is a String, and always appears to be null, even when PhotosGetInfo.License is 1 for the same photo.  What is this property used for - a string the photo owner can set?
Coordinator
Apr 9, 2009 at 1:53 PM
Edited Apr 9, 2009 at 1:55 PM
The following code works fine for me, returning the license number either from the PhotosSearch method, or from the PhotoGetInfo method:

            Flickr f = new Flickr(APIKey);
            PhotoSearchOptions o = new PhotoSearchOptions();
            o.AddLicense(LicenseType.AttributionCC);
            o.AddLicense(LicenseType.AttributionShareAlikeCC);
            o.Tags = "colorful";
            o.Extras |= PhotoSearchExtras.License;
            o.PerPage = 10;

            Photos ps = f.PhotosSearch(o);
            foreach (Photo p in ps.PhotoCollection)
            {
                Console.WriteLine("Photo '{0}' has License {1}", p.Title, p.License);

                PhotoInfo pi = f.PhotosGetInfo(p.PhotoId);
                Console.WriteLine("Photo '{0}' has License {1}", p.Title, pi.License);
            }

I have added the new enum called LicenseType which will be in the next version of the library, but you can use the numbers available on the Flickr API web site:


http://www.flickr.com/services/api/flickr.photos.licenses.getInfo.htm