1
$\begingroup$

The Flickr service API doesn’t seem to have the getfavorites() request implemented. Is there an good way to do this with WebExecute?

Code to get started with:

For a given user, say 7944912@N05, there are n pages for which one can manually extract images:

s = StartWebSession[];

WebExecute[s, 
 "OpenPage" -> 
  "https://www.flickr.com/photos/7944912@N05/favorites/page1/"]

possibleimageurls = WebExecute[s, "PageHyperlinks"];
Length@possibleimageurls

i = Import@
   "https://live.staticflickr.com/4278/34611590423_5f44dc95d2_k.jpg";
{Thumbnail@i, ImageDimensions[i]}

enter image description here

But I don't know how to enumerate the highest resolution ones.

$\endgroup$
  • 2
    $\begingroup$ Easier is probably to patch the ServiceConnect paclet to add the request. That on its own isn't too hard. Just find the paclet with PacletFind and figure out where they implement all their requests. $\endgroup$ – b3m2a1 Sep 12 at 4:58
  • 1
    $\begingroup$ Open the paclet with PacletFind["ServiceConnect_Flickr"]["Location"]. There’ll be a Kernel folder. Inside that there should be like Flickr.m or something. That’s where all the API requests are implemented. $\endgroup$ – b3m2a1 Sep 20 at 21:29
  • 2
    $\begingroup$ I wrote up a Q/A about how to work with service connect packets here a few years back $\endgroup$ – b3m2a1 Sep 20 at 21:29
  • 1
    $\begingroup$ @b3m2a1 Thanks, but PacletFind["ServiceConnect_Flickr"] gives {}, is there a link to your tutorial? $\endgroup$ – M.R. Sep 20 at 21:35
  • 1
    $\begingroup$ @b3m2a1 Would you be able to point me to your tutorial? $\endgroup$ – M.R. Sep 23 at 19:12
1
$\begingroup$

This is not a full answer

As @b3m2a1 suggested, I looked into the paclet and tried updating the functions:

p = PacletFind["Service*_*Fl*"]
p[[1]]["Location"]

enter image description here

Which looks like this:

enter image description here

Then I added this to Flickr.m:

 flickrdata["RawFaves"] := {
    "URL"                -> "https://api.flickr.com/services/rest?method=flickr.favorites.getlist",
    "HTTPSMethod"        -> "GET",
    "Parameters"        -> {"user_id","tags","tag_mode","text","min_upload_date","max_upload_date",
                            "min_taken_date","max_taken_date","license","sort","privacy_filter","bbox",
                            "accuracy","safe_search","content_type","machine_tags","machine_tag_mode",
                            "group_id","contacts","woe_id","place_id","media","has_geo","geo_context",
                            "lat","lon","radius","radius_units","is_commons","in_gallery","is_getty",
                            "extras","per_page","page","format","nojsoncallback","jsoncallback"},
    "RequiredParameters"-> {},
    "ReturnContentData" -> True,
    "ResultsFunction"    -> flickrimport
}

Then I restarted the kernel, configure the connection again (which there was a way to save between restarts):

PacletUpdate[p[[1]]]
f = ServiceConnect["Flickr"]

and tried it out:

results = 
 f["RawFaves", "user_id" -> "97408942@N04", "per_page" -> "2", 
  "page" -> "1", "format" -> "json", "nojsoncallback" -> "1"]

enter image description here

Q: How do I get it to return the original sized images?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.