Skip to content

Conversation

@arunabhdas
Copy link

Improved checking for totalContentPages reached which solves the termination condition issue.

break
}
if (pageNav.page > totalContentPages) {
if (pageNav.page >= totalContentPages) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this in one of the books I extracted, but I had to do (totalContentPages - 1) otherwise it would keep trying to go to a last page that couldn't be navigated to.

It's strange because the kindle app calculates the total content pages the same, but you can't navigate to that last page. It then gets stuck in a loop of screenshotting the same page and trying to navigate to the next.

With more time, a smarter solution would probably be checking if the current page has already been navigated to, then break

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, in my testing it seemed to be slightly different for different books. i never had the chance to improve the robustness, but I like the idea of trying to get the current page ID and breaking if it's been visited

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some books do not include page numbers. I stumbled across this project while doing some research for another, so I decided to see if I could add some robustness to extract-kindkle-book. Seems to work well with three different books I tried, one is a biblical commentary, and the other two were both business books. I hope it helps.

Comment on lines +50 to +60
const getChromeExecutablePath = () => {
switch (os.platform()) {
case 'win32':
return 'C:/Program Files/Google/Chrome/Application/chrome.exe';
case 'darwin':
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
default:
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
}
}
const chromePath = getChromeExecutablePath();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt merge this in this PR as it's unrelated, and hardcoding paths is not guaranteed, e.g. i do not use chrome and use a custom build of chromium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants