dsh-mikan 0.2.0 → 0.2.2

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 CHANGED
@@ -1,5 +1,34 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### 新增
6
+
7
+ - **Nyaa 源检测预留**:状态条新增「Nyaa 可用 / 不可用」,可点击查看连接状态、填写自定义镜像、重新检测
8
+ - 检测优先级与 Bangumi 一致:有代理时优先官方主站,直连时优先镜像
9
+ - 配置项 `nyaaBase` 支持自定义镜像
10
+ - 资源接入计划在 0.3.0
11
+
12
+ ### 文档
13
+
14
+ - `docs/DETAIL.md` 精简:移除配置表与对话示例,功能表改用纯功能描述
15
+ - 统一「下载器」表述,不再出现「P2P 下载器」
16
+
17
+ ## 0.2.1
18
+
19
+ ### 新增
20
+
21
+ - **蜜柑可达性提示**:状态条上的蜜柑来源改为带色块的状态标签,探测失败时显示为红色(此前只显示域名,连不上也看不出来)
22
+ - **自定义镜像域名**:配置项 `mikanBase` / `bgmBase` 可填入自建或第三方镜像;留空则自动探测
23
+ - **bgm 镜像目录**:内置社区维护的 Bangumi 镜像目录(`bangumi.wiki/api/v1/mirrors`),官方 API 不可达时自动从目录里挑一个可用的 API 镜像,结果缓存 1 小时
24
+ - **镜像不硬编码**:目录会持续变化,插件只硬编码目录入口,具体镜像每次从目录读取
25
+
26
+ ### 背景
27
+
28
+ 部分运营商(如安徽联通的部分地区)封锁了 Cloudflare 节点,而 mikan 的两个域名都在 Cloudflare 后面,会导致插件完全无法获取数据。`mikanBase` 提供了绕开内置域名的途径;没有可用镜像时,仍然只能通过代理访问。
29
+
30
+ bgm.tv 官方 API 在大陆同样需要代理,但社区镜像通常可以直连,因此插件改用「官方优先、目录镜像兜底」的策略,无代理用户也能补全开播日期。
31
+
3
32
  ## 0.2.0
4
33
 
5
34
  ### 新增
@@ -28,7 +57,7 @@
28
57
  ### 优化
29
58
 
30
59
  - 工具默认返回条数 60 → 30,单次约省一半 token
31
- - 下载器状态统一称「P2P 下载器」,未连接时不再区分具体软件
60
+ - 下载器状态统一称「下载器」,未连接时不再区分具体软件
32
61
  - 连接指引同时展示 BitComet 与 qBittorrent 两套步骤
33
62
  - 移除本地调试残留(硬编码路径、调试日志)
34
63
 
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
- - 对话工具:检索、订阅、检查更新、按 hash 下载
6
+ - 作品按语言分类(简体 / 繁体 / 多字幕),支持单集与批量下载
7
+ - 对话工具:浏览、订阅、检查更新、按 hash 下载
7
8
  - 半自动:只通知你,下载永远由你确认
8
9
 
9
10
  ## 安装
@@ -20,12 +21,13 @@ dsh plugin --profile web add dsh-mikan
20
21
 
21
22
  打开「追番」:
22
23
 
23
- 1. **浏览季度** → 按放送星期折叠列出当季新番(只标题,点开才加载)
24
- 2. 点某部番 → 看开播日和做这部番的字幕组
25
- 3. 点某个字幕组 → 看它的作品列表,可「订阅本组」或直接下载
26
- 4. 订阅后出现在周历,卡片显示 `字幕组 已到 X / 全番 Y`
24
+ 1. **当季浏览**:按当前月份自动判断季度,按放送星期折叠列出新番
25
+ 2. **往季浏览**:从近 12 年里选任意季度
26
+ 3. 点某部番 → 看开播日和做这部番的字幕组
27
+ 4. 点某个字幕组 → 看它的作品列表,带语言标签,可「订阅本组」或按语言批量下载
28
+ 5. 订阅后出现在周历,卡片显示 `字幕组 已到 X / 全番 Y`
27
29
 
28
- 订阅只跟**指定字幕组**:该组出新集才通知,别组的进度只作参考(全番最新)。
30
+ 订阅只跟**指定字幕组**:该组出新集才通知。
29
31
 
30
32
  ## 配置
31
33
 
