-
Notifications
You must be signed in to change notification settings - Fork 28
Add HookRunner #788
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 HookRunner #788
Conversation
改成 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #788 +/- ##
==========================================
- Coverage 41.31% 41.10% -0.21%
==========================================
Files 32 32
Lines 2246 2272 +26
==========================================
+ Hits 928 934 +6
- Misses 1318 1338 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
感觉是不是提供个基类然后继承比较好。这样可以给hook传参数。比如这里可以给hook传一下刚刚添加了哪一集? |
那hook的地方就要变得细粒度好多了,或者可以把 locals() 或者单独的updated_bangumi_obj传进去;写继承的话也无法做hook代码想要什么信息就能在hook点得到什么信息吧 明天起来再说() |
没有想到什么特别好的设计,因为即使继承了的话,在hook的代码这边想要什么变量,怎么实现在hook点也自动传过去呢 |
有什么想法吗( |
运行的时候 from typing import Protocol
class BaseHook(Protocol):
def pre_add_download(self, *args, **kwargs):
pass
def post_add_download(self, *args, **kwargs):
pass
class MyHook(BaseHook):
def pre_add_download(self, *args, **kwargs):
print("my pre-add-download hook")
|
改成了继承基类的方式,但是现在感觉没有必要传什么参数,因为里面可以直接操作bgmi里面的数据库了,所以没有什么参数是必须要传的,可以直接拿db的类去query |
bgmi/script.py
Outdated
def __init__(self) -> None: | ||
pass | ||
|
||
def pre_add_download(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*args
和 **kwrags
呢。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改了
从 #786 拆封出来
基于ScriptRunner改了一个HookRunner,这个hook runner可以在下载前和下载后执行一些东西
我用来直接在提交给qbit下载后根据文件名进行重命名,变成成
S01/xxx S01Exx.mkv
的形式,可以直接被emby、jellyfin更好地进行刮削。因为如果要在下载时就重命名好,好像需要对里面许多东西进行大量重构,不如单独针对特定的来一点点修,这个也不会针对每一个episode就新建一个文件夹放在
~/.bgmi/hooks
下面即可给qbit用的重命名hook