-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
I'm trying to use this in a webapp I'm building, but I keep getting this "Cannot find Asset" error when searching for photos.
I think this url is backwards per unsplash API docs
python-unsplash/unsplash/photo.py
Line 107 in f15d1c8
url = "/photos/search" |
I think a fix would be to update the function as so
def search(self, query, category=None, orientation=None, page=1, per_page=10):
"""
Get a single page from a photo search.
Optionally limit your search to a set of categories by supplying the category ID’s.
Note: If supplying multiple category ID’s,
the resulting photos will be those that match all of the given categories,
not ones that match any category.
:param query [string]: Search terms.
:param category [string]: Category ID(‘s) to filter search. If multiple, comma-separated. (deprecated)
:param orientation [string]: Filter search results by photo orientation.
Valid values are landscape, portrait, and squarish.
:param page [integer]: Page number to retrieve. (Optional; default: 1)
:param per_page [integer]: Number of items per page. (Optional; default: 10)
:return: [Array]: A single page of the curated Photo list.
:raise UnsplashError: If the given orientation is not in the default orientation values.
"""
if orientation and orientation not in self.orientation_values:
raise Exception()
params = {
"query": query,
"category": category,
"orientation": orientation,
"page": page,
"per_page": per_page
}
url = "/search/photos" # update the URL
_result = self._get(url, params=params)
result = _result.get("results", []) # returns a dict, so key into what the function would have been expecting
return PhotoModel.parse_list(result)
Metadata
Metadata
Assignees
Labels
No labels