@@ -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` | 空 | 自定义 Bangumi 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
- 启动时自动探测:有可用代理 → 走墙外 `mikanani.me` + bgm.tv 补开播日;否则走墙内 `mikanime.tv` + AniList 兜底。
71
+ - **蜜柑镜像**:自动探测墙内 `mikanime.tv` 与墙外 `mikanani.me`,优先使用可用的一方
72
+ - **作品列表**:走 `/Home/ExpandEpisodeTable`,不受 RSS 单组 100 条限制
73
+ - **开播日**:有代理时优先官方 Bangumi API,直连时优先社区镜像目录(`bangumi.wiki/api/v1/mirrors`,缓存 1 小时)
74
+ - **更新检查**:RSS(最近 100 条足够覆盖新集)
75
+
76
+ ## 界面状态
77
+
78
+ 状态条上的标签可点击:
79
+
80
+ | 标签 | 点击后 |
81
+ |---|---|
82
+ | 代理模式 / 直连模式 | — |
83
+ | Mikan 可用 / 不可用 | 查看连接详情、填自定义镜像、重新检测 |
84
+ | Bangumi 可用 / 不可用 | 同上 |
85
+ | 下载器 | 端口扫描结果、切换 BitComet / qBittorrent |
68
86
 
69
87
  ## 已知限制
70
88
 
71
- - 没有字幕组做的番剧只有标题,开播日依赖 bgm/AniList,都不可用时显示未知
72
- - 剧场版/OVA 的「放送日期」字段不可信,只用「放送开始」
73
- - 全站 RSS 单次最多 100 条,订阅多时靠单番 RSS 补漏
74
- - 比特彗星的添加/删除接口返回值不可靠,一律以任务列表复核
75
- - 插件不会自己启动或关闭比特彗星
89
+ - 没有字幕组做的番剧只有标题,开播日依赖 Bangumi / 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: ok ? 'var(--dsw-alias-success, #2f9e44)' : 'var(--dsw-alias-danger, #e03131)',
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,9 @@ 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('');
127
+ const [nyaaBaseInput, setNyaaBaseInput] = useState('');
122
128
 
123
129
  const load = useCallback(async ({ autoCheck = false } = {}) => {
124
130
  try {
@@ -300,8 +306,8 @@ window.__ModuleLoader__.load({
300
306
  subgroupId: subgroup.subgroupId, subgroupName: subgroup.name, loading: true, works: [],
301
307
  }));
302
308
  try {
303
- const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=60`);
304
- setBrowse((b) => ({ ...b, loading: false, works: r.items || [], total: r.total || 0, limit: 60, counts: r.counts || null }));
309
+ const r = await getJson(`/works?bangumiId=${encodeURIComponent(id)}&subgroupId=${encodeURIComponent(subgroup.subgroupId || '')}&subgroupName=${encodeURIComponent(subgroup.name || '')}&limit=30`);
310
+ setBrowse((b) => ({ ...b, loading: false, works: r.items || [], total: r.total || 0, limit: 30, counts: r.counts || null }));
305
311
  } catch (e) {
306
312
  setBrowse((b) => ({ ...b, loading: false, works: [], error: e.message }));
307
313
  }
@@ -333,7 +339,7 @@ window.__ModuleLoader__.load({
333
339
 
334
340
  const loadMoreWorks = useCallback(async () => {
335
341
  if (!browse) return;
336
- const next = Math.min((browse.limit || 60) + 60, browse.total || 0);
342
+ const next = Math.min((browse.limit || 30) + 30, browse.total || 0);
337
343
  try {
338
344
  const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=${next}`);
339
345
  setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: next }));
@@ -342,6 +348,16 @@ window.__ModuleLoader__.load({
342
348
  }
343
349
  }, [browse]);
344
350
 
351
+ const showAllWorks = useCallback(async () => {
352
+ if (!browse) return;
353
+ try {
354
+ const r = await getJson(`/works?bangumiId=${encodeURIComponent(browse.bangumiId)}&subgroupId=${encodeURIComponent(browse.subgroupId || '')}&subgroupName=${encodeURIComponent(browse.subgroupName || '')}&limit=500`);
355
+ setBrowse((b) => ({ ...b, works: r.items || [], total: r.total || 0, limit: r.displayed || 500 }));
356
+ } catch (e) {
357
+ setNotice('加载失败:' + e.message);
358
+ }
359
+ }, [browse]);
360
+
345
361
  const openBatch = useCallback(async (bangumiId, title, subgroup, ctx) => {
346
362
  setBatchTarget({
347
363
  bangumiId,
@@ -389,6 +405,65 @@ window.__ModuleLoader__.load({
389
405
  }
390
406
  }, [batchStats]);
391
407
 
408
+ const refreshEnv = useCallback(async () => {
409
+ setBusy('env');
410
+ try {
411
+ const r = await getJson('/state?refresh=1');
412
+ setState(r);
413
+ setNotice(r.mikanOk
414
+ ? `蜜柑可达:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
415
+ : '蜜柑不可达,请检查网络或配置镜像');
416
+ } catch (e) {
417
+ setNotice('检测失败:' + e.message);
418
+ } finally {
419
+ setBusy('');
420
+ }
421
+ }, []);
422
+
423
+ const saveMikanBase = useCallback(async () => {
424
+ setBusy('mikan');
425
+ try {
426
+ await postJson('/config', { mikanBase: mikanBaseInput.trim() });
427
+ const r = await getJson('/state?refresh=1');
428
+ setState(r);
429
+ setNotice(r.mikanOk
430
+ ? `已保存并连接:${String(r.mikan || '').replace(/^https?:\/\//, '')}`
431
+ : '已保存,但该镜像当前不可达');
432
+ } catch (e) {
433
+ setNotice('保存失败:' + e.message);
434
+ } finally {
435
+ setBusy('');
436
+ }
437
+ }, [mikanBaseInput]);
438
+
439
+ const saveBgmBase = useCallback(async () => {
440
+ setBusy('bgm');
441
+ try {
442
+ await postJson('/config', { bgmBase: bgmBaseInput.trim() });
443
+ const r = await getJson('/state?refresh=1');
444
+ setState(r);
445
+ setNotice(r.bgm ? 'Bangumi 已连接' : 'Bangumi 不可用(需要代理,或填一个国内可达的镜像)');
446
+ } catch (e) {
447
+ setNotice('保存失败:' + e.message);
448
+ } finally {
449
+ setBusy('');
450
+ }
451
+ }, [bgmBaseInput]);
452
+
453
+ const saveNyaaBase = useCallback(async () => {
454
+ setBusy('nyaa');
455
+ try {
456
+ await postJson('/config', { nyaaBase: nyaaBaseInput.trim() });
457
+ const r = await getJson('/state?refresh=1');
458
+ setState(r);
459
+ setNotice(r.nyaa ? 'Nyaa 已连接' : 'Nyaa 不可用(需要代理,或填一个可用的镜像)');
460
+ } catch (e) {
461
+ setNotice('保存失败:' + e.message);
462
+ } finally {
463
+ setBusy('');
464
+ }
465
+ }, [nyaaBaseInput]);
466
+
392
467
  /* ---------- render ---------- */
393
468
 
394
469
  if (error) {
@@ -540,9 +615,11 @@ window.__ModuleLoader__.load({
540
615
  : g.items.map(renderWorkItem)))
541
616
  : items.map(renderWorkItem)))),
