dsh-mikan 0.2.3 → 0.3.0

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/lib/store.js CHANGED
@@ -28,6 +28,8 @@ const EMPTY = {
28
28
  subscriptions: [],
29
29
  sources: [],
30
30
  seen: {},
31
+ orders: {},
32
+ activeSession: '',
31
33
  lastCheckAt: '',
32
34
  lastUpdates: [],
33
35
  lastUpdatesAt: '',
@@ -244,3 +246,77 @@ export async function updateSubscription(id, patch) {
244
246
  await saveState(state);
245
247
  return rec;
246
248
  }
249
+
250
+ /* ---------------- conversation orders ---------------- */
251
+
252
+ /**
253
+ * Remember which conversation is currently looking at its order list.
254
+ * Tools have no session context, so they attach new items to this session;
255
+ * the client refreshes it whenever the order tab is opened.
256
+ */
257
+ export async function setActiveSession(sessionId) {
258
+ const state = await loadState();
259
+ if (!sessionId) return state.activeSession || '';
260
+ if (state.activeSession === sessionId) return sessionId;
261
+ state.activeSession = sessionId;
262
+ await saveState(state);
263
+ return sessionId;
264
+ }
265
+
266
+ /** Read one session's order, falling back to the last active session. */
267
+ export async function getOrder(sessionId) {
268
+ const state = await loadState();
269
+ const key = sessionId || state.activeSession || '';
270
+ return { sessionId: key, items: Array.isArray(state.orders?.[key]) ? state.orders[key] : [] };
271
+ }
272
+
273
+ /** Append items to a session's order, deduped by hash. */
274
+ export async function addOrderItems(sessionId, items) {
275
+ const state = await loadState();
276
+ const key = sessionId || state.activeSession || '';
277
+ if (!key) return { sessionId: '', items: [] };
278
+ if (!state.orders) state.orders = {};
279
+ const list = Array.isArray(state.orders[key]) ? state.orders[key] : [];
280
+ const seen = new Set(list.map((i) => i.hash));
281
+ for (const item of items || []) {
282
+ if (!item || !item.hash || seen.has(item.hash)) continue;
283
+ seen.add(item.hash);
284
+ list.push({ ...item, addedAt: new Date().toISOString() });
285
+ }
286
+ state.orders[key] = list;
287
+ await saveState(state);
288
+ return { sessionId: key, items: list };
289
+ }
290
+
291
+ /** Remove one hash from a session's order. */
292
+ export async function removeOrderItem(sessionId, hash) {
293
+ const state = await loadState();
294
+ const key = sessionId || state.activeSession || '';
295
+ const list = Array.isArray(state.orders?.[key]) ? state.orders[key] : [];
296
+ if (!state.orders) state.orders = {};
297
+ state.orders[key] = list.filter((i) => i.hash !== hash);
298
+ await saveState(state);
299
+ return { sessionId: key, items: state.orders[key] };
300
+ }
301
+
302
+ /**
303
+ * Drop hashes after they were handed to the downloader. An empty/absent list
304
+ * clears the whole order — confirming once always empties once.
305
+ */
306
+ export async function consumeOrderItems(sessionId, hashes) {
307
+ const state = await loadState();
308
+ const key = sessionId || state.activeSession || '';
309
+ if (!key) return { removed: 0, items: [] };
310
+ const list = Array.isArray(state.orders?.[key]) ? state.orders[key] : [];
311
+ if (!Array.isArray(hashes) || hashes.length === 0) {
312
+ state.orders[key] = [];
313
+ await saveState(state);
314
+ return { removed: list.length, items: [] };
315
+ }
316
+ const drop = new Set(hashes);
317
+ const kept = list.filter((i) => !drop.has(i.hash));
318
+ const removed = list.length - kept.length;
319
+ state.orders[key] = kept;
320
+ await saveState(state);
321
+ return { removed, items: kept };
322
+ }
package/lib/t2s.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Traditional → Simplified character folding.
3
+ *
4
+ * Subtitles come from groups that use traditional characters ("FX 戰士久留美")
5
+ * while the season catalog and Bangumi store simplified titles ("FX战士久留美"),
6
+ * so name matching needs one canonical form. This is a small high-frequency map
7
+ * rather than a full conversion table: it only folds characters that actually
8
+ * appear in anime titles, which keeps it auditable.
9
+ *
10
+ * Dependency-free on purpose — `catalog.js` imports it, and `names.js` imports
11
+ * `catalog.js`, so putting the map here avoids a cycle.
12
+ */
13
+
14
+ const MAP = {
15
+ 戰: '战', 劇: '剧', 畫: '画', 學: '学', 會: '会', 說: '说', 龍: '龙', 鳳: '凤',
16
+ 寶: '宝', 國: '国', 東: '东', 華: '华', 愛: '爱', 戀: '恋', 夢: '梦', 時: '时',
17
+ 間: '间', 當: '当', 這: '这', 來: '来', 過: '过', 後: '后', 發: '发', 動: '动',
18
+ 門: '门', 問: '问', 題: '题', 麼: '么', 兒: '儿', 為: '为', 對: '对', 應: '应',
19
+ 該: '该', 聽: '听', 見: '见', 覺: '觉', 實: '实', 現: '现', 經: '经', 歷: '历',
20
+ 開: '开', 關: '关', 頭: '头', 臉: '脸', 體: '体', 風: '风', 雲: '云', 電: '电',
21
+ 車: '车', 嗎: '吗', 讓: '让', 記: '记', 憶: '忆', 誰: '谁', 認: '认', 識: '识',
22
+ 話: '话', 語: '语', 讀: '读', 寫: '写', 書: '书', 筆: '笔', 點: '点', 線: '线',
23
+ 無: '无', 數: '数', 變: '变', 還: '还', 進: '进', 遠: '远', 邊: '边', 樣: '样',
24
+ 種: '种', 類: '类', 級: '级', 場: '场', 長: '长', 總: '总', 統: '统', 隊: '队',
25
+ 員: '员', 師: '师', 團: '团', 鬥: '斗', 軍: '军', 機: '机', 裝: '装', 製: '制',
26
+ 產: '产', 業: '业', 務: '务', 勞: '劳', 內: '内', 從: '从', 們: '们', 個: '个',
27
+ 傳: '传', 條: '条', 規: '规', 則: '则', 標: '标', 準: '准', 確: '确', 決: '决',
28
+ 選: '选', 擇: '择', 錯: '错', 誤: '误', 計: '计', 劃: '划', 參: '参', 與: '与',
29
+ 處: '处', 據: '据', 舉: '举', 辦: '办', 須: '须', 雖: '虽', 盡: '尽', 達: '达',
30
+ 運: '运', 轉: '转', 輸: '输', 載: '载', 陸: '陆', 陽: '阳', 陰: '阴', 葉: '叶',
31
+ 樹: '树', 宮: '宫', 廳: '厅', 廣: '广', 廢: '废', 庫: '库', 廠: '厂', 區: '区',
32
+ 醫: '医', 藥: '药', 護: '护', 療: '疗', 傷: '伤', 殘: '残', 屍: '尸', 殺: '杀',
33
+ 爭: '争', 紅: '红', 綠: '绿', 藍: '蓝', 黃: '黄', 銀: '银', 鐵: '铁', 鋼: '钢',
34
+ 劍: '剑', 槍: '枪', 彈: '弹', 砲: '炮', 機: '机', 飛: '飞', 航: '航', 船: '船',
35
+ 島: '岛', 灣: '湾', 縣: '县', 鄉: '乡', 鎮: '镇', 橋: '桥', 燈: '灯', 爐: '炉',
36
+ 燒: '烧', 熱: '热', 凍: '冻', 溫: '温', 濕: '湿', 聲: '声', 響: '响', 靜: '静',
37
+ 號: '号', 稱: '称', 讚: '赞', 賞: '赏', 賜: '赐', 獻: '献', 禮: '礼', 祭: '祭',
38
+ 聖: '圣', 靈: '灵', 惡: '恶', 魔: '魔', 獄: '狱', 煉: '炼', 爐: '炉', 讀: '读',
39
+ 講: '讲', 訓: '训', 練: '练', 習: '习', 試: '试', 驗: '验', 護: '护', 衛: '卫',
40
+ 統: '统', 領: '领', 導: '导', 帶: '带', 隨: '随', 屬: '属', 腦: '脑', 臉: '脸',
41
+ 胸: '胸', 腳: '脚', 頸: '颈', 髮: '发', 髪: '发', 鬪: '斗', 鬭: '斗', 覚: '觉',
42
+ 鍊: '炼', 鉄: '铁', 銀: '银', 銃: '铳', 錢: '钱', 鐵: '铁', 鐘: '钟', 鑰: '钥',
43
+ 闇: '暗', 驚: '惊', 驟: '骤', 變: '变', 獵: '猎', 獸: '兽', 蟲: '虫', 鳥: '鸟',
44
+ 魚: '鱼', 馬: '马', 雞: '鸡', 鴨: '鸭', 鷹: '鹰', 鶴: '鹤', 鹿: '鹿', 龍: '龙',
45
+ };
46
+
47
+ /** Fold traditional characters to their simplified form. */
48
+ export function toSimplified(text) {
49
+ return String(text || '').replace(/[\u3400-\u9fff]/g, (ch) => MAP[ch] || ch);
50
+ }
51
+
52
+ export { MAP };
package/locale/en.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
- "title": "Mikan tracker",
4
- "description": "Track Mikan season releases by subgroup and send confirmed picks to BitComet, with a weekly schedule view and season preview.",
3
+ "title": "Anime Tracker",
4
+ "description": "Track Mikan and nyaa releases, follow subgroups, confirm picks before downloading, and organise finished files into a local media library. Includes a weekly schedule and an offline title index.",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/locale/zh.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "meta": {
3
- "title": "蜜柑追番",
4
- "description": "跟踪蜜柑计划的季度新番与字幕组更新,确认后调用比特彗星下载;含追番周历与季前预告。",
3
+ "title": "追番助手",
4
+ "description": "浏览蜜柑与 nyaa 的新番资源、按字幕组订阅、确认后下载,并把下载好的文件整理进本地媒体库;含追番周历、离线名称库与更新提醒。",
5
5
  "detail": "docs/DETAIL.md"
6
6
  }
7
7
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-mikan",
3
- "version": "0.2.3",
4
- "description": "Mikan Project tracker for DeepSeek Harness: browse current and past seasons, follow subgroups, and send confirmed releases to BitComet or qBittorrent.",
3
+ "version": "0.3.0",
4
+ "description": "Anime tracker for DeepSeek Harness: browse Mikan seasons, follow subgroups, search Mikan and nyaa, queue releases for confirmation, then organise a local media library.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "琉璃羽Ryuribana",
@@ -10,7 +10,10 @@
10
10
  "dsh-plugin",
11
11
  "deepseek-harness",
12
12
  "mikan",
13
+ "nyaa",
13
14
  "anime",
15
+ "bangumi",
16
+ "media-library",
14
17
  "bitcomet",
15
18
  "qbittorrent",
16
19
  "rss"
@@ -25,6 +28,7 @@
25
28
  "index.js",
26
29
  "client.js",
27
30
  "lib",
31
+ "assets",
28
32
  "cordis.patch.yml",
29
33
  "locale/*.json",
30
34
  "docs",