Skip to content

Commit

Permalink
feat(pixiv): improve ai filter (#140)
Browse files Browse the repository at this point in the history
* feat: improve ai filter

* fix: AI parameters value

---------

Co-authored-by: SaarChaffee <[email protected]>
  • Loading branch information
MaikoTan and SaarChaffee authored Mar 5, 2024
1 parent 4dec198 commit 29d3741
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/pixiv/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PixivImageSource extends ImageSource<PixivImageSource.Config> {
const params: PixivAppApi.SearchParams = {
word: query.tags.join(' '),
search_target: 'partial_match_for_tags',
search_ai_type: this.config.ai === 2 ? PixivAppApi.SearchAIType.SHOW_AI : PixivAppApi.SearchAIType.HIDE_AI,
sort: 'date_desc', // TODO: Pixiv member could use 'popular_desc'
filter: 'for_ios',
}
Expand Down Expand Up @@ -165,10 +166,9 @@ namespace PixivImageSource {
Schema.const(2).description('R18G')
]).description('年龄分级').default(0),
ai: Schema.union([
Schema.const(0).description('不允许AI作品'),
Schema.const(1).description('允许未知(旧画作或字段未更新)'),
Schema.const(1).description('不允许AI作品'),
Schema.const(2).description('允许AI作品')
]).description('是否允许搜索AI作品').default(0)
]).description('是否允许搜索AI作品').default(1)
}).description('搜索设置'),
])
}
Expand Down
6 changes: 5 additions & 1 deletion packages/pixiv/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ export namespace PixivAppApi {
| 'week_r18g'

export type SearchTarget = 'partial_match_for_tags' | 'exact_match_for_tags' | 'title_and_caption' | 'keyword'

export enum SearchAIType {
SHOW_AI = 0,
HIDE_AI = 1,
}
export type Sort = 'date_desc' | 'date_asc' | 'popular_desc'
export type Duration = 'within_last_day' | 'within_last_week' | 'within_last_month'

export interface SearchParams {
word: string
search_target: SearchTarget
search_ai_type?: SearchAIType
sort?: Sort
filter: Filter
duration?: Duration
Expand Down

0 comments on commit 29d3741

Please sign in to comment.