542
617
  items.length > 0 && items.length < (browse.total || 0)
543
- ? h('div', { style: { textAlign: 'center', marginTop: 14 } },
618
+ ? h('div', { style: { display: 'flex', gap: 8, justifyContent: 'center', marginTop: 14 } },
544
619
  h('button', { onClick: loadMoreWorks, disabled: Boolean(busy) },
545
- `显示更多(已显示 ${items.length} / 共 ${browse.total})`))
620
+ `显示更多(已显示 ${items.length} / 共 ${browse.total})`),
621
+ h('button', { onClick: showAllWorks, disabled: Boolean(busy) },
622
+ `显示全部(${browse.total})`))
546
623
  : null);
547
624
  }
548
625
 
@@ -557,15 +634,25 @@ window.__ModuleLoader__.load({
557
634
  h('button', { onClick: () => load(), disabled: Boolean(busy) }, '刷新')),
558
635
 
559
636
  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('span', { style: muted }, '蜜柑 ' + String(state.mikan || '').replace(/^https?:\/\//, '')),
562
- h(Pill, { ok: state.bgm }, 'bgm ' + (state.bgm ? '可用' : '不可用')),
637
+ h(Pill, { ok: state.mode === 'proxy', warn: state.mode !== 'proxy' }, state.mode === 'proxy' ? '代理模式' : '直连模式'),
638
+ h(Pill, {
639
+ ok: state.mikanOk !== false,
640
+ onClick: () => { setMikanBaseInput(state?.mikanCustom || ''); setDialog({ type: 'mikan' }); },
641
+ }, state.mikanOk !== false ? 'Mikan 可用' : 'Mikan 不可用'),
642
+ h(Pill, {
643
+ ok: state.bgm,
644
+ onClick: () => { setBgmBaseInput(state?.bgmCustom || ''); setDialog({ type: 'bgm' }); },
645
+ }, 'Bangumi ' + (state.bgm ? '可用' : '不可用')),
646
+ h(Pill, {
647
+ ok: state.nyaa,
648
+ onClick: () => { setNyaaBaseInput(state?.nyaaCustom || ''); setDialog({ type: 'nyaa' }); },
649
+ }, 'Nyaa ' + (state.nyaa ? '可用' : '不可用')),
563
650
  h(Pill, {
564
651
  ok: state.downloader?.ok,
565
652
  onClick: () => setDialog({ type: 'downloader' }),
566
653
  }, state.downloader?.ok
567
654
  ? `${state.downloader?.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet'} 已连接`
568
- : 'P2P 下载器 未连接')),
655
+ : '下载器 未连接')),
569
656
 
570
657
  state && !state.downloader?.ok ? h('div', {
571
658
  onClick: () => setDialog({ type: 'guide', title: '下载器连接指引' }),
@@ -573,7 +660,7 @@ window.__ModuleLoader__.load({
573
660
  ...panel, padding: '8px 12px', marginBottom: 12, cursor: 'pointer',
574
661
  borderColor: 'var(--dsw-alias-warning, #f08c00)', color: 'var(--dsw-alias-warning, #f08c00)', fontSize: 13,
575
662
  },
576
- }, '⚠ P2P 下载器未连接 —— 点击查看配置指引') : null,
663
+ }, '⚠ 下载器未连接 —— 点击查看配置指引') : null,
577
664
 
