[flickr] add 'profile' option
This commit is contained in:
@@ -48,6 +48,8 @@ class FlickrExtractor(Extractor):
|
||||
def metadata(self):
|
||||
"""Return general metadata"""
|
||||
self.user = self.api.urls_lookupUser(self.item_id)
|
||||
if self.config("profile", False):
|
||||
self.user.update(self.api.people_getInfo(self.user["nsid"]))
|
||||
return {"user": self.user}
|
||||
|
||||
def photos(self):
|
||||
@@ -87,7 +89,11 @@ class FlickrImageExtractor(FlickrExtractor):
|
||||
else:
|
||||
self.api._extract_photo(photo)
|
||||
|
||||
photo["user"] = photo["owner"]
|
||||
if self.config("profile", False):
|
||||
photo["user"] = self.api.people_getInfo(photo["owner"]["nsid"])
|
||||
else:
|
||||
photo["user"] = photo["owner"]
|
||||
|
||||
photo["title"] = photo["title"]["_content"]
|
||||
photo["comments"] = text.parse_int(photo["comments"]["_content"])
|
||||
photo["description"] = photo["description"]["_content"]
|
||||
@@ -322,6 +328,26 @@ class FlickrAPI(oauth.OAuth1API):
|
||||
params = {"group_id": group_id}
|
||||
return self._pagination("groups.pools.getPhotos", params)
|
||||
|
||||
def people_getInfo(self, user_id):
|
||||
"""Get information about a user."""
|
||||
params = {"user_id": user_id}
|
||||
user = self._call("people.getInfo", params)
|
||||
|
||||
try:
|
||||
user = user["person"]
|
||||
for key in ("description", "username", "realname", "location",
|
||||
"profileurl", "photosurl", "mobileurl"):
|
||||
if isinstance(user.get(key), dict):
|
||||
user[key] = user[key]["_content"]
|
||||
photos = user["photos"]
|
||||
for key in ("count", "firstdate", "firstdatetaken"):
|
||||
if isinstance(photos.get(key), dict):
|
||||
photos[key] = photos[key]["_content"]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return user
|
||||
|
||||
def people_getPhotos(self, user_id):
|
||||
"""Return photos from the given user's photostream."""
|
||||
params = {"user_id": user_id}
|
||||
|
||||
Reference in New Issue
Block a user