samjudson / flickr-net

Home of the FlickrNet API libary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Photo Set property for photos (total count of photos and videos

Fyzel opened this issue · comments

commented

Flickr returns a a count of the total number of photos and videos in a Photo Set. Could you please please add this?

Fyzel@6e4011b#diff-1d4f6c2e8ea1db365eb3282f7c67aeb3

The property "NumberOfPhotos" is actually already this value. Perhaps it could have been named better, but the property returned from Flickr is called "photos" after all.

commented

Not quite. The returned 'photos' attribute is the count of photos and videos.

'count_photos' is the count of photos only. 'count_videos' is the count of only videos

<photoset id="72157660633195178" primary="25928385062" secret="b096cca9fe" server="1478" farm="2" photos="72" videos="2" needs_interstitial="0" visibility_can_see_set="1" count_views="0" count_comments="0" can_comment="1" date_create="1447949294" date_update="1488801826">
      <title>Auto Upload</title>
      <description />
    </photoset>

Here we see the response from Flickr - "photos" is the number of photos, and "videos" is the number of videos. The "count_photos" and "count_videos" are legacy properties that are not returned anymore.

So my code is correct. Their is no "total" value returned.

commented

Incorrect. The flickr-net PhotoSet.cs doesn't implement the returned 'photos' result only 'count_photos' and 'count_videos'.

The change I am asking for is to include the returned 'photos' result.

Whether it is a Photos or TotalPhotosAndVideos is immaterial.

case "photos":
case "count_photos":
      NumberOfPhotos = reader.ReadContentAsInt();
      break;

The above will set NumberOfPhotos if either "photos" or "count_photos" attribute is returned (note, there is not break or return after the first case statement, so both will execute the NumberOfPhotos line).

See the test here:

Assert.IsTrue(set.NumberOfPhotos > 0, "NumberOfPhotos should be greater than zero");

If I'm missing something here and you have an actual example that is not performing correctly then could you perhaps supply an example photoset id (hopefully public) that I can use to reproduce the issue.

commented

If the returned attributes are parsed serially, the value returned for 'photos' would be overridden by 'count_photos'. The NumberOfPhotos property's value would not include the total number of objects contained in the PhotoSet.

In my use of the Flickr API, the 'photos', 'count_photos', and 'count_videos' are all returned.

commented

I will try to find an example when I am back on a computer rather than a mobile device.

Right, ok we have two usages of the Photoset class, with different data returned by Flickr.

flickr.photosets.getList returns "photos" and "videos", but not "count_photos" or "count_videos".
flickr.photosets.getInfo returns "count_photos" and "count_videos", with "photos" being the total of both.

This is really annoying. I'll try and work out how to handle this, but unfortunately its not as easy as it first appears (basically "photos" means something different in each situation).

commented

To test this, you could create a Photo Set with say 5 photos and 5 videos. This would give the following counts:

photos: 10
count_photos: 5
count_videos: 5

commented

Ok. Gotcha. I've been using getInfo. This explains the madness.

commented

Thanks for looking into this.

Yeah, once I realised we were talking about different methods I have a test photoset I can use (72 photos, 2 videos).

I've added a new Total property and updated to logic to cover this slightly weird scenario.