-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Dev #175
Dev #175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,10 +6,10 @@ filter(过滤器)是v2.1.12新引入的机制, | |||||
使用filter的步骤如下: | ||||||
|
||||||
``` | ||||||
1. 自定义class,继承JmDownloader,重写filter_iter_objs方法,即: | ||||||
1. 自定义class,继承JmDownloader,重写do_filter方法,即: | ||||||
class MyDownloader(JmDownloader): | ||||||
def filter_iter_objs(self, iter_objs: DownloadIterObjs): | ||||||
# 如何重写?参考JmDownloader.filter_iter_objs和下面的示例 | ||||||
def do_filter(self, iter_objs: DownloadIterObjs): | ||||||
# 如何重写?参考JmDownloader.do_filter和下面的示例 | ||||||
... | ||||||
|
||||||
2. 让你的class生效,使用如下代码: | ||||||
|
@@ -30,8 +30,8 @@ from jmcomic import * | |||||
|
||||||
class First3ImageDownloader(JmDownloader): | ||||||
|
||||||
def filter_iter_objs(self, iter_objs: DownloadIterObjs): | ||||||
if isinstance(iter_objs, JmPhotoDetail): | ||||||
def do_filter(self, detail): | ||||||
if detail.is_photo(): | ||||||
photo: JmPhotoDetail = iter_objs | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable - photo: JmPhotoDetail = iter_objs
+ photo: JmPhotoDetail = detail Committable suggestion
Suggested change
|
||||||
# 支持[start,end,step] | ||||||
return photo[:3] | ||||||
|
@@ -52,8 +52,8 @@ class FindUpdateDownloader(JmDownloader): | |||||
'xxx': 'yyy' | ||||||
} | ||||||
|
||||||
def filter_iter_objs(self, iter_objs: DownloadIterObjs): | ||||||
if not isinstance(iter_objs, JmAlbumDetail): | ||||||
def do_filter(self, detail): | ||||||
if not detail.is_album(): | ||||||
return iter_objs | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable - return iter_objs
+ return detail Committable suggestion
Suggested change
|
||||||
|
||||||
return self.find_update(iter_objs) | ||||||
|
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.
The
branches-ignore
entry has a trailing comma which is not necessary and could potentially cause issues with YAML parsing. It's best to remove it to avoid any ambiguity.Committable suggestion