578
665
  (() => {
579
666
  const count = updateStatus?.count || 0;
@@ -723,16 +810,79 @@ window.__ModuleLoader__.load({
723
810
  : h('div', { style: muted }, '加载作品中…'),
724
811
  h('div', { style: { ...muted, marginTop: 12 } }, '没有对应语言的作品会置灰。'))) : null,
725
812
 
813
+ dialog && dialog.type === 'nyaa' ? h(Overlay, {
814
+ title: 'Nyaa 连接', onClose: () => setDialog(null),
815
+ }, h('div', null,
816
+ h('div', { style: { marginBottom: 10, fontSize: 13 } },
817
+ state?.nyaa
818
+ ? `当前:可用${state.nyaaActive ? `(${String(state.nyaaActive).replace(/^https?:\/\//, '')})` : ''}`
819
+ : '当前:不可用'),
820
+ h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
821
+ 'Nyaa 官方主站在墙外,直连通常无法访问。有代理时优先连主站,否则优先用镜像。'),
822
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
823
+ h('input', {
824
+ value: nyaaBaseInput,
825
+ onChange: (e) => setNyaaBaseInput(e.target.value),
826
+ placeholder: '自定义镜像,如 https://nyaa.example',
827
+ style: { flex: 1, minWidth: 240, padding: '6px 8px' },
828
+ }),
829
+ h('button', { onClick: saveNyaaBase, disabled: Boolean(busy) }, busy === 'nyaa' ? '保存中…' : '保存并检测'),
830
+ h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
831
+ h('div', { style: muted }, '留空则使用官方 nyaa.si(需要代理)。'),
832
+ )) : null,
833
+
834
+ dialog && dialog.type === 'bgm' ? h(Overlay, {
835
+ title: 'Bangumi 连接', onClose: () => setDialog(null),
836
+ }, h('div', null,
837
+ h('div', { style: { marginBottom: 10, fontSize: 13 } },
838
+ state?.bgm
839
+ ? `当前:可用${state.bgmActive ? `(${String(state.bgmActive).replace(/^https?:\/\//, '')})` : ''}`
840
+ : '当前:不可用'),
841
+ h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
842
+ 'Bangumi 用于补全开播日期。官方 API 在大陆需要代理;如果你有国内可达的镜像,填在下面。'),
843
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
844
+ h('input', {
845
+ value: bgmBaseInput,
846
+ onChange: (e) => setBgmBaseInput(e.target.value),
847
+ placeholder: '自定义 API,留空自动选择',
848
+ style: { flex: 1, minWidth: 240, padding: '6px 8px' },
849
+ }),
850
+ h('button', { onClick: saveBgmBase, disabled: Boolean(busy) }, busy === 'bgm' ? '保存中…' : '保存并检测'),
851
+ h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
852
+ h('div', { style: muted }, '留空则使用官方 api.bgm.tv(需要代理)或内置目录镜像。'),
853
+ )) : null,
854
+
855
+ dialog && dialog.type === 'mikan' ? h(Overlay, {
856
+ title: '蜜柑连接', onClose: () => setDialog(null),
857
+ }, h('div', null,
858
+ h('div', { style: { marginBottom: 10, fontSize: 13 } },
859
+ state?.mikanOk
860
+ ? `当前:可达 · ${String(state.mikan || '').replace(/^https?:\/\//, '')}(${state.mikanReason || ''})`
861
+ : '当前:不可达'),
862
+ h('div', { style: { ...muted, marginBottom: 12, lineHeight: 1.7 } },
863
+ '蜜柑的内置域名都在 Cloudflare 后面。部分运营商封锁 Cloudflare 节点时,插件会完全无法获取数据;此时只能通过代理,或在这里填一个可用的自定义镜像。'),
864
+ h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 10 } },
865
+ h('input', {
866
+ value: mikanBaseInput,
867
+ onChange: (e) => setMikanBaseInput(e.target.value),
868
+ placeholder: '自定义镜像,如 https://mirror.example',
869
+ style: { flex: 1, minWidth: 240, padding: '6px 8px' },
870
+ }),
871
+ h('button', { onClick: saveMikanBase, disabled: Boolean(busy) }, busy === 'mikan' ? '保存中…' : '保存并检测'),
872
+ h('button', { onClick: refreshEnv, disabled: Boolean(busy) }, busy === 'env' ? '检测中…' : '重新检测')),
873
+ h('div', { style: muted }, '留空则使用内置域名自动探测(mikanime.tv / mikanani.me)。'),
874
+ )) : null,
875
+
726
876
  dialog && dialog.type === 'downloader' ? (() => {
727
877
  const dl = state?.downloader || {};
728
878
  const typeLabel = dl.type === 'qbittorrent' ? 'qBittorrent' : 'BitComet';
729
879
  let currentPort = '';
730
880
  try { currentPort = new URL(dl.base || '').port; } catch { /* unknown */ }
731
881
  return h(Overlay, {
732
- title: 'P2P 下载器', onClose: () => setDialog(null),
882
+ title: '下载器', onClose: () => setDialog(null),
733
883
  }, h('div', null,
734
884
  h('div', { style: { marginBottom: 12, fontSize: 13 } },
735
- dl.ok ? `当前:${typeLabel} 已连接 · 端口 ${currentPort || '?????'}` : '当前:P2P 下载器 未连接'),
885
+ dl.ok ? `当前:${typeLabel} 已连接 · 端口 ${currentPort || '?????'}` : '当前:下载器 未连接'),
736
886
  h('div', { style: { display: 'flex', gap: 8, flexWrap: 'wrap', marginBottom: 14 } },
737
887
  h('button', { onClick: runScan, disabled: Boolean(busy) }, busy === 'scan' ? '检测中…' : '自动检测'),
738
888
  h('button', {
@@ -764,7 +914,7 @@ window.__ModuleLoader__.load({
764
914
  title: '下载器连接指引', onClose: () => setDialog(null),
765
915
  }, h('div', null,
766
916
  h('div', { style: { ...muted, marginBottom: 12 } },
767
- '任选一个 P2P 下载器开启 Web 接口,然后在插件配置里用 downloader 指定它。'),
917
+ '任选一个下载器开启 Web 接口,然后在插件配置里用 downloader 指定它。'),
768
918
 
769
919
  h('div', { style: { fontWeight: 600, fontSize: 13, marginBottom: 6 } }, 'qBittorrent(端口默认 8080)'),
770
920
  h('ol', { style: { paddingLeft: 20, lineHeight: 1.9, fontSize: 13, margin: 0 } },
package/docs/DETAIL.md CHANGED
@@ -1,64 +1,42 @@
1
1
  # 蜜柑追番(dsh-mikan)
2
2
 
3
- 把「蜜柑计划的番剧更新」和「比特彗星」连起来的半自动追番工具:**自动发现 → 你确认 → 自动下载**。
3
+ 把「蜜柑计划的番剧更新」和「下载器」连起来的半自动追番工具:**自动发现 → 你确认 → 自动下载**。
4
+
5
+ 支持 BitComet 与 qBittorrent 两种下载器,可自动检测切换。
4
6
 
5
7
  ## 功能
6
8
 
7
9
  | 能力 | 说明 |
8
10
  |---|---|
9
- | 实时检索 | 按中文番名搜索,列出资源与字幕组 |
10
- | 分级查询 | 季度 → 番剧 → 字幕组 → 资源 |
11
- | 订阅管理 | 番剧 + 字幕组(可多组),运行时增删,不写死 |
12
- | 更新跟进 | 定时抓取,比集数水位,发现新集推送通知 |
13
- | 季前预告 | 换季前一周看下季度新番,三态判定(未开播 / 已开播无资源 / 已开播有资源) |
14
- | 追番周历 | 周一~周日分列,看每部番的更新时间 |
15
- | 下载执行 | 确认后拼 magnet 调用比特彗星 |
11
+ | 当季浏览 | 按当前月份自动判断季度,按放送星期折叠列出新番 |
12
+ | 往季浏览 | 从近 12 年里选任意季度 |
13
+ | 字幕组浏览 | 番剧 → 字幕组 → 作品,逐层展开 |
14
+ | 语言分类 | 作品按简体 / 繁体 / 多字幕三类标记 |
15
+ | 批量下载 | 全部 / 简中 / 繁中 / 多字幕 |
16
+ | 订阅管理 | 番剧 + 字幕组(可多组),随时增删 |
17
+ | 更新跟进 | 定时检查,该组出新集时通知 |
18
+ | 追番周历 | 周一~周日分列,看每部番的更新 |
19
+ | 静默关注 | 不显示在周历,仍接收更新 |
20
+ | 下载执行 | 单集或批量,确认后发送给下载器 |
21
+ | 源检测 | Mikan / Bangumi / Nyaa 三个源分别检测,可自定义镜像 |
16
22
 
17
23
  ## 环境自适应
18
24
 
19
- 插件启动时自动探测环境,决定走哪条链路:
20
-
21
- | 检测结果 | 蜜柑源 | 开播日源 |
22
- |---|---|---|
23
- | 代理可用 | `mikanani.me`(墙外) | bgm.tv API |
24
- | 无代理 | `mikanime.tv`(墙内) | AniList(需日文名) |
25
-
26
- 探测结果缓存 5 分钟;抓取失败会立即重探并降级。
27
-
28
- ## 配置
29
-
30
- 在 profile 的 `cordis.patch.yml` 中为该行设置 `config`:
31
-
32
- ```yaml
33
- - id: dsh-mikan
34
- config:
35
- proxy: 'http://127.0.0.1:7890'
36
- bitcometBase: 'http://127.0.0.1:10816'
37
- savePath: 'D:\Downloads\Anime'
38
- checkIntervalMinutes: 30
39
- ```
25
+ 插件启动时自动探测三个来源:
40
26
 
41
- | 字段 | 默认 | 说明 |
27
+ | 来源 | 代理模式 | 直连模式 |
42
28
  |---|---|---|
43
- | `proxy` | 空 | 本地代理地址,留空走直连 |
44
- | `bitcometBase` | `http://127.0.0.1:10816` | 比特彗星 WebUI 地址 |
45
- | `savePath` | 空(必填) | 下载保存目录,未设置时下载会被拒绝 |
46
- | `checkIntervalMinutes` | 30 | 后台更新检查间隔 |
29
+ | **Mikan** | 优先 `mikanani.me`(墙外) | 优先 `mikanime.tv`(墙内) |
30
+ | **Bangumi** | 官方 API(走代理) | 社区镜像目录里的 API |
31
+ | **Nyaa** | 官方 `nyaa.si`(走代理) | 优先自定义镜像 |
47
32
 
48
- 比特彗星的用户名/密码会自动从 `%APPDATA%\BitComet\BitComet.xml` 读取,无需填写。
33
+ - 自动选择当前网络可用的来源
34
+ - 探测失败会降级,不会让整个插件报错
35
+ - Nyaa 目前只做连接检测,资源接入计划在 0.3.0
49
36
 
50
- ## 使用(对话内)
37
+ ## 下载器配置要求
51
38
 
52
- ```
53
- 帮我查一下「乱马1/2」有哪些字幕组在做
54
- 追「乱马1/2」第 31 集,LoliHouse 的
55
- 看看我的追番订阅
56
- 检查一下有没有更新
57
- 把这一集下到比特彗星
58
- 下季度有什么新番,哪天开播
59
- ```
60
-
61
- ## 比特彗星配置要求
39
+ **BitComet**
62
40
 
63
41
  1. 远程访问 → 监听端口填固定值(如 10816)
64
42
  2. 勾选「启用网页版远程访问」
@@ -66,11 +44,31 @@
66
44
  4. 设置用户名 / 密码
67
45
  5. 不勾选「执行远程访问操作时显示提示窗口」
68
46
 
47
+ **qBittorrent**
48
+
49
+ 1. 工具 → 选项 → Web UI
50
+ 2. 勾选「启用 Web 用户界面」
51
+ 3. 端口默认 8080
52
+ 4. 设置用户名 / 密码(本机使用可勾「对本地主机跳过身份验证」)
53
+
54
+ ## 界面状态
55
+
56
+ 状态条上的标签均可点击:
57
+
58
+ | 标签 | 点击后 |
59
+ |---|---|
60
+ | 代理模式(绿)/ 直连模式(黄) | — |
61
+ | Mikan 可用(绿)/ 不可用(红) | 连接详情、自定义镜像、重新检测 |
62
+ | Bangumi 可用 / 不可用 | 连接详情、自定义 API、重新检测 |
63
+ | Nyaa 可用 / 不可用 | 连接详情、自定义镜像、重新检测(资源接入在 0.3.0) |
64
+ | 下载器 | 端口扫描结果、切换 BitComet / qBittorrent |
65
+
69
66
  ## 已知限制
70
67
 
71
- 1. **无作品的番剧**在蜜柑只有 id/名称/封面,开播日依赖 bgm/AniList;都不可用时标注「未知」,不编造
68
+ 1. **无作品的番剧**在蜜柑只有 id/名称/封面,开播日依赖 Bangumi / AniList;都不可用时标注「未知」,不编造
72
69
  2. **剧场版 / OVA 的「放送日期」不可信**(页面显示周日),只用「放送开始」
73
- 3. 全站 RSS 单次最多 100 条,订阅多时靠单番 RSS 补漏
74
- 4. 比特彗星的添加/删除接口返回值不可靠,一律以任务列表复核结果为准
75
- 5. 插件**不会**自己启动或关闭比特彗星进程
70
+ 3. **运营商封锁 Cloudflare** 时蜜柑会完全不可达(两个内置域名都在 CF 后面),只能走代理或自定义镜像
71
+ 4. 下载器的添加 / 删除接口返回值不可靠,一律以任务列表复核结果为准
72
+ 5. 插件**不会**自己启动或关闭下载器进程
76
73
  6. 后台检查只产生通知,不会自动下载——下载必须由你确认
74
+ 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, NYAA_OFFICIAL, 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,131 @@ 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 = 'no-proxy';
151
- if (proxy) {
152
- const r = await probeProxy(proxy, 'https://api.bgm.tv/v0/subjects/274243', 6000);
153
- bgmOk = r.ok;
154
- bgmReason = r.reason || '';
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
+ }
223
+ }
224
+
225
+ const mikan = await detectMikanSource({ proxy: bgmViaProxy ? proxy : '', customBase: cfg.mikanBase || '' });
226
+
227
+ // nyaa: the official site is blocked from the mainland, so a direct
228
+ // connection prefers a user-supplied mirror. A proxy flips the order.
229
+ // Detection only — the source itself is wired up in a later release.
230
+ const customNyaa = String(cfg.nyaaBase || '').trim().replace(/\/+$/, '');
231
+ const officialNyaa = NYAA_OFFICIAL.replace(/\/+$/, '');
232
+ const nyaaPlan = [];
233
+ if (customNyaa) {
234
+ if (proxy) {
235
+ nyaaPlan.push({ base: officialNyaa, via: proxy }, { base: customNyaa, via: '' });
236
+ } else {
237
+ nyaaPlan.push({ base: customNyaa, via: '' }, { base: officialNyaa, via: '' });
238
+ }
239
+ } else {
240
+ nyaaPlan.push({ base: officialNyaa, via: proxy });
241
+ }
242
+ let nyaaOk = false;
243
+ let nyaaReason = 'unreachable';
244
+ let nyaaBase = customNyaa || officialNyaa;
245
+ let nyaaViaProxy = false;
246
+ for (const step of nyaaPlan) {
247
+ const r = await probeProxy(step.via, `${step.base}/`, 6000);
248
+ if (r.ok) {
249
+ nyaaOk = true;
250
+ nyaaBase = step.base;
251
+ nyaaViaProxy = Boolean(step.via);
252
+ nyaaReason = customNyaa && step.base === customNyaa ? 'custom' : 'official';
253
+ break;
254
+ }
255
+ nyaaReason = r.reason || 'unreachable';
155
256
  }
156
- const mikan = await detectMikanSource({ proxy: bgmOk ? proxy : '' });
157
257
  env = {
158
258
  at: Date.now(),
159
259
  proxy,
160
260
  bgmOk,
161
261
  bgmReason,
262
+ bgmBase,
263
+ bgmViaProxy,
162
264
  mikanBase: mikan.base,
163
265
  mikanViaProxy: mikan.viaProxy,
164
266
  mikanReason: mikan.reason,
165
- mode: bgmOk ? 'proxy' : 'direct',
267
+ mikanOk: mikan.reason !== 'all-probes-failed',
268
+ nyaaOk,
269
+ nyaaReason,
270
+ nyaaBase,
271
+ nyaaViaProxy,
272
+ // "proxy" means the proxy actually carried a request, not that bgm happened
273
+ // to be reachable through a direct mirror.
274
+ mode: (bgmViaProxy || mikan.viaProxy) ? 'proxy' : 'direct',
166
275
  };
167
276
  logger?.info?.(`[dsh-mikan] env=${env.mode} mikan=${env.mikanBase} bgm=${bgmOk}`);
168
277
  return env;
@@ -315,7 +424,7 @@ export async function apply(ctx) {
315
424
  } catch { /* keep the fallback */ }
316
425
  if (!info.startDate) {
317
426
  try {
318
- const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: cfg.proxy, year: new Date().getFullYear() });
427
+ const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year: new Date().getFullYear() });
319
428
  if (r.ok) { info.airDate = r.airDate; info.airSource = r.source || ''; }
320
429
  } catch { /* unknown */ }
321
430
  }
@@ -395,7 +504,7 @@ export async function apply(ctx) {
395
504
 
396
505
  ctx.tools.register(defineTool({
397
506
  name: 'mikan_status',
398
- description: 'Report the current Mikan environment: proxy reachability, chosen mirror domain, air-date fallback availability, and P2P downloader connection state.',
507
+ description: 'Report the current Mikan environment: proxy reachability, chosen mirror domain, air-date fallback availability, and downloader connection state.',
399
508
  parameters: {
400
509
  type: 'object',
401
510
  properties: {
@@ -432,6 +541,9 @@ export async function apply(ctx) {
432
541
  qbittorrentBase: { type: 'string', description: 'qBittorrent WebUI base URL.' },
433
542
  qbittorrentUser: { type: 'string', description: 'qBittorrent username.' },
434
543
  qbittorrentPassword: { type: 'string', description: 'qBittorrent password.' },
544
+ mikanBase: { type: 'string', description: 'Custom Mikan mirror base URL. Empty means auto-detect between built-ins.' },
545
+ bgmBase: { type: 'string', description: 'Custom bgm.tv API base. Empty means official api.bgm.tv, then mirrors from the community directory.' },
546
+ nyaaBase: { type: 'string', description: 'Custom nyaa mirror. Empty means official nyaa.si (needs a proxy).' },
435
547
  savePath: { type: 'string', description: 'Default download directory inside the downloader.' },
436
548
  checkIntervalMinutes: { type: 'number', description: 'Background check interval in minutes.' },
437
549
  },
@@ -440,7 +552,7 @@ export async function apply(ctx) {
440
552
  output: { schema: OBJ, render: renderJson },
441
553
  async execute(args) {
442
554
  const patch = {};
443
- for (const key of ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'savePath', 'checkIntervalMinutes']) {
555
+ for (const key of ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'mikanBase', 'bgmBase', 'nyaaBase', 'savePath', 'checkIntervalMinutes']) {
444
556
  if (args?.[key] !== undefined) patch[key] = args[key];
445
557
  }
446
558
  if (Object.keys(patch).length === 0) return { config: await loadConfig(), changed: false };
@@ -543,7 +655,7 @@ export async function apply(ctx) {
543
655
 
544
656
  ctx.tools.register(defineTool({
545
657
  name: 'mikan_download',
546
- description: 'Send releases to the configured P2P downloader by 40-character info hash (full magnet URIs are also accepted). The downloader reports unreliable status, so the task list is verified afterwards.',
658
+ 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
659
  parameters: {
548
660
  type: 'object',
549
661
  properties: {
@@ -629,15 +741,24 @@ export async function apply(ctx) {
629
741
  const route = u.pathname.slice('/dsh-mikan'.length);
630
742
  try {
631
743
  if (route === '/state' && req.method === 'GET') {
632
- const e = await detectEnv();
744
+ const e = await detectEnv(u.searchParams.get('refresh') === '1');
633
745
  const cfg = await loadConfig();
634
746
  const dl = await downloaderInfo();
635
747
  return send(res, 200, {
636
748
  mode: e.mode,
637
749
  proxy: e.proxy,
638
750
  bgm: e.bgmOk,
751
+ bgmReason: e.bgmReason,
752
+ bgmActive: e.bgmBase,
753
+ bgmCustom: cfg.bgmBase || '',
754
+ nyaa: e.nyaaOk,
755
+ nyaaActive: e.nyaaBase,
756
+ nyaaCustom: cfg.nyaaBase || '',
639
757
  mikan: e.mikanBase,
640
758
  mikanViaProxy: e.mikanViaProxy,
759
+ mikanOk: e.mikanOk,
760
+ mikanReason: e.mikanReason,
761
+ mikanCustom: cfg.mikanBase || '',
641
762
  downloader: dl,
642
763
  savePath: cfg.savePath,
643
764
  checkIntervalMinutes: cfg.checkIntervalMinutes,
@@ -770,7 +891,7 @@ export async function apply(ctx) {
770
891
  }
771
892
  return send(res, 200, {
772
893
  ok: false,
773
- reason: '未找到可用的 P2P 下载器(qBittorrent 和 BitComet 都试过了)',
894
+ reason: '未找到可用的下载器(qBittorrent 和 BitComet 都试过了)',
774
895
  tried,
775
896
  });
776
897
  }
@@ -788,7 +909,7 @@ export async function apply(ctx) {
788
909
  const rows = await mapLimit(flat, 8, async ({ item, group }) => {
789
910
  let air = { ok: false };
790
911
  try {
791
- air = await resolveAirDate({ names: [item.title], proxy: cfg.proxy, year });
912
+ air = await resolveAirDate({ names: [item.title], proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year });
792
913
  } catch { /* ignore */ }
793
914
  const airDate = air.ok ? air.airDate : '';
794
915
  const state = airDate
@@ -849,7 +970,7 @@ export async function apply(ctx) {
849
970
  let airSource = '';
850
971
  if (!info.startDate) {
851
972
  try {
852
- const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: cfg.proxy, year: new Date().getFullYear() });
973
+ const r = await resolveAirDate({ names: [info.title].filter(Boolean), proxy: env?.bgmViaProxy ? cfg.proxy : '', bgmBase: env?.bgmBase || cfg.bgmBase || '', year: new Date().getFullYear() });
853
974
  if (r.ok) { airDate = r.airDate; airSource = r.source; }
854
975
  } catch { /* unknown */ }
855
976
  }
@@ -949,7 +1070,7 @@ export async function apply(ctx) {
949
1070
  }
950
1071
  if (route === '/config' && req.method === 'POST') {
951
1072
  const body = await readBody(req);
952
- const allowed = ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'savePath', 'checkIntervalMinutes'];
1073
+ const allowed = ['downloader', 'proxy', 'bitcometBase', 'qbittorrentBase', 'qbittorrentUser', 'qbittorrentPassword', 'mikanBase', 'bgmBase', 'nyaaBase', 'savePath', 'checkIntervalMinutes'];
953
1074
  const patch = {};
954
1075
  for (const key of allowed) {
955
1076
  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
- if (hasProxy(proxy)) {
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
@@ -5,6 +5,8 @@
5
5
  export const MIKAN_INSIDE = 'https://mikanime.tv';
6
6
  export const MIKAN_OUTSIDE = 'https://mikanani.me';
7
7
  export const BGM_API = 'https://api.bgm.tv';
8
+ /** nyaa official site; mirrors are user-supplied until a directory exists. */
9
+ export const NYAA_OFFICIAL = 'https://nyaa.si';
8
10
  export const ANILIST_API = 'https://graphql.anilist.co';
9
11
 
10
12
  /** Common local proxy ports, tried by the auto-bridge when the user's port fails. */
@@ -38,6 +40,12 @@ export const DEFAULT_CONFIG = {
38
40
  qbittorrentBase: 'http://127.0.0.1:8080',
39
41
  qbittorrentUser: '',
40
42
  qbittorrentPassword: '',
43
+ /** Optional custom Mikan mirror; empty means auto-detect between built-ins. */
44
+ mikanBase: '',
45
+ /** Optional custom bgm.tv API base; empty means the official api.bgm.tv. */
46
+ bgmBase: '',
47
+ /** Optional nyaa mirror; empty means the official nyaa.si. */
48
+ nyaaBase: '',
41
49
  /** Download directory inside the downloader; must be set before downloading. */
42
50
  savePath: '',
43
51
  /** 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. Tries the outside domain through the proxy, then
47
- * the inside domain directly, then the outside domain directly.
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.0",
4
- "description": "Mikan Project tracker with BitComet integration: browse seasons, follow subgroups, and send confirmed releases to BitComet.",
3
+ "version": "0.2.2",
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": {