Closed miguelssimao closed 2 months ago
In such cases, when iTunes itself doesn't answer a proper JSON response, what behavior do you expect? We could raise a custom Exception, or you can simply catch this exception in your code and decide to retry.
NB: It would be interesting to see the raw response when it happens. NB2: If you're intensively calling itunes it may be possible they raise a rate limit error
In such cases, when iTunes itself doesn't answer a proper JSON response, what behavior do you expect? We could raise a custom Exception, or you can simply catch this exception in your code and decide to retry.
NB: It would be interesting to see the raw response when it happens. NB2: If you're intensively calling itunes it may be possible they raise a rate limit error
Not even necessarily a custom exception, I think it could raise a LookupError
as well.
Yes, iTunes is being called everytime the metadata from the stream changes, so I was expecting this scenario to happen due to the frequent number of calls.
Thanks for raising this, I think it definitely makes sense to handle this in itunespy itself, since manually catching this exception would require you to couple yourself with specific errors from the JSON parser library itunespy uses, which is never a good thing :^)
I think it makes sense to catch it inside of the library and expose some LookupError
with details about what happened. It's been a while since I worked on the library, I might take a stab at it whenever I get some time, but feel free to create a PR if you feel like it @miguelssimao!
Hey folks, just for awareness I've just published version 1.6.1 with this fix. Happy coding :^) https://pypi.org/project/itunespy/1.6.1/
Thanks @pfouque for addressing this 🙇🏻
Occasionally,
lookup()
throws mejson.decoder.JSONDecodeError
andrequests.exceptions.JSONDecodeError
exceptions. I believe this happens because the server did not respond to my request and so there is no data to decode.Here is the full log:
Would it be possible for you to handle these exceptions in the module?