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

为B站动态API建立model,转发动态放入repost字段 #507

Merged
merged 9 commits into from
Mar 29, 2024

Conversation

AzideCupric
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Mar 21, 2024

Deploy Preview for nonebot-bison ready!

Name Link
🔨 Latest commit ea5e76e
🔍 Latest deploy log https://app.netlify.com/sites/nonebot-bison/deploys/66029d8ff40c080008d750ba
😎 Deploy Preview https://deploy-preview-507--nonebot-bison.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 89.04110% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 83.66%. Comparing base (0acd457) to head (5fc1da4).

Files Patch % Lines
nonebot_bison/platform/bilibili.py 88.96% 16 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           fix/pyd-compat     #507      +/-   ##
==================================================
+ Coverage           83.50%   83.66%   +0.15%     
==================================================
  Files                  78       78              
  Lines                3565     3636      +71     
==================================================
+ Hits                 2977     3042      +65     
- Misses                588      594       +6     
Flag Coverage Δ
smoke-test 83.66% <89.04%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

nonebot_bison/platform/bilibili.py Outdated Show resolved Hide resolved
nonebot_bison/platform/bilibili.py Outdated Show resolved Hide resolved
Comment on lines 250 to 277
if in_repost and raw_origin:
url = f"https://t.bilibili.com/{raw_origin.dynamic_id_str}"
else:
url = f"https://t.bilibili.com/{raw_post.desc.dynamic_id_str}"
text: str = card_content["item"]["description"]
pic: list[str] = [img["img_src"] for img in card_content["item"]["pictures"]]
return ParsedPost(text, pic, url, repost_owner)
case 2:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里为什么不像原来那样分为 _get_info 和 parse 两个函数了

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

因为原来两个函数里都是按category分支看起来很啰嗦,感觉不如合成一个

Copy link
Collaborator

Choose a reason for hiding this comment

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

但是这里写了4便if repose,看起来还是可以简化的那种

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

...
def extract_id(name: str):
    if in_repost and raw_origin:
        return getattr(raw_origin, name)
    return getattr(raw_post.desc, name)

match self._do_get_category(raw_post.desc.type):
    case 1:
        # 一般动态
        url = f"https://t.bilibili.com/{extract_id('dynamic_id_str')}"
...

这样呢(

Copy link
Collaborator

Choose a reason for hiding this comment

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

行吧

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

稍微再改了一点

@felinae98 felinae98 mentioned this pull request Mar 26, 2024
@AzideCupric AzideCupric changed the base branch from main to fix/pyd-compat March 27, 2024 10:29
@AzideCupric
Copy link
Collaborator Author

先合并前置的 #512

Base automatically changed from fix/pyd-compat to main March 29, 2024 07:03
@felinae98 felinae98 changed the title ♻️ 为B站动态API建立model,转发动态放入repost字段 为B站动态API建立model,转发动态放入repost字段 Mar 29, 2024
@felinae98 felinae98 added the bug Something isn't working label Mar 29, 2024
@felinae98 felinae98 merged commit 9bc5be5 into main Mar 29, 2024
30 checks passed
@felinae98 felinae98 deleted the fix/bilibili-none branch March 29, 2024 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants