Add support for fetching reading progress (and improved type safety)#5
Open
ShortTimeNoSee wants to merge 6 commits intoym496:mainfrom
Open
Add support for fetching reading progress (and improved type safety)#5ShortTimeNoSee wants to merge 6 commits intoym496:mainfrom
ShortTimeNoSee wants to merge 6 commits intoym496:mainfrom
Conversation
reading_progress to the features list; new code example for fetching progress; cookie requirements for authenticated endpoints
This commit marks a significant evolution of the unofficial StoryGraph API wrapper, focusing on performance, reliability, and expanded functionality.
- Replaced Selenium with `requests`: The core scraping logic has been refactored to use the `requests` library directly, removing the heavy dependency on Selenium and a headless browser. This results in a much faster, lighter, and more stable client.
- Expanded API Coverage: Added numerous new methods to interact with the StoryGraph API:
- **User:** Fetch `currently-reading`, `to-read`, and `books-read` shelves, and retrieve all journal entries.
- **Book:** Get reading progress, read dates, AI summaries, and journal entries for specific books.
- Enhanced Authentication: Implemented a more reliable cookie-based authentication flow, requiring `_storygraph_session` and `remember_user_token`.
- Added Comprehensive Tests: A new `test.py` script provides a full suite of tests for all client methods, ensuring reliability.
- New README: Generated a completely new `README.md` that reflects all the new features, including detailed setup instructions and up-to-date usage examples.
|
Just wanted to thank you for putting this PR together, works great for me! The updated error handling is a lot easier to debug as well. |
|
merge this @ShortTimeNoSee ? @ym496 LTGM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi there! Thanks for creating this package. I'd wanted to add a feature for my own use and thought it might be helpful for others too.
This pull request adds the ability to fetch a user's reading progress for a book.
book.reading_progress(book_id, cookies)method would be the new method on the Book client to get the current progress (e.g., "70%"). This requires authentication, so I've added the necessary logic to handle session cookies for book-related requests. I also added a user-agent to book requests. This should HELP to prevent the 403 issues seen in Issue #4The README is also updated, and while adding the new feature, I ran the static type checker pyright and fixed a number of potential type-related issues in the parsing logic. This should make the code a bit more robust/future-proof without changing any existing functionality.
All existing methods are backward compatible, so these changes shouldn't break anything for current users.
Let me know if you have any feedback or suggestions.