View Single Post
Old 01-25-2021, 02:07 PM   #1103
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
Posts: 7,119
Karma: 92500001
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
Quote:
Originally Posted by activedirectory View Post
I discovered that the current availability of a book is rendered using javascript and was wondering if you could give me a hint of how to recover that information?
There are two main cases. If the book is already on hold for the current user then the data comes from the HTML page that shows the user's holds. Otherwise it comes from the main HTML page for the book.

The book HTML page has an inline script that assigns a structure containing data about the book to window.OverDrive.mediaItems. In the plugin the get_media_items2() in overdrive.py locates this data and parses it using the JSON decoder. get_current_book_availability() extracts the needed data and calculate_wait_weeks() combines it to produce the wait time estimate.
jhowell is offline   Reply With Quote