Closed philborman closed 6 years ago
@philborman Thanks! That worked perfectly. What's the longest you've seen it take for GoodReads to return a response? I didn't add a max tries yet, but I do like the idea if it becomes a problem.
I've had goodreads timeout completely on occasion, might be the vpn I'm using though. LazyLibrarian will trap timeout at 30 seconds by default, and also some very long result lists can take a while to return as they are paginated, eg findBook&name=Star+Wars can take nearly a minute but each individual page doesn't exceed the timeout.
Looks good, I have made a few changes to the api though which might make it easier. queueBook now returns an error if the book id is not recognised. This means the sleep() after queueBook is not needed. Also the sleep after addBook is not ideal as we are waiting for goodreads to get back to us and it could be a while. addBook doesn't put the bookID into the database until it gets the reply from goodreads so it would be safer to call addBook then poll queueBook in a loop until you get "OK". You could maybe sleep a second in the loop, maybe add a limit on how many tries? Hope this helps :-)