MCPcopy Index your code
hub / github.com/clips/pattern / FlickrResult

Class FlickrResult

pattern/web/__init__.py:2211–2231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2209 return results
2210
2211class FlickrResult(Result):
2212
2213 @property
2214 def url(self):
2215 # Retrieving the url of a FlickrResult (i.e. image location) requires another query.
2216 # Note: the "Original" size no longer appears in the response,
2217 # so Flickr might not like it if we download it.
2218 url = FLICKR + "?method=flickr.photos.getSizes&photo_id=%s&api_key=%s" % (self._id, self._license)
2219 data = URL(url).download(throttle=self._throttle, unicode=True)
2220 data = xml.dom.minidom.parseString(bytestring(data))
2221 size = { TINY: "Thumbnail",
2222 SMALL: "Small",
2223 MEDIUM: "Medium",
2224 LARGE: "Original" }.get(self._size, "Medium")
2225 for x in data.getElementsByTagName("size"):
2226 if size == x.getAttribute("label"):
2227 return x.getAttribute("source")
2228 if size == "Original":
2229 url = x.getAttribute("source")
2230 url = url[:-len(extension(url))-2] + "_o" + extension(url)
2231 return u(url)
2232
2233#images = Flickr().search("kitten", count=10, size=SMALL)
2234#for img in images:

Callers 1

searchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…