Replies: 4 comments 3 replies
-
最新发现:在文档中未标注 |
Beta Was this translation helpful? Give feedback.
-
添加一个日志的开关,有时候不想输出那么多的日志这个点也很符合我的想法,jmcomic目前的版本提供以下几种日志自定义方式来解决这个问题:
1. 日志完全开启/关闭使用代码:
使用配置: log: false
2. 日志过滤,只保留特定topic使用插件配置 log: true
plugins:
after_init:
- plugin: log_topic_filter # 日志topic过滤插件
kwargs:
whitelist: [ # 只保留api和html,这两个是Client发请求时会打的日志topic
'api',
'html',
] 3. 屏蔽插件的日志给插件配置加上一个 plugins:
after_init:
- plugin: client_proxy # 提高移动端的请求效率的插件
log: false # 插件自身不打印日志
kwargs:
proxy_client_key: cl_proxy_future
whitelist: [ api, ] 4. 完全自定义 jmcomic 日志参考文档:https://jmcomic.readthedocs.io/en/latest/tutorial/4_module_custom/ |
Beta Was this translation helpful? Give feedback.
-
关于第2点,很合理的想法。我觉得除了返回album实体类,还可以返回downloader,即向外界返回更多上下文信息 # api.py
def download_album(jm_album_id, option=None, downloader=None):
if not isinstance(jm_album_id, (str, int)):
return download_batch(download_album, jm_album_id, option, downloader)
with new_downloader(option, downloader) as dler:
# 返回album,downloader
return dler.download_album(jm_album_id), dler
# jm_downloader.py
class JmDownloader(DownloadCallback):
def download_album(self, album_id):
client = self.client_for_album(album_id)
album = client.get_album_detail(album_id)
self.download_by_album_detail(album, client)
# 返回album实体类
return album |
Beta Was this translation helpful? Give feedback.
-
这个点,好像正是你现在在做的吧?要不你来实现这个插件叭!你会Pull Request吗? 插件的实现模板如下: from jmcomic import *
class InsertAlbumToSqlitePlugin(JmOptionPlugin):
plugin_key = 'sqlite'
def invoke(self,
# 声明album和downloader,当插件在after_album被调用时可以获取到
album: JmAlbumDetail,
downloader: JmDownloader,
# 这里定义用户配置项
db_filepath: str, # 例如db文件路径
):
"""
下面实现插件的功能
"""
pass 可以进一步参考zip插件: 和jm-server插件: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions