dsh-mikan 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/README.md +32 -14
- package/client.js +125 -15
- package/docs/DETAIL.md +61 -27
- package/index.js +99 -17
- package/lib/airdate.js +4 -3
- package/lib/constants.js +4 -0
- package/lib/mikan.js +9 -4
- package/lib/mirrors.js +58 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### 新增
|
|
6
|
+
|
|
7
|
+
- **蜜柑可达性提示**:状态条上的蜜柑来源改为带色块的状态标签,探测失败时显示为红色(此前只显示域名,连不上也看不出来)
|
|
8
|
+
- **自定义镜像域名**:配置项 `mikanBase` / `bgmBase` 可填入自建或第三方镜像;留空则自动探测
|
|
9
|
+
- **bgm 镜像目录**:内置社区维护的 Bangumi 镜像目录(`bangumi.wiki/api/v1/mirrors`),官方 API 不可达时自动从目录里挑一个可用的 API 镜像,结果缓存 1 小时
|
|
10
|
+
- **镜像不硬编码**:目录会持续变化,插件只硬编码目录入口,具体镜像每次从目录读取
|
|
11
|
+
|
|
12
|
+
### 背景
|
|
13
|
+
|
|
14
|
+
部分运营商(如安徽联通的部分地区)封锁了 Cloudflare 节点,而 mikan 的两个域名都在 Cloudflare 后面,会导致插件完全无法获取数据。`mikanBase` 提供了绕开内置域名的途径;没有可用镜像时,仍然只能通过代理访问。
|
|
15
|
+
|
|
16
|
+
bgm.tv 官方 API 在大陆同样需要代理,但社区镜像通常可以直连,因此插件改用「官方优先、目录镜像兜底」的策略,无代理用户也能补全开播日期。
|
|
17
|
+
|
|
3
18
|
## 0.2.0
|
|
4
19
|
|
|
5
20
|
### 新增
|
|
@@ -28,7 +43,7 @@
|
|
|
28
43
|
### 优化
|
|
29
44
|
|
|
30
45
|
- 工具默认返回条数 60 → 30,单次约省一半 token
|
|
31
|
-
-
|
|
46
|
+
- 下载器状态统一称「下载器」,未连接时不再区分具体软件
|
|
32
47
|
- 连接指引同时展示 BitComet 与 qBittorrent 两套步骤
|
|
33
48
|
- 移除本地调试残留(硬编码路径、调试日志)
|
|
34
49
|
|
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# dsh-mikan
|
|
2
2
|
|
|
3
|
-
DeepSeek Harness
|
|
3
|
+
DeepSeek Harness 的**蜜柑计划追番插件**:浏览当季与往季新番、按字幕组订阅、把确认的作品送进 BitComet 或 qBittorrent。
|
|
4
4
|
|
|
5
5
|
- 侧边栏「追番」页:七列周历 + 三级浏览 + 红绿黄更新点
|
|
6
|
-
-
|
|
6
|
+
- 作品按语言分类(简体 / 繁体 / 多字幕),支持单集与批量下载
|
|
7
|
+
- 对话工具:浏览、订阅、检查更新、按 hash 下载
|
|
7
8
|
- 半自动:只通知你,下载永远由你确认
|
|
8
9
|
|
|
9
10
|
## 安装
|
|
@@ -20,10 +21,11 @@ dsh plugin --profile web add dsh-mikan
|
|
|
20
21
|
|
|
21
22
|
打开「追番」:
|
|
22
23
|
|
|
23
|
-
1.
|
|
24
|
-
2.
|
|
25
|
-
3.
|
|
26
|
-
4.
|
|
24
|
+
1. **当季浏览**:按当前月份自动判断季度,按放送星期折叠列出新番
|
|
25
|
+
2. **往季浏览**:从近 12 年里选任意季度
|
|
26
|
+
3. 点某部番 → 看开播日和做这部番的字幕组
|
|
27
|
+
4. 点某个字幕组 → 看它的作品列表,带语言标签,可「订阅本组」或按语言批量下载
|
|
28
|
+
5. 订阅后出现在周历,卡片显示 `字幕组 已到 X / 全番 Y`
|
|
27
29
|
|
|
28
30
|
订阅只跟**指定字幕组**:该组出新集才通知,别组的进度只作参考(全番最新)。
|
|
29
31
|
|
|
@@ -47,6 +49,8 @@ dsh plugin --profile web add dsh-mikan
|
|
|
47
49
|
| `bitcometBase` | `http://127.0.0.1:10816` | BitComet WebUI 地址 |
|
|
48
50
|
| `qbittorrentBase` | `http://127.0.0.1:8080` | qBittorrent WebUI 地址 |
|
|
49
51
|
| `qbittorrentUser` / `qbittorrentPassword` | 空 | qB 凭据;qB 允许 localhost 免认证时可留空 |
|
|
52
|
+
| `mikanBase` | 空 | 自定义蜜柑镜像;留空自动探测内置域名 |
|
|
53
|
+
| `bgmBase` | 空 | 自定义 bgm API;留空用官方 + 内置目录镜像 |
|
|
50
54
|
| `savePath` | 空(必填) | 下载保存目录,未设置时下载会被拒绝 |
|
|
51
55
|
| `proxy` | 空 | 本地代理地址,留空直连 |
|
|
52
56
|
| `checkIntervalMinutes` | 30 | 后台检查间隔 |
|
|
@@ -60,19 +64,33 @@ BitComet 的用户名密码会从 `%APPDATA%\BitComet\BitComet.xml` 自动读取
|
|
|
60
64
|
| **BitComet** | 选项 → 远程访问 → 开启网页版访问,端口固定值 |
|
|
61
65
|
| **qBittorrent** | 工具 → 选项 → Web UI → 启用 Web 用户界面 |
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
「自动检测」会依次尝试两种下载器,找到即自动切换。插件不会自己启动或关闭下载器,请保持它运行。
|
|
64
68
|
|
|
65
|
-
##
|
|
69
|
+
## 数据源
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
- **蜜柑镜像**:自动探测墙内 `mikanime.tv` 与墙外 `mikanani.me`,优先使用可用的一方
|
|
72
|
+
- **作品列表**:走 `/Home/ExpandEpisodeTable`,不受 RSS 单组 100 条限制
|
|
73
|
+
- **开播日**:有代理时优先官方 bgm API,直连时优先社区镜像目录(`bangumi.wiki/api/v1/mirrors`,缓存 1 小时)
|
|
74
|
+
- **更新检查**:RSS(最近 100 条足够覆盖新集)
|
|
75
|
+
|
|
76
|
+
## 界面状态
|
|
77
|
+
|
|
78
|
+
状态条上的标签可点击:
|
|
79
|
+
|
|
80
|
+
| 标签 | 点击后 |
|
|
81
|
+
|---|---|
|
|
82
|
+
| 代理模式 / 直连模式 | — |
|
|
83
|
+
| Mikan 可用 / 不可用 | 查看连接详情、填自定义镜像、重新检测 |
|
|
84
|
+
| bgm 可用 / 不可用 | 同上 |
|
|
85
|
+
| 下载器 | 端口扫描结果、切换 BitComet / qBittorrent |
|
|
68
86
|
|
|
69
87
|
## 已知限制
|
|
70
88
|
|
|
71
|
-
- 没有字幕组做的番剧只有标题,开播日依赖 bgm/AniList,都不可用时显示未知
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
89
|
+
- 没有字幕组做的番剧只有标题,开播日依赖 bgm / AniList,都不可用时显示未知
|
|
90
|
+
- 剧场版 / OVA 的「放送日期」字段不可信,只用「放送开始」
|
|
91
|
+
- 部分运营商封锁 Cloudflare 时,蜜柑会完全不可达(两个内置域名都在 CF 后面),此时只能走代理或填自定义镜像
|
|
92
|
+
- 下载器接口返回值不可靠,一律以任务列表复核
|
|
93
|
+
- 插件不会自己启动或关闭下载器
|
|
76
94
|
|
|
77
95
|
## License
|
|
78
96
|
|
package/client.js
CHANGED
|
@@ -35,13 +35,16 @@ window.__ModuleLoader__.load({
|
|
|
35
35
|
multi: 'var(--dsw-alias-text-secondary, #868e96)',
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
function Pill({ ok, children, onClick }) {
|
|
38
|
+
function Pill({ ok, warn, children, onClick }) {
|
|
39
|
+
const color = warn
|
|
40
|
+
? 'var(--dsw-alias-warning, #f08c00)'
|
|
41
|
+
: (ok ? 'var(--dsw-alias-success, #2f9e44)' : 'var(--dsw-alias-danger, #e03131)');
|
|
39
42
|
return h('span', {
|
|
40
43
|
onClick,
|
|
41
44
|
style: {
|
|
42
45
|
display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 12,
|
|
43
46
|
padding: '2px 8px', borderRadius: 999, border,
|
|
44
|
-
color
|
|
47
|
+
color,
|
|
45
48
|
cursor: onClick ? 'pointer' : 'default',
|
|
46
49
|
},
|
|
47
50
|
}, h('span', { style: { width: 6, height: 6, borderRadius: '50%', background: 'currentColor' } }), children);
|
|
@@ -119,6 +122,8 @@ window.__ModuleLoader__.load({
|
|
|
119
122
|
const [groupByLang, setGroupByLang] = useState(false);
|
|
120
123
|
const [batchTarget, setBatchTarget] = useState(null);
|
|
121
124
|
const [batchStats, setBatchStats] = useState(null);
|
|
125
|
+
const [mikanBaseInput, setMikanBaseInput] = useState('');
|
|
126
|
+
const [bgmBaseInput, setBgmBaseInput] = useState('');
|
|
122
127
|
|
|
123
128
|
const load = useCallback(async ({ autoCheck = false } = {}) => {
|
|
124
129
|
try {
|
|
@@ -300,8 +305,8 @@ window.__ModuleLoader__.load({
|
|
|
300
305
|
subgroupId: subgroup.subgroupId, subgroupName: subgroup.name, loading: true, works: [],
|
|
301
306
|
}));
|
|
302
307
|
try {
|
|
303
|
-
const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=
|
|
304
|
-
setBrowse((b) => ({ ...b, loading: false, works: r.items || [], total: r.total || 0, limit:
|
|
308
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=30`);
|
|
309
|
+
setBrowse((b) => ({ ...b, loading: false, works: r.items || [], total: r.total || 0, limit: 30, counts: r.counts || null }));
|
|
305
310
|
} catch (e) {
|
|
306
311
|
setBrowse((b) => ({ ...b, loading: false, works: [], error: e.message }));
|
|
307
312
|
}
|
|
@@ -333,7 +338,7 @@ window.__ModuleLoader__.load({
|
|
|
333
338
|
|
|
334
339
|
const loadMoreWorks = useCallback(async () => {
|
|
335
340
|
if (!browse) return;
|
|
336
|
-
const next = Math.min((browse.limit ||
|
|
341
|
+
const next = Math.min((browse.limit || 30) + 30, browse.total || 0);
|
|
337
342
|
try {
|
|
338
343
|
const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=${next}`);
|
|
339
344
|
setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: next }));
|
|
@@ -342,6 +347,16 @@ window.__ModuleLoader__.load({
|
|
|
342
347
|
}
|
|
343
348
|
}, [browse]);
|
|
344
349
|
|
|
350
|
+
const showAllWorks = useCallback(async () => {
|
|
351
|
+
if (!browse) return;
|
|
352
|
+
try {
|
|
353
|
+
const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=500`);
|
|
354
|
+
setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: r.displayed || 500 }));
|
|
355
|
+
} catch (e) {
|
|
356
|
+
setNotice('加载失败:' + e.message);
|
|
357
|
+
}
|
|
358
|
+
}, [browse]);
|
|
359
|
+
|
|
345
360
|
const openBatch = useCallback(async (bangumiId, title, subgroup, ctx) => {
|
|
346
361
|
setBatchTarget({
|
|
347
362
|
bangumiId,
|
|
@@ -389,6 +404,51 @@ window.__ModuleLoader__.load({
|
|
|
389
404
|
}
|
|
390
405
|
}, [batchStats]);
|
|
391
406
|
|
|
407
|
+
const refreshEnv = useCallback(async () => {
|
|
408
|
+
setBusy('env');
|
|
409
|
+
try {
|
|
410
|
+
const r = await getJson('/state?refresh=1');
|
|
411
|
+
setState(r);
|
|
412
|
+
setNotice(r.mikanOk
|
|
413
|
+
? `蜜柑可达:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
|
|
414
|
+
: '蜜柑不可达,请检查网络或配置镜像');
|
|
415
|
+
} catch (e) {
|
|
416
|
+
setNotice('检测失败:' + e.message);
|
|
417
|
+
} finally {
|
|
418
|
+
setBusy('');
|
|
419
|
+
}
|
|
420
|
+
}, []);
|
|
421
|
+
|
|
422
|
+
const saveMikanBase = useCallback(async () => {
|
|
423
|
+
setBusy('mikan');
|
|
424
|
+
try {
|
|
425
|
+
await postJson('/config', { mikanBase: mikanBaseInput.trim() });
|
|
426
|
+
const r = await getJson('/state?refresh=1');
|
|
427
|
+
setState(r);
|
|
428
|
+
setNotice(r.mikanOk
|
|
429
|
+
? `已保存并连接:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
|
|
430
|
+
: '已保存,但该镜像当前不可达');
|
|
431
|
+
} catch (e) {
|
|
432
|
+
setNotice('保存失败:' + e.message);
|
|
433
|
+
} finally {
|
|
434
|
+
setBusy('');
|
|
435
|
+
}
|
|
436
|
+
}, [mikanBaseInput]);
|
|
437
|
+
|
|
438
|
+
const saveBgmBase = useCallback(async () => {
|
|
439
|
+
setBusy('bgm');
|
|
440
|
+
try {
|
|
441
|
+
await postJson('/config', { bgmBase: bgmBaseInput.trim() });
|
|
442
|
+
const r = await getJson('/state?refresh=1');
|
|
443
|
+
setState(r);
|
|
444
|
+
setNotice(r.bgm ? 'bgm 已连接' : 'bgm 不可用(需要代理,或填一个国内可达的镜像)');
|
|
445
|
+
} catch (e) {
|
|
446
|
+
setNotice('保存失败:' + e.message);
|
|
447
|
+
} finally {
|
|
448
|
+
setBusy('');
|
|
449
|
+
}
|
|
450
|
+
}, [bgmBaseInput]);
|
|
451
|
+
|
|
392
452
|
/* ---------- render ---------- */
|
|
393
453
|
|
|
394
454
|
if (error) {
|
|
@@ -540,9 +600,11 @@ window.__ModuleLoader__.load({
|
|
|
540
600
|
: g.items.map(renderWorkItem)))
|
|
541
601
|
: items.map(renderWorkItem)))),
|
|
542
602
|
items.length > 0 && items.length < (browse.total || 0)
|
|
543
|
-
? h('div', { style: {
|
|
603
|
+
? h('div', { style: { display: 'flex', gap: 8, justifyContent: 'center', marginTop: 14 } },
|
|
544
604
|
h('button', { onClick: loadMoreWorks, disabled: Boolean(busy) },
|
|
545
|
-
`显示更多(已显示 ${items.length} / 共 ${browse.total})`)
|
|
605
|
+
`显示更多(已显示 ${items.length} / 共 ${browse.total})`),
|
|
606
|
+
h('button', { onClick: showAllWorks, disabled: Boolean(busy) },
|
|
607
|
+
`显示全部(${browse.total})`))
|
|
546
608
|
: null);
|
|
547
609
|
}
|
|
548
610
|
|
|
@@ -557,15 +619,21 @@ window.__ModuleLoader__.load({
|
|
|
557
619
|
h('button', { onClick: () => load(), disabled: Boolean(busy) }, '刷新')),
|
|
558
620
|
|
|
559
621
|
state && h('div', { style: { ...panel, display: 'flex', flexWrap: 'wrap', gap: 10, alignItems: 'center', padding: '10px 12px', marginBottom: 12 } },
|
|
560
|
-
h(Pill, { ok: state.mode === 'proxy' }, state.mode === 'proxy' ? '代理模式' : '直连模式'),
|
|
561
|
-
h(
|
|
562
|
-
|
|
622
|
+
h(Pill, { ok: state.mode === 'proxy', warn: state.mode !== 'proxy' }, state.mode === 'proxy' ? '代理模式' : '直连模式'),
|
|
623
|
+
h(Pill, {
|
|
624
|
+
ok: state.mikanOk !== false,
|
|
625
|
+
onClick: () => { setMikanBaseInput(state?.mikanCustom || ''); setDialog({ type: 'mikan' }); },
|
|
626
|
+
}, state.mikanOk !== false ? 'Mikan 可用' : 'Mikan 不可用'),
|
|
627
|
+
h(Pill, {
|
|
628
|
+
ok: state.bgm,
|
|
629
|
+
onClick: () => { setBgmBaseInput(state?.bgmCustom || ''); setDialog({ type: 'bgm' }); },
|
|
630
|
+
}, 'bgm ' + (state.bgm ? '可用' : '不可用')),
|
|
563
631
|
h(Pill, {
|
|
564
632
|
ok: state.downloader?.ok,
|
|
565
633
|
onClick: () => setDialog({ type: 'downloader' }),
|
|
566
634
|
}, state.downloader?.ok
|
|
567
635
|
? `${state.downloader?.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet'} 已连接`
|
|
568
|
-
: '
|
|
636
|
+
: '下载器 未连接')),
|
|
569
637
|
|
|
570
638
|
state && !state.downloader?.ok ? h('div', {
|
|
571
639
|
onClick: () => setDialog({ type: 'guide', title: '下载器连接指引' }),
|
|
@@ -573,7 +641,7 @@ window.__ModuleLoader__.load({
|
|
|
573
641
|
...panel, padding: '8px 12px', marginBottom: 12, cursor: 'pointer',
|
|
574
642
|
borderColor: 'var(--dsw-alias-warning, #f08c00)', color: 'var(--dsw-alias-warning, #f08c00)', fontSize: 13,
|
|
575
643
|
},
|
|
576
|
-
}, '⚠
|
|
644
|
+
}, '⚠ 下载器未连接 —— 点击查看配置指引') : null,
|
|
577
645
|
|
|
578
646
|
(() => {
|
|
579
647
|
const count = updateStatus?.count || 0;
|
|
@@ -723,16 +791,58 @@ window.__ModuleLoader__.load({
|
|
|
723
791
|
: h('div', { style: muted }, '加载作品中…'),
|
|
724
792
|
h('div', { style: { ...muted, marginTop: 12 } }, '没有对应语言的作品会置灰。'))) : null,
|
|
725
793
|
|
|
794
|
+
dialog && dialog.type === 'bgm' ? h(Overlay, {
|
|
795
|
+
title: 'bgm 连接', onClose: () => setDialog(null),
|
|
796
|
+
}, h('div', null,
|
|
797
|
+
h('div', { style: { marginBottom: 10, fontSize: 13 } },
|
|
798
|
+
state?.bgm
|
|
799
|
+
? `当前:可用${state.bgmActive ? `(${String(state.bgmActive).replace(/^https?:\/\//, '')})` : ''}`
|
|
800
|
+
: '当前:不可用'),
|
|
801
|
+
h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
|
|
802
|
+
'bgm.tv 用于补全开播日期。官方 API 在大陆需要代理;如果你有国内可达的镜像,填在下面。'),
|
|
803
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
|
|
804
|
+
h('input', {
|
|
805
|
+
value: bgmBaseInput,
|
|
806
|
+
onChange: (e) => setBgmBaseInput(e.target.value),
|
|
807
|
+
placeholder: '自定义 API,留空自动(官方 / api.bgm.lat)',
|
|
808
|
+
style: { flex: 1, minWidth: 240, padding: '6px 8px' },
|
|
809
|
+
}),
|
|
810
|
+
h('button', { onClick: saveBgmBase, disabled: Boolean(busy) }, busy === 'bgm' ? '保存中…' : '保存并检测'),
|
|
811
|
+
h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
|
|
812
|
+
h('div', { style: muted }, '留空则使用官方 api.bgm.tv(需要代理)或内置目录镜像。'),
|
|
813
|
+
)) : null,
|
|
814
|
+
|
|
815
|
+
dialog && dialog.type === 'mikan' ? h(Overlay, {
|
|
816
|
+
title: '蜜柑连接', onClose: () => setDialog(null),
|
|
817
|
+
}, h('div', null,
|
|
818
|
+
h('div', { style: { marginBottom: 10, fontSize: 13 } },
|
|
819
|
+
state?.mikanOk
|
|
820
|
+
? `当前:可达 · ${String(state.mikan || '').replace(/^https?:\/\//, '')}(${state.mikanReason || ''})`
|
|
821
|
+
: '当前:不可达'),
|
|
822
|
+
h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
|
|
823
|
+
'蜜柑的内置域名都在 Cloudflare 后面。部分运营商封锁 Cloudflare 节点时,插件会完全无法获取数据;此时只能通过代理,或在这里填一个可用的自定义镜像。'),
|
|
824
|
+
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
|
|
825
|
+
h('input', {
|
|
826
|
+
value: mikanBaseInput,
|
|
827
|
+
onChange: (e) => setMikanBaseInput(e.target.value),
|
|
828
|
+
placeholder: '自定义镜像,如 https://mirror.example',
|
|
829
|
+
style: { flex: 1, minWidth: 240, padding: '6px 8px' },
|
|
830
|
+
}),
|
|
831
|
+
h('button', { onClick: saveMikanBase, disabled: Boolean(busy) }, busy === 'mikan' ? '保存中…' : '保存并检测'),
|
|
832
|
+
h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
|
|
833
|
+
h('div', { style: muted }, '留空则使用内置域名自动探测(mikanime.tv / mikanani.me)。'),
|
|
834
|
+
)) : null,
|
|
835
|
+
|
|
726
836
|
dialog && dialog.type === 'downloader' ? (() => {
|
|
727
837
|
const dl = state?.downloader || {};
|
|
728
838
|
const typeLabel = dl.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
|
|
729
839
|
let currentPort = '';
|
|
730
840
|
try { currentPort = new URL(dl.base || '').port; } catch { /* unknown */ }
|
|
731
841
|
return h(Overlay, {
|
|
732
|
-
title: '
|
|
842
|
+
title: '下载器', onClose: () => setDialog(null),
|
|
733
843
|
}, h('div', null,
|
|
734
844
|
h('div', { style: { marginBottom: 12, fontSize: 13 } },
|
|
735
|
-
dl.ok ? `当前:${typeLabel} 已连接 · 端口 ${currentPort || '?????'}` : '
|
|
845
|
+
dl.ok ? `当前:${typeLabel} 已连接 · 端口 ${currentPort || '?????'}` : '当前:下载器 未连接'),
|
|
736
846
|
h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 14 } },
|
|
737
847
|
h('button', { onClick: runScan, disabled: Boolean(busy) }, busy === 'scan' ? '检测中…' : '自动检测'),
|
|
738
848
|
h('button', {
|
|
@@ -764,7 +874,7 @@ window.__ModuleLoader__.load({
|
|
|
764
874
|
title: '下载器连接指引', onClose: () => setDialog(null),
|
|
765
875
|
}, h('div', null,
|
|
766
876
|
h('div', { style: { ...muted, marginBottom: 12 } },
|
|
767
|
-
'
|
|
877
|
+
'任选一个下载器开启 Web 接口,然后在插件配置里用 downloader 指定它。'),
|
|
768
878
|
|
|
769
879
|
h('div', { style: { fontWeight: 600, fontSize: 13, marginBottom: 6 } }, 'qBittorrent(端口默认 8080)'),
|
|
770
880
|
h('ol', { style: { paddingLeft: 20, lineHeight: 1.9, fontSize: 13, margin: 0 } },
|
package/docs/DETAIL.md
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
# 蜜柑追番(dsh-mikan)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
把「蜜柑计划的番剧更新」和「P2P 下载器」连起来的半自动追番工具:**自动发现 → 你确认 → 自动下载**。
|
|
4
|
+
|
|
5
|
+
支持 BitComet 与 qBittorrent 两种下载器,可自动检测切换。
|
|
4
6
|
|
|
5
7
|
## 功能
|
|
6
8
|
|
|
7
9
|
| 能力 | 说明 |
|
|
8
10
|
|---|---|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
11
|
+
| 当季浏览 | 按当前月份自动判断季度,按放送星期折叠列出新番 |
|
|
12
|
+
| 往季浏览 | 从近 12 年里选任意季度 |
|
|
13
|
+
| 字幕组浏览 | 番剧 → 字幕组 → 作品,三级懒加载 |
|
|
14
|
+
| 语言分类 | 作品按简体 / 繁体 / 多字幕(垃圾桶)三类标记 |
|
|
15
|
+
| 批量下载 | 全部 / 简中 / 繁中 / 多字幕,数量实时统计,空类置灰 |
|
|
16
|
+
| 订阅管理 | 番剧 + 字幕组(可多组),每组独立水位,运行时增删 |
|
|
17
|
+
| 更新跟进 | 定时抓取,该组出新集才通知,别组进度只作参考 |
|
|
18
|
+
| 追番周历 | 周一~周日分列,卡片显示各组进度 |
|
|
19
|
+
| 静默关注 | 从周表下架但仍接收更新 |
|
|
20
|
+
| 下载执行 | 单集或批量,确认后拼 magnet 调用下载器 |
|
|
16
21
|
|
|
17
22
|
## 环境自适应
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
插件启动时自动探测环境:
|
|
20
25
|
|
|
21
|
-
|
|
|
26
|
+
| 场景 | 蜜柑源 | 开播日源 |
|
|
22
27
|
|---|---|---|
|
|
23
|
-
|
|
|
24
|
-
| 无代理 | `mikanime.tv`(墙内) |
|
|
28
|
+
| 有可用代理 | 优先 `mikanani.me`(墙外) | 官方 bgm API(走代理) |
|
|
29
|
+
| 无代理 | 优先 `mikanime.tv`(墙内) | 社区镜像目录里的 API |
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
- 蜜柑探测结果缓存 5 分钟
|
|
32
|
+
- bgm 镜像目录(`bangumi.wiki/api/v1/mirrors`)缓存 1 小时,镜像不硬编码
|
|
33
|
+
- 探测失败会降级,不会让整个插件报错
|
|
27
34
|
|
|
28
35
|
## 配置
|
|
29
36
|
|
|
@@ -32,33 +39,41 @@
|
|
|
32
39
|
```yaml
|
|
33
40
|
- id: dsh-mikan
|
|
34
41
|
config:
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
downloader: 'qbittorrent'
|
|
43
|
+
qbittorrentBase: 'http://127.0.0.1:8080'
|
|
37
44
|
savePath: 'D:\Downloads\Anime'
|
|
45
|
+
proxy: 'http://127.0.0.1:7890'
|
|
38
46
|
checkIntervalMinutes: 30
|
|
39
47
|
```
|
|
40
48
|
|
|
41
49
|
| 字段 | 默认 | 说明 |
|
|
42
50
|
|---|---|---|
|
|
43
|
-
| `
|
|
44
|
-
| `bitcometBase` | `http://127.0.0.1:10816` |
|
|
51
|
+
| `downloader` | `bitcomet` | 下载器后端:`bitcomet` 或 `qbittorrent` |
|
|
52
|
+
| `bitcometBase` | `http://127.0.0.1:10816` | BitComet WebUI 地址 |
|
|
53
|
+
| `qbittorrentBase` | `http://127.0.0.1:8080` | qBittorrent WebUI 地址 |
|
|
54
|
+
| `qbittorrentUser` / `qbittorrentPassword` | 空 | qB 凭据;localhost 免认证时可留空 |
|
|
55
|
+
| `mikanBase` | 空 | 自定义蜜柑镜像,留空自动探测 |
|
|
56
|
+
| `bgmBase` | 空 | 自定义 bgm API,留空用官方 + 目录镜像 |
|
|
45
57
|
| `savePath` | 空(必填) | 下载保存目录,未设置时下载会被拒绝 |
|
|
58
|
+
| `proxy` | 空 | 本地代理地址,留空走直连 |
|
|
46
59
|
| `checkIntervalMinutes` | 30 | 后台更新检查间隔 |
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
BitComet 的用户名 / 密码会自动从 `%APPDATA%\BitComet\BitComet.xml` 读取,无需填写。
|
|
49
62
|
|
|
50
63
|
## 使用(对话内)
|
|
51
64
|
|
|
52
65
|
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
帮我看看这季有什么新番
|
|
67
|
+
「乱马1/2」有哪些字幕组在做
|
|
68
|
+
追「乱马1/2」,LoliHouse 的
|
|
56
69
|
检查一下有没有更新
|
|
57
|
-
|
|
70
|
+
把这组简中的都下了
|
|
58
71
|
下季度有什么新番,哪天开播
|
|
59
72
|
```
|
|
60
73
|
|
|
61
|
-
##
|
|
74
|
+
## 下载器配置要求
|
|
75
|
+
|
|
76
|
+
**BitComet**
|
|
62
77
|
|
|
63
78
|
1. 远程访问 → 监听端口填固定值(如 10816)
|
|
64
79
|
2. 勾选「启用网页版远程访问」
|
|
@@ -66,11 +81,30 @@
|
|
|
66
81
|
4. 设置用户名 / 密码
|
|
67
82
|
5. 不勾选「执行远程访问操作时显示提示窗口」
|
|
68
83
|
|
|
84
|
+
**qBittorrent**
|
|
85
|
+
|
|
86
|
+
1. 工具 → 选项 → Web UI
|
|
87
|
+
2. 勾选「启用 Web 用户界面」
|
|
88
|
+
3. 端口默认 8080
|
|
89
|
+
4. 设置用户名 / 密码(本机使用可勾「对本地主机跳过身份验证」)
|
|
90
|
+
|
|
91
|
+
## 界面状态
|
|
92
|
+
|
|
93
|
+
状态条上的标签均可点击:
|
|
94
|
+
|
|
95
|
+
| 标签 | 点击后 |
|
|
96
|
+
|---|---|
|
|
97
|
+
| 代理模式(绿)/ 直连模式(黄) | — |
|
|
98
|
+
| Mikan 可用(绿)/ 不可用(红) | 连接详情、自定义镜像、重新检测 |
|
|
99
|
+
| bgm 可用 / 不可用 | 连接详情、自定义 API、重新检测 |
|
|
100
|
+
| 下载器 | 端口扫描结果、切换 BitComet / qBittorrent |
|
|
101
|
+
|
|
69
102
|
## 已知限制
|
|
70
103
|
|
|
71
|
-
1. **无作品的番剧**在蜜柑只有 id/名称/封面,开播日依赖 bgm/AniList;都不可用时标注「未知」,不编造
|
|
104
|
+
1. **无作品的番剧**在蜜柑只有 id/名称/封面,开播日依赖 bgm / AniList;都不可用时标注「未知」,不编造
|
|
72
105
|
2. **剧场版 / OVA 的「放送日期」不可信**(页面显示周日),只用「放送开始」
|
|
73
|
-
3.
|
|
74
|
-
4.
|
|
75
|
-
5.
|
|
106
|
+
3. **运营商封锁 Cloudflare** 时蜜柑会完全不可达(两个内置域名都在 CF 后面),只能走代理或自定义镜像
|
|
107
|
+
4. 下载器的添加 / 删除接口返回值不可靠,一律以任务列表复核结果为准
|
|
108
|
+
5. 插件**不会**自己启动或关闭下载器进程
|
|
76
109
|
6. 后台检查只产生通知,不会自动下载——下载必须由你确认
|
|
110
|
+
7. 特殊集数格式(如「39-下周停播」)可能解析不出集号,但不影响下载
|
package/index.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
import fs from 'node:fs/promises';
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
|
|
16
|
-
import { DEFAULT_CONFIG, MIKAN_INSIDE, MIKAN_OUTSIDE, COMMON_PROXY_PORTS } from './lib/constants.js';
|
|
16
|
+
import { DEFAULT_CONFIG, MIKAN_INSIDE, MIKAN_OUTSIDE, BGM_API, COMMON_PROXY_PORTS } from './lib/constants.js';
|
|
17
|
+
import { fetchBgmMirrors } from './lib/mirrors.js';
|
|
17
18
|
import {
|
|
18
19
|
createMikanClient,
|
|
19
20
|
detectMikanSource,
|
|
@@ -146,23 +147,96 @@ export async function apply(ctx) {
|
|
|
146
147
|
const cfg = await loadConfig();
|
|
147
148
|
if (!force && env && Date.now() - env.at < ENV_TTL && env.proxy === cfg.proxy) return env;
|
|
148
149
|
const proxy = cfg.proxy || '';
|
|
150
|
+
// bgm: a custom base wins. Otherwise try the official API through a proxy,
|
|
151
|
+
// then fall back to whatever the community mirror directory currently lists.
|
|
152
|
+
// Mirrors change over time, so none of them is hard-coded here.
|
|
153
|
+
const customBgm = String(cfg.bgmBase || '').trim().replace(/\/+$/, '');
|
|
154
|
+
const officialBgm = BGM_API.replace(/\/+$/, '');
|
|
149
155
|
let bgmOk = false;
|
|
150
|
-
let bgmReason = '
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
let bgmReason = 'unreachable';
|
|
157
|
+
let bgmBase = customBgm || officialBgm;
|
|
158
|
+
let bgmViaProxy = false;
|
|
159
|
+
|
|
160
|
+
if (customBgm) {
|
|
161
|
+
try {
|
|
162
|
+
const r = await probeProxy(proxy, `${customBgm}/v0/subjects/274243`, 6000);
|
|
163
|
+
if (r.ok) {
|
|
164
|
+
bgmOk = true;
|
|
165
|
+
bgmBase = customBgm;
|
|
166
|
+
bgmViaProxy = Boolean(proxy);
|
|
167
|
+
bgmReason = 'custom';
|
|
168
|
+
} else {
|
|
169
|
+
bgmReason = r.reason || 'unreachable';
|
|
170
|
+
}
|
|
171
|
+
} catch (err) {
|
|
172
|
+
bgmReason = err.message;
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
if (proxy) {
|
|
176
|
+
try {
|
|
177
|
+
const r = await probeProxy(proxy, `${officialBgm}/v0/subjects/274243`, 6000);
|
|
178
|
+
if (r.ok) {
|
|
179
|
+
bgmOk = true;
|
|
180
|
+
bgmBase = officialBgm;
|
|
181
|
+
bgmViaProxy = true;
|
|
182
|
+
bgmReason = 'official';
|
|
183
|
+
} else {
|
|
184
|
+
bgmReason = r.reason || 'unreachable';
|
|
185
|
+
}
|
|
186
|
+
} catch (err) {
|
|
187
|
+
bgmReason = err.message;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!bgmOk) {
|
|
191
|
+
const mirrors = await fetchBgmMirrors(proxy);
|
|
192
|
+
for (const m of mirrors) {
|
|
193
|
+
if (m.base === officialBgm) continue;
|
|
194
|
+
try {
|
|
195
|
+
const r = await probeProxy('', `${m.base}/v0/subjects/274243`, 6000);
|
|
196
|
+
if (r.ok) {
|
|
197
|
+
bgmOk = true;
|
|
198
|
+
bgmBase = m.base;
|
|
199
|
+
bgmViaProxy = false;
|
|
200
|
+
bgmReason = 'mirror';
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
} catch { /* try next */ }
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Last resort on a direct connection: the official API (usually blocked
|
|
207
|
+
// from the mainland, hence only attempted after the mirror directory).
|
|
208
|
+
if (!bgmOk && !proxy) {
|
|
209
|
+
try {
|
|
210
|
+
const r = await probeProxy('', `${officialBgm}/v0/subjects/274243`, 6000);
|
|
211
|
+
if (r.ok) {
|
|
212
|
+
bgmOk = true;
|
|
213
|
+
bgmBase = officialBgm;
|
|
214
|
+
bgmViaProxy = false;
|
|
215
|
+
bgmReason = 'official-direct';
|
|
216
|
+
} else {
|
|
217
|
+
bgmReason = r.reason || 'unreachable';
|
|
218
|
+
}
|
|
219
|
+
} catch (err) {
|
|
220
|
+
bgmReason = err.message;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
155
223
|
}
|
|
156
|
-
|
|
224
|
+
|
|
225
|
+
const mikan = await detectMikanSource({ proxy: bgmViaProxy ? proxy : '', customBase: cfg.mikanBase || '' });
|
|
157
226
|
env = {
|
|
158
227
|
at: Date.now(),
|
|
159
228
|
proxy,
|
|
160
229
|
bgmOk,
|
|
161
230
|
bgmReason,
|
|
231
|
+
bgmBase,
|
|
232
|
+
bgmViaProxy,
|
|
162
233
|
mikanBase: mikan.base,
|
|
163
234
|
mikanViaProxy: mikan.viaProxy,
|
|
164
235
|
mikanReason: mikan.reason,
|
|
165
|
-
|
|
236
|
+
mikanOk: mikan.reason !== 'all-probes-failed',
|
|
237
|
+
// "proxy" means the proxy actually carried a request, not that bgm happened
|
|
238
|
+
// to be reachable through a direct mirror.
|
|
239
|
+
mode: (bgmViaProxy || mikan.viaProxy) ? 'proxy' : 'direct',
|
|
166
240
|
};
|
|
167
241
|
logger?.info?.(`[dsh-mikan] env=${env.mode} mikan=${env.mikanBase} bgm=${bgmOk}`);
|
|
168
242
|
return env;
|
|
@@ -315,7 +389,7 @@ export async function apply(ctx) {
|
|
|
315
389
|
} catch { /* keep the fallback */ }
|
|
316
390
|
if (!info.startDate) {
|
|
317
391
|
try {
|
|
318
|
-
const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: cfg.proxy, year: new Date().getFullYear() });
|
|
392
|
+
const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year: new Date().getFullYear() });
|
|
319
393
|
if (r.ok) { info.airDate = r.airDate; info.airSource = r.source || ''; }
|
|
320
394
|
} catch { /* unknown */ }
|
|
321
395
|
}
|
|
@@ -395,7 +469,7 @@ export async function apply(ctx) {
|
|
|
395
469
|
|
|
396
470
|
ctx.tools.register(defineTool({
|
|
397
471
|
name: 'mikan_status',
|
|
398
|
-
description: 'Report the current Mikan environment: proxy reachability, chosen mirror domain, air-date fallback availability, and
|
|
472
|
+
description: 'Report the current Mikan environment: proxy reachability, chosen mirror domain, air-date fallback availability, and downloader connection state.',
|
|
399
473
|
parameters: {
|
|
400
474
|
type: 'object',
|
|
401
475
|
properties: {
|
|
@@ -432,6 +506,8 @@ export async function apply(ctx) {
|
|
|
432
506
|
qbittorrentBase: { type: 'string', description: 'qBittorrent WebUI base URL.' },
|
|
433
507
|
qbittorrentUser: { type: 'string', description: 'qBittorrent username.' },
|
|
434
508
|
qbittorrentPassword: { type: 'string', description: 'qBittorrent password.' },
|
|
509
|
+
mikanBase: { type: 'string', description: 'Custom Mikan mirror base URL. Empty means auto-detect between built-ins.' },
|
|
510
|
+
bgmBase: { type: 'string', description: 'Custom bgm.tv API base. Empty means official api.bgm.tv, then mirrors from the community directory.' },
|
|
435
511
|
savePath: { type: 'string', description: 'Default download directory inside the downloader.' },
|
|
436
512
|
checkIntervalMinutes: { type: 'number', description: 'Background check interval in minutes.' },
|
|
437
513
|
},
|
|
@@ -440,7 +516,7 @@ export async function apply(ctx) {
|
|
|
440
516
|
output: { schema: OBJ, render: renderJson },
|
|
441
517
|
async execute(args) {
|
|
442
518
|
const patch = {};
|
|
443
|
-
for (const key of ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'savePath', 'checkIntervalMinutes']) {
|
|
519
|
+
for (const key of ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'mikanBase', 'bgmBase', 'savePath', 'checkIntervalMinutes']) {
|
|
444
520
|
if (args?.[key] !== undefined) patch[key] = args[key];
|
|
445
521
|
}
|
|
446
522
|
if (Object.keys(patch).length === 0) return { config: await loadConfig(), changed: false };
|
|
@@ -543,7 +619,7 @@ export async function apply(ctx) {
|
|
|
543
619
|
|
|
544
620
|
ctx.tools.register(defineTool({
|
|
545
621
|
name: 'mikan_download',
|
|
546
|
-
description: 'Send releases to the configured
|
|
622
|
+
description: 'Send releases to the configured downloader by 40-character info hash (full magnet URIs are also accepted). The downloader reports unreliable status, so the task list is verified afterwards.',
|
|
547
623
|
parameters: {
|
|
548
624
|
type: 'object',
|
|
549
625
|
properties: {
|
|
@@ -629,15 +705,21 @@ export async function apply(ctx) {
|
|
|
629
705
|
const route = u.pathname.slice('/dsh-mikan'.length);
|
|
630
706
|
try {
|
|
631
707
|
if (route === '/state' && req.method === 'GET') {
|
|
632
|
-
const e = await detectEnv();
|
|
708
|
+
const e = await detectEnv(u.searchParams.get('refresh') === '1');
|
|
633
709
|
const cfg = await loadConfig();
|
|
634
710
|
const dl = await downloaderInfo();
|
|
635
711
|
return send(res, 200, {
|
|
636
712
|
mode: e.mode,
|
|
637
713
|
proxy: e.proxy,
|
|
638
714
|
bgm: e.bgmOk,
|
|
715
|
+
bgmReason: e.bgmReason,
|
|
716
|
+
bgmActive: e.bgmBase,
|
|
717
|
+
bgmCustom: cfg.bgmBase || '',
|
|
639
718
|
mikan: e.mikanBase,
|
|
640
719
|
mikanViaProxy: e.mikanViaProxy,
|
|
720
|
+
mikanOk: e.mikanOk,
|
|
721
|
+
mikanReason: e.mikanReason,
|
|
722
|
+
mikanCustom: cfg.mikanBase || '',
|
|
641
723
|
downloader: dl,
|
|
642
724
|
savePath: cfg.savePath,
|
|
643
725
|
checkIntervalMinutes: cfg.checkIntervalMinutes,
|
|
@@ -770,7 +852,7 @@ export async function apply(ctx) {
|
|
|
770
852
|
}
|
|
771
853
|
return send(res, 200, {
|
|
772
854
|
ok: false,
|
|
773
|
-
reason: '
|
|
855
|
+
reason: '未找到可用的下载器(qBittorrent 和 BitComet 都试过了)',
|
|
774
856
|
tried,
|
|
775
857
|
});
|
|
776
858
|
}
|
|
@@ -788,7 +870,7 @@ export async function apply(ctx) {
|
|
|
788
870
|
const rows = await mapLimit(flat, 8, async ({ item, group }) => {
|
|
789
871
|
let air = { ok: false };
|
|
790
872
|
try {
|
|
791
|
-
air = await resolveAirDate({ names: [item.title], proxy: cfg.proxy, year });
|
|
873
|
+
air = await resolveAirDate({ names: [item.title], proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year });
|
|
792
874
|
} catch { /* ignore */ }
|
|
793
875
|
const airDate = air.ok ? air.airDate : '';
|
|
794
876
|
const state = airDate
|
|
@@ -849,7 +931,7 @@ export async function apply(ctx) {
|
|
|
849
931
|
let airSource = '';
|
|
850
932
|
if (!info.startDate) {
|
|
851
933
|
try {
|
|
852
|
-
const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: cfg.proxy, year: new Date().getFullYear() });
|
|
934
|
+
const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year: new Date().getFullYear() });
|
|
853
935
|
if (r.ok) { airDate = r.airDate; airSource = r.source; }
|
|
854
936
|
} catch { /* unknown */ }
|
|
855
937
|
}
|
|
@@ -949,7 +1031,7 @@ export async function apply(ctx) {
|
|
|
949
1031
|
}
|
|
950
1032
|
if (route === '/config' && req.method === 'POST') {
|
|
951
1033
|
const body = await readBody(req);
|
|
952
|
-
const allowed = ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'savePath', 'checkIntervalMinutes'];
|
|
1034
|
+
const allowed = ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'mikanBase', 'bgmBase', 'savePath', 'checkIntervalMinutes'];
|
|
953
1035
|
const patch = {};
|
|
954
1036
|
for (const key of allowed) {
|
|
955
1037
|
if (body[key] !== undefined) patch[key] = body[key];
|
package/lib/airdate.js
CHANGED
|
@@ -156,7 +156,7 @@ export async function searchBgm(keyword, opts = {}) {
|
|
|
156
156
|
const name = typeof keyword === 'string' ? keyword.trim() : '';
|
|
157
157
|
if (name === '') return { ok: false, results: [], reason: '搜索关键词为空' };
|
|
158
158
|
const timeout = Number(opts.timeout) > 0 ? Number(opts.timeout) : DEFAULT_TIMEOUT;
|
|
159
|
-
const url = `${BGM_API}/search/subject/${encodeURIComponent(name)}?type=2&responseGroup=large`;
|
|
159
|
+
const url = `${opts.base || BGM_API}/search/subject/${encodeURIComponent(name)}?type=2&responseGroup=large`;
|
|
160
160
|
|
|
161
161
|
let response;
|
|
162
162
|
try {
|
|
@@ -370,9 +370,10 @@ export async function resolveAirDate(options = {}) {
|
|
|
370
370
|
const proxy = options?.proxy;
|
|
371
371
|
const notes = [];
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
const bgmBase = typeof options?.bgmBase === 'string' ? options.bgmBase.trim() : '';
|
|
374
|
+
if (hasProxy(proxy) || bgmBase) {
|
|
374
375
|
for (const name of candidates) {
|
|
375
|
-
const res = await searchBgm(name, { proxy, timeout });
|
|
376
|
+
const res = await searchBgm(name, { proxy, timeout, base: bgmBase });
|
|
376
377
|
if (!res.ok) {
|
|
377
378
|
notes.push(`bgm「${name}」:${res.reason}`);
|
|
378
379
|
// A network-level failure will hit every name the same way; stop early.
|
package/lib/constants.js
CHANGED
|
@@ -38,6 +38,10 @@ export const DEFAULT_CONFIG = {
|
|
|
38
38
|
qbittorrentBase: 'http://127.0.0.1:8080',
|
|
39
39
|
qbittorrentUser: '',
|
|
40
40
|
qbittorrentPassword: '',
|
|
41
|
+
/** Optional custom Mikan mirror; empty means auto-detect between built-ins. */
|
|
42
|
+
mikanBase: '',
|
|
43
|
+
/** Optional custom bgm.tv API base; empty means the official api.bgm.tv. */
|
|
44
|
+
bgmBase: '',
|
|
41
45
|
/** Download directory inside the downloader; must be set before downloading. */
|
|
42
46
|
savePath: '',
|
|
43
47
|
/** Minutes between automatic update checks. */
|
package/lib/mikan.js
CHANGED
|
@@ -43,13 +43,18 @@ export function createMikanClient({ base = MIKAN_INSIDE, proxy = '' } = {}) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Pick the reachable mirror.
|
|
47
|
-
* the
|
|
46
|
+
* Pick the reachable mirror. A custom mirror wins when configured; otherwise it
|
|
47
|
+
* tries the outside domain through the proxy, then the inside domain directly,
|
|
48
|
+
* then the outside domain directly.
|
|
48
49
|
* @returns {Promise<{base:string, viaProxy:boolean, reason:string}>}
|
|
49
50
|
*/
|
|
50
|
-
export async function detectMikanSource({ proxy = '' } = {}) {
|
|
51
|
+
export async function detectMikanSource({ proxy = '', customBase = '' } = {}) {
|
|
51
52
|
const probe = { proxy, timeout: 8000 };
|
|
52
53
|
const attempts = [];
|
|
54
|
+
if (customBase) {
|
|
55
|
+
attempts.push({ base: customBase.replace(/\/+$/, ''), proxy: '', label: 'custom-direct' });
|
|
56
|
+
if (proxy) attempts.push({ base: customBase.replace(/\/+$/, ''), proxy, label: 'custom+proxy' });
|
|
57
|
+
}
|
|
53
58
|
if (proxy) attempts.push({ base: MIKAN_OUTSIDE, proxy, label: 'outside+proxy' });
|
|
54
59
|
attempts.push({ base: MIKAN_INSIDE, proxy: '', label: 'inside-direct' });
|
|
55
60
|
if (proxy) attempts.push({ base: MIKAN_OUTSIDE, proxy: '', label: 'outside-direct' });
|
|
@@ -63,7 +68,7 @@ export async function detectMikanSource({ proxy = '' } = {}) {
|
|
|
63
68
|
/* try next */
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
|
-
return { base: MIKAN_INSIDE, viaProxy: false, reason: 'all-probes-failed' };
|
|
71
|
+
return { base: customBase || MIKAN_INSIDE, viaProxy: false, reason: 'all-probes-failed' };
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
/** Extract the 40-char info hash from an Episode link. */
|
package/lib/mirrors.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Community Bangumi mirror directory.
|
|
3
|
+
*
|
|
4
|
+
* https://bangumi.wiki/api/v1/mirrors lists mirrors of the main site along with
|
|
5
|
+
* the services each one exposes (`main`, `next`, `api`, `lain`, `doujin`). Only
|
|
6
|
+
* entries that carry an `api` service are useful here, because the plugin talks
|
|
7
|
+
* to the v0 / search API rather than the website.
|
|
8
|
+
*
|
|
9
|
+
* The directory itself is a third party; a failure to fetch it never becomes an
|
|
10
|
+
* error, it just means no extra candidates are offered.
|
|
11
|
+
*/
|
|
12
|
+
import { fetchText } from './net.js';
|
|
13
|
+
|
|
14
|
+
const DIRECTORY_URL = 'https://bangumi.wiki/api/v1/mirrors';
|
|
15
|
+
const CACHE_TTL = 60 * 60 * 1000;
|
|
16
|
+
|
|
17
|
+
let cache = { at: 0, list: [] };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Return mirrors that expose an `api` service, highest weight first.
|
|
21
|
+
* Cached for an hour; failures fall back to the previous cached list.
|
|
22
|
+
* @param {string} [proxy]
|
|
23
|
+
* @returns {Promise<Array<{name:string, base:string, weight:number, recommended:boolean}>>}
|
|
24
|
+
*/
|
|
25
|
+
export async function fetchBgmMirrors(proxy = '') {
|
|
26
|
+
if (Date.now() - cache.at < CACHE_TTL && cache.list.length > 0) return cache.list;
|
|
27
|
+
try {
|
|
28
|
+
// The directory itself is directly reachable; only fall back to the proxy
|
|
29
|
+
// when a direct attempt fails (a configured-but-dead proxy must not block it).
|
|
30
|
+
let res;
|
|
31
|
+
try {
|
|
32
|
+
res = await fetchText(DIRECTORY_URL, { timeout: 8000 });
|
|
33
|
+
} catch {
|
|
34
|
+
res = await fetchText(DIRECTORY_URL, { proxy, timeout: 8000 });
|
|
35
|
+
}
|
|
36
|
+
if (res.status !== 200) return cache.list;
|
|
37
|
+
const data = JSON.parse(res.body);
|
|
38
|
+
const list = [];
|
|
39
|
+
for (const mirror of Array.isArray(data?.mirrors) ? data.mirrors : []) {
|
|
40
|
+
for (const service of Array.isArray(mirror?.services) ? mirror.services : []) {
|
|
41
|
+
if (service?.id !== 'api') continue;
|
|
42
|
+
const host = Array.isArray(service.hosts) && service.hosts[0];
|
|
43
|
+
if (!host) continue;
|
|
44
|
+
list.push({
|
|
45
|
+
name: mirror.name || host,
|
|
46
|
+
base: `https://${host}`,
|
|
47
|
+
weight: Number(mirror.weight) || 0,
|
|
48
|
+
recommended: Boolean(mirror.recommended),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
list.sort((a, b) => b.weight - a.weight);
|
|
53
|
+
cache = { at: Date.now(), list };
|
|
54
|
+
return list;
|
|
55
|
+
} catch {
|
|
56
|
+
return cache.list;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mikan",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "Mikan Project tracker
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Mikan Project tracker for DeepSeek Harness: browse current and past seasons, follow subgroups, and send confirmed releases to BitComet or qBittorrent.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "琉璃羽Ryuribana",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"mikan",
|
|
13
13
|
"anime",
|
|
14
14
|
"bitcomet",
|
|
15
|
+
"qbittorrent",
|
|
15
16
|
"rss"
|
|
16
17
|
],
|
|
17
18
|
"exports": {
|