lorenzodifuccia / safaribooks

Download and generate EPUB of your favorite books from O'Reilly Learning (aka Safari Books Online) library.
Do What The F*ck You Want To Public License
4.62k stars 685 forks source link

Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError) #250

Closed dhruv-bansal closed 1 year ago

dhruv-bansal commented 3 years ago

getting this error Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError)

[10/Dec/2020 22:30:00] Description: Apply microservices patterns to build resilient and scalable distributed systemsKey FeaturesUnderstand the challenges of building large-scale microservice landscapes Build cloud-native production-ready microservices with this comprehensive guide Discover how to get the best out of Spring Cloud, Kubernetes, and Istio when used togetherBook DescriptionMicroservices architecture allows developers to build and maintain applications with ease, and enterprises are rapidly adopting it to build software... [10/Dec/2020 22:30:00] Release Date: 2019-09-20 [10/Dec/2020 22:30:00] URL: https://learning.oreilly.com/library/view/handson-microservices-with/9781789613476/ [10/Dec/2020 22:30:00] Retrieving book chapters... [10/Dec/2020 22:30:15] File "safaribooks.py", line 1112, in SafariBooks(args_parsed) File "safaribooks.py", line 349, in init self.book_chapters = self.get_book_chapters() File "safaribooks.py", line 572, in get_book_chapters return result + (self.get_book_chapters(page + 1) if response["next"] else []) File "safaribooks.py", line 572, in get_book_chapters return result + (self.get_book_chapters(page + 1) if response["next"] else []) File "safaribooks.py", line 572, in get_book_chapters return result + (self.get_book_chapters(page + 1) if response["next"] else []) [Previous line repeated 4 more times] File "safaribooks.py", line 555, in get_book_chapters response = response.json() File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 897, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None

[10/Dec/2020 22:30:15] Unhandled Exception: Expecting value: line 1 column 1 (char 0) (type: JSONDecodeError) [10/Dec/2020 22:30:15] Last request done: URL: https://learning.oreilly.com/api/v1/book/9781789613476/chapter/?page=8 DATA: None OTHERS: {}

500
Connection: keep-alive
Content-Length: 5
server: istio-envoy
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000; includeSubDomains
x-envoy-upstream-service-time: 547
etag: W/"5-HNpjNEc7NA6q6c3n6by2sZ4GE1Y"
x-content-type-options: nosniff
x-powered-by: Express
Fastly-Restarts: 1
Accept-Ranges: bytes
Date: Thu, 10 Dec 2020 17:00:15 GMT
Via: 1.1 varnish
X-Client-IP: 122.160.17.110
X-Served-By: cache-del21723-DEL
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1607619607.255622,VS0,VE8504
Vary: Accept, Accept-Encoding, Authorization, Cookie

Oops.

lorenzodifuccia commented 3 years ago

🤷🏻‍♂️

fullstackzach commented 3 years ago

I'm also running into this error with book 9780134757681 - Refactoring: Improving the Design of Existing Code

Lugghawk commented 3 years ago

This seems like it might be temporary with the API on Oreilly. I was getting this 500 error last night and this morning it worked fine 🤷

@lorenzodifuccia, a possible stopgap for this is to try and specifically catch this error and report that something is up with the Oreilly API and to try again later.