Skip to content

Commit 359579f

Browse files
committed
feat!: migrate to latest animegarden
1 parent f5f1042 commit 359579f

File tree

10 files changed

+33
-77
lines changed

10 files changed

+33
-77
lines changed

packages/animegarden/src/format.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,21 @@ export function formatAnimeGardenSearchURL(anime: Anime) {
1616
}
1717

1818
export function printKeywords(anime: Anime, logger: ConsolaInstance) {
19-
if (anime.plan.keywords.include.length === 1) {
20-
const first = anime.plan.keywords.include[0];
21-
const sum = first.reduce((acc, t) => acc + width(t), 0);
22-
if (sum > 50) {
23-
logger.log(dim('Include keywords | ') + underline(overflowText(first[0], 50)));
24-
for (const t of first.slice(1)) {
25-
logger.log(` ${dim('|')} ${underline(overflowText(t, 50))}`);
26-
}
27-
} else {
28-
logger.log(
29-
`${dim('Include keywords')} ${first
30-
.map((t) => underline(overflowText(t, 50)))
31-
.join(dim(' | '))}`
32-
);
19+
const include = anime.plan.keywords.include;
20+
const sum = include.reduce((acc, t) => acc + width(t), 0);
21+
if (sum > 50) {
22+
logger.log(dim('Include keywords | ') + underline(overflowText(include[0], 50)));
23+
for (const t of include.slice(1)) {
24+
logger.log(` ${dim('|')} ${underline(overflowText(t, 50))}`);
3325
}
3426
} else {
35-
logger.log(dim(`Include keywords:`));
36-
for (const include of anime.plan.keywords.include) {
37-
logger.log(` ${DOT} ${include.map((t) => underline(overflowText(t, 50))).join(' | ')}`);
38-
}
27+
logger.log(
28+
`${dim('Include keywords')} ${include
29+
.map((t) => underline(overflowText(t, 50)))
30+
.join(dim(' | '))}`
31+
);
3932
}
33+
4034
if (anime.plan.keywords.exclude.length > 0) {
4135
logger.log(
4236
`${dim(`Exclude keywords`)} [ ${anime.plan.keywords.exclude

packages/animegarden/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export function AnimeGarden(options: AnimeGardenOptions): Plugin {
7575

7676
const resource = await fetchResourceDetail(
7777
ufetch,
78+
'dmhy',
7879
video.source.magnet.split('/').at(-1)!
7980
);
8081

packages/animegarden/src/resources/cache.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,11 @@ export class ResourcesCache {
162162
return false;
163163
}
164164

165-
const stringifyArray = (include: string[][]) => {
166-
return include.map((inc) => `[${inc.map(normalizeTitle).join(',')}]`).join(',');
167-
};
168165
const stringify = (keys?: string[]) => (keys ?? []).join(',');
169166

170167
if (
171168
!cache.filter.include ||
172-
stringifyArray(cache.filter.include) !== stringifyArray(anime.plan.keywords.include)
169+
stringify(cache.filter.include) !== stringify(anime.plan.keywords.include)
173170
) {
174171
return false;
175172
}

packages/bangumi/src/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export async function getCollections(username: string) {
164164

165165
async function getFansub(titles: string[]) {
166166
const { resources } = await fetchResources(ufetch, {
167-
include: [titles],
167+
include: titles,
168168
count: -1,
169169
retry: 5
170170
});

packages/cli/test/__snapshots__/space.test.ts.snap

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ exports[`system > should load 1`] = `
1717
"keywords": {
1818
"exclude": [],
1919
"include": [
20-
[
21-
"熊熊勇闯异世界 Punch!",
22-
],
20+
"熊熊勇闯异世界 Punch!",
2321
],
2422
},
2523
"preference": {
@@ -73,10 +71,8 @@ exports[`system > should load 1`] = `
7371
"keywords": {
7472
"exclude": [],
7573
"include": [
76-
[
77-
"天国大魔境",
78-
"Tengoku Daimakyou",
79-
],
74+
"天国大魔境",
75+
"Tengoku Daimakyou",
8076
],
8177
},
8278
"preference": {
@@ -136,19 +132,7 @@ exports[`system > should load 1`] = `
136132
"闪耀色彩",
137133
],
138134
"include": [
139-
[
140-
"偶像大师 灰姑娘女孩 U149",
141-
],
142-
[
143-
"偶像大师",
144-
"iDOLM@STER",
145-
],
146-
[
147-
"灰姑娘女孩",
148-
],
149-
[
150-
"U149",
151-
],
135+
"偶像大师 灰姑娘女孩 U149",
152136
],
153137
},
154138
"preference": {

packages/core/src/anime/anime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ export class Anime {
9292
return false;
9393
}
9494
}
95-
for (const list of this.plan.keywords.include) {
96-
if (list.every((keyword) => !text.includes(keyword))) {
97-
return false;
95+
for (const key of this.plan.keywords.include) {
96+
if (text.includes(key)) {
97+
return true;
9898
}
9999
}
100100
return true;

packages/core/src/plan/plan.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,24 @@ function resolveKeywordsArray(
106106
if (keywords !== undefined && keywords !== null) {
107107
if (typeof keywords === 'string') {
108108
if (!keywords.startsWith('!')) {
109-
return { include: [titles, [keywords]], exclude: [] };
109+
return { include: [...titles, keywords], exclude: [] };
110110
} else {
111-
return { include: [titles], exclude: [keywords.slice(1)] };
111+
return { include: titles, exclude: [keywords.slice(1)] };
112112
}
113113
} else if (Array.isArray(keywords)) {
114-
const include: string[][] = [titles];
114+
const include: string[] = [];
115115
const exclude: string[] = [];
116116
for (const keyword of keywords) {
117117
if (typeof keyword === 'string') {
118118
if (!keyword.startsWith('!')) {
119-
include.push([keyword]);
119+
include.push(keyword);
120120
} else {
121121
exclude.push(keyword.slice(1));
122122
}
123-
} else if (Array.isArray(keyword)) {
124-
include.push(keyword);
125123
}
126124
}
127125
return { include, exclude };
128126
}
129127
}
130-
return { include: [titles], exclude: [] };
128+
return { include: titles, exclude: [] };
131129
}

packages/core/src/plan/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface AnimePlan {
8282
}
8383

8484
export interface KeywordsParams {
85-
readonly include: string[][];
85+
readonly include: string[];
8686

8787
readonly exclude: string[];
8888
}

packages/core/test/__snapshots__/space.test.ts.snap

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ exports[`Load Space > should work 2`] = `
111111
"keywords": {
112112
"exclude": [],
113113
"include": [
114-
[
115-
"熊熊勇闯异世界 Punch!",
116-
],
114+
"熊熊勇闯异世界 Punch!",
117115
],
118116
},
119117
"preference": {
@@ -167,10 +165,8 @@ exports[`Load Space > should work 2`] = `
167165
"keywords": {
168166
"exclude": [],
169167
"include": [
170-
[
171-
"天国大魔境",
172-
"Tengoku Daimakyou",
173-
],
168+
"天国大魔境",
169+
"Tengoku Daimakyou",
174170
],
175171
},
176172
"preference": {
@@ -230,19 +226,7 @@ exports[`Load Space > should work 2`] = `
230226
"闪耀色彩",
231227
],
232228
"include": [
233-
[
234-
"偶像大师 灰姑娘女孩 U149",
235-
],
236-
[
237-
"偶像大师",
238-
"iDOLM@STER",
239-
],
240-
[
241-
"灰姑娘女孩",
242-
],
243-
[
244-
"U149",
245-
],
229+
"偶像大师 灰姑娘女孩 U149",
246230
],
247231
},
248232
"preference": {

packages/core/test/fixtures/space/plans/2023.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@ onair:
2121
bgm: 376703
2222
fansub: 喵萌奶茶屋
2323
keywords:
24-
- [偶像大师, iDOLM@STER]
25-
- 灰姑娘女孩
26-
- U149
24+
- 偶像大师 灰姑娘女孩 U149
2725
- '!闪耀色彩'

0 commit comments

Comments
 (0)