Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Access Token parameter #13

Closed
wants to merge 18 commits into from
Closed

Add Access Token parameter #13

wants to merge 18 commits into from

Conversation

NULL204
Copy link
Contributor

@NULL204 NULL204 commented Nov 25, 2024

Add Access Token parameter

Summary by Sourcery

Add an optional access token parameter to the Bangumi data fetching function to support authenticated requests, and update the CLI to accept this token as an argument.

New Features:

  • Introduce an optional access token parameter for fetching Bangumi data, allowing for authenticated requests.

Enhancements:

  • Update the command-line interface to accept a Bangumi access token as an optional argument.

NULL204 and others added 18 commits November 2, 2024 16:20
更改内容以符合规范
格式化代码,现在应该不会有错误了吧🤔
Use httpx for asynchrony and coroutine pool instead of multithreading
Add separate file test code
Trying to solve asyncio.run lifecycle issue
	modified:   tests/test_bangumi.py
	modified:   tests/test_llm.py
	modified:   tests/test_sub.py
	modified:   yuisub/bangumi.py
	modified:   yuisub/sub.py
	modified:   yuisub/sub.py
	modified:   yuisub/bangumi.py
	modified:   yuisub/sub.py
Copy link

sourcery-ai bot commented Nov 25, 2024

Reviewer's Guide by Sourcery

This PR adds support for Bangumi access token authentication by introducing a new optional parameter across multiple files. The token is used to authenticate API requests by adding a Bearer token to the request headers.

Sequence diagram for Bangumi API request with Access Token

sequenceDiagram
    actor User
    participant Main as __main__.py
    participant Sub as sub.py
    participant Bangumi as bangumi.py
    User->>Main: Provide BANGUMI_URL and BANGUMI_ACCESS_TOKEN
    Main->>Sub: Call translate with bangumi_url and bangumi_access_token
    Sub->>Bangumi: Call bangumi with url and token
    Bangumi->>Bangumi: Add Authorization header if token is provided
    Bangumi->>Sub: Return bangumi info
    Sub->>Main: Return translated subtitles
    Main->>User: Display subtitles
Loading

Updated class diagram for Bangumi function

classDiagram
    class Bangumi {
        +async bangumi(url: Optional[str], token: Optional[str])
    }
    note for Bangumi "Added token parameter to support access token authentication"
Loading

File-Level Changes

Change Details Files
Added Bangumi access token support to the authentication system
  • Added optional 'token' parameter to the bangumi function
  • Added Bearer token authentication header when token is provided
  • Added new command line argument for Bangumi access token
yuisub/bangumi.py
yuisub/__main__.py
Updated translation function to support Bangumi authentication
  • Added bangumi_access_token parameter to translate function
  • Modified bangumi function call to pass through the access token
yuisub/sub.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @NULL204 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@NULL204 NULL204 closed this Nov 25, 2024
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