Giter VIP home page Giter VIP logo

pyunsplash's People

Contributors

maximilianventura avatar oboratav avatar salvopr avatar salvoventura avatar scarbajali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyunsplash's Issues

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

import logging
from pyunsplash import PyUnsplash

api_key = 'MY_APP_ACCESS_KEY'
pu = PyUnsplash(api_key=api_key)
logging.getLogger("pyunsplash").setLevel(logging.DEBUG)

search = pu.search(type_='photos', query='red,car')
for photo in search.entries:
    print(photo.id, photo.link_download)

Traceback (most recent call last):
File "unsplash_download.py", line 24, in
search = pu.search(type_='photos', query='red,car')
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyunsplash/pyunsplash.py", line 58, in search
return Search(api_key=self.api_key, where=type, **kwargs)
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyunsplash/src/search.py", line 29, in init
super(Search, self).init(url=url, api_key=api_key, valid_options=valid_options, **kwargs)
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyunsplash/src/unpage.py", line 47, in init
r = self._agent.get(self.url, self.query_parameters)
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pyunsplash/src/rest.py", line 84, in get
self._body = _r.json()
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/site-packages/requests/models.py", line 858, in json
self.content.decode(encoding), **kwargs
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Users/appion/.pyenv/versions/3.7.0/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Return urls of photo

Hello !

First of all, nice projet, I use your library for one of my personal projet, easy to setup and use, so thanks a lot for that !

Was just wondering, for User.photos() can you add the "urls" property in return ?

photo.link_download is not really usefull, it's simply https://unsplash.com/photos/{id} + '/download' which can be done quite easy without having to return a property.

However, returning the "urls" will be way more interesting because it will allow us the opportunity to literally download the picture and save them locally if necessary.

Thanks in advance :D

Make `photos` an attribute of `collection`

Evaluate whether having photos as a property of collection is viable, and makes sense.
This would allow to rewrite the example code loop as:

collections = py_un.collections(per_page=30)
while collections.has_next:
    for collection in collections.entries:
        for photo in collection.photos.entries:
            print collection.title, photo.link_download
    # no need to specify per_page: will take from original object
    collections = collections.get_next_page()

No attribute as 'entries'

while collections.has_next:
    for collection in collections.entries:
        photos = collection.photos
        for photo in photos.entries:
            print(collection.title, photo.link_download)
# no need to specify per_page: will take from original object
collections = collections.get_next_page()

Traceback (most recent call last):
File "<ipython-input-19-97290a89529d>", line 4, in <module>
for photo in photos.entries:

AttributeError: 'function' object has no attribute 'entries'

Get raw URL and author info independently

Hi,

Thanks a lot for this library. It would be nice to also support the retrieval of photos' raw URLs and author info as properties. (photo.url_raw and photo.author_info).

Regards,

Curated photos, curated collections, featured collections, and photo stats are EOL

Search class: Param "type" is "type_"

Hey there! Nice Wrapper!

Is there a possible issue with the search class.

See following error:
search = py_un.search(type='photos', query='red')
TypeError: search() missing 1 required positional argument: 'type_'

Per your documentation/examples it says to use param "type" however, using "type_" works correctly, a possible typo?

Provide property for `download_location` in PyUnsplasy.Photo class.

At this time, the PyUnsplash.photo class directly exposes link_download which maps to a different property, in particular photo.links.download. I can add the additional class property.

However, you can still work around this by something like:

import pyunsplash
pu = pyunsplash.PyUnsplash(api_key='<your Unsplash API key>')
photos = pu.photos(type='random', per_page=15)
for photo in photos.entries:
    print photo.links.get('download_location', None)

Originally posted by @salvoventura in #3 (comment)

Help parsing RandomPhotos.

Hey there!

I need some help parsing a random photos object. I am unsure how to parse the object.

The following code I have tried:

py_un = PyUnsplash(api_key="**")
resp = py_un.photos(type_="random", per_page=4, order_by="popular")
for num, item in enumerate(resp.entries):
    print(item)

I have tried looking at the object using however, I cannot access the body or entries.

dir(resp)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_agent', '_api_root', '_parse_navigation', '_ret_link', '_sanitized_query_parameters', '_sanitized_url', 'api_key', 'body', 'delete','entries', 'get', 'get_first_page', 'get_last_page', 'get_next_page', 'get_previous_page', 'has_next', 'has_previous', 'header', 'link_first', 'link_last', 'link_next', 'link_previous', 'link_self', 'navigation', 'post', 'put', 'query_parameters', 'requests', 'set_api_key', 'status_code', 'url', 'valid_options']

Could you please tell me what I am doing wrong?
Many Thanks.

search.get_next_page() does not work

This code fails to work, am I doing something wrong? This is the minimum code that triggers the issue. I'm trying to get next page in search results.

from pyunsplash import PyUnsplash
pu = PyUnsplash(api_key="api_key")
search = pu.search(type_="photos", query="bear")
if search.has_next:
    search.get_next_page()
TypeError                                 Traceback (most recent call last)

<ipython-input-16-b0e2b3485380> in <module>()
      2 search = pu.search(type_="photos", query="bear")
      3 if search.has_next:
----> 4     search.get_next_page()

/usr/local/lib/python3.6/dist-packages/pyunsplash/src/unpage.py in get_next_page(self)
    118 
    119     def get_next_page(self):
--> 120         return self.__class__(url=self.link_next, api_key=self.api_key)
    121 
    122     def get_previous_page(self):

TypeError: __init__() missing 1 required positional argument: 'where'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.