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

feat: add bgm Access Token parameter #14

Merged
merged 19 commits into from
Nov 25, 2024
Merged

feat: add bgm Access Token parameter #14

merged 19 commits into from
Nov 25, 2024

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' function and update the CLI to accept this token, enabling authenticated requests to the Anime Bangumi API.

New Features:

  • Introduce an optional 'Access Token' parameter to the 'bangumi' function to allow authenticated requests.

Enhancements:

  • Update command-line interface to accept a new '--BANGUMI_ACCESS_TOKEN' argument for providing the access token.

NULL204 and others added 19 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 an access token parameter in the Bangumi API integration. The implementation adds a new optional parameter for the access token across multiple files, which is then used to add Bearer token authentication to API requests when provided.

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(bangumi_url, bangumi_access_token)
    Sub->>Bangumi: Call bangumi(url, 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]) BGM
    }
    note for Bangumi "Added token parameter for Bearer authentication"
Loading

File-Level Changes

Change Details Files
Added Bearer token authentication support for Bangumi API requests
  • Added optional 'token' parameter to bangumi function
  • Added Authorization header with Bearer token when token is provided
yuisub/bangumi.py
Added command line argument support for Bangumi access token
  • Added new command line argument '-ac' or '--BANGUMI_ACCESS_TOKEN' for the access token
yuisub/__main__.py
Updated translation function to support Bangumi access token
  • Added bangumi_access_token parameter to translate function
  • Updated bangumi function call to pass 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.

@Tohrusky Tohrusky changed the title Add Access Token parameter feat: add bgm Access Token parameter Nov 25, 2024
@Tohrusky Tohrusky merged commit b67c9c6 into TensoRaws:main Nov 25, 2024
3 checks passed
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