Skip to content

Conversation

@NHagar
Copy link
Owner

@NHagar NHagar commented May 25, 2025

This pull request introduces functionality to handle renamed Substack user accounts by following redirects, along with corresponding updates to the documentation, API, and tests. The main changes include the addition of redirect handling in the User class, a new helper function for manual handle resolution, and updates to the user guide and API reference.

New Features and Enhancements:

  • Redirect Handling in User Class:

    • Added a follow_redirects parameter to the User class to enable automatic redirect handling for renamed Substack handles. [1] [2]
    • Introduced a was_redirected property to check if a user's handle was redirected.
    • Implemented _update_handle to update the user's handle and endpoint after a redirect. [1] [2]
  • Helper Function for Manual Handle Resolution:

    • Added resolve_handle_redirect to resolve renamed handles manually by following redirects. [1] [2]

Documentation Updates:

  • API Reference Updates:

    • Documented the new follow_redirects parameter, was_redirected property, and _update_handle method in the User class. [1] [2] [3]
    • Added error handling details for renamed accounts in _fetch_user_data.
  • User Guide Enhancements:

    • Included examples for using the User class with and without redirect handling. [1] [2]
    • Added a section on resolving handle redirects manually.

Codebase Updates:

  • substack_api/__init__.py:

    • Exposed resolve_handle_redirect in the module's public API.
  • Improved Error Handling:

    • Enhanced _fetch_user_data to handle 404 errors caused by renamed accounts and retry with the new handle if follow_redirects is enabled.

@NHagar NHagar requested a review from Copilot May 25, 2025 17:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces automatic and manual redirect handling for renamed Substack user accounts. Key changes include updates to the User class to follow redirects with a new follow_redirects parameter and was_redirected property, the addition of the resolve_handle_redirect helper function, and corresponding documentation and tests updates.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_user_redirects.py Added comprehensive tests for handling redirects and error cases.
test.py Provided a simple example usage of the new User functionality.
substack_api/user.py Updated User class with redirect handling, _update_handle, and _fetch_user_data enhancements along with resolve_handle_redirect.
substack_api/init.py Exported resolve_handle_redirect in the public API.
docs/user-guide.md Updated examples and added documentation for redirect handling.
docs/api-reference/user.md Documented new parameters and methods related to redirect handling.
README.md Included sections detailing the handling of renamed accounts.

@NHagar NHagar merged commit 3ac1b62 into master May 25, 2025
2 checks passed
@NHagar NHagar deleted the renamed-accounts branch May 25, 2025 17:29
@NHagar NHagar mentioned this pull request May 25, 2025
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.

2 participants