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$
9
  • 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$ Commented Sep 12, 2019 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$ Commented Sep 20, 2019 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$ Commented Sep 20, 2019 at 21:29
  • 1
    $\begingroup$ @b3m2a1 Thanks, but PacletFind["ServiceConnect_Flickr"] gives {}, is there a link to your tutorial? $\endgroup$ Commented Sep 20, 2019 at 21:35
  • 1
    $\begingroup$ @b3m2a1 Would you be able to point me to your tutorial? $\endgroup$ Commented Sep 23, 2019 at 19:12

1 Answer 1

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$
1
  • $\begingroup$ @b3m2a1 PacletUpdate is now obsolete, and this stopped working in v12.1... any ideas? $\endgroup$ Commented May 26, 2020 at 1:28

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.