@aronnaxlin/bgm-cli 1.1.0 → 1.1.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/README.en.md CHANGED
@@ -52,19 +52,6 @@ bgm auth set-token YOUR_ACCESS_TOKEN
52
52
  bgm auth token-status
53
53
  ```
54
54
 
55
- ### Multiple accounts
56
-
57
- Snapshot the current credentials as a named profile and switch between accounts quickly:
58
-
59
- ```bash
60
- bgm auth profile save main
61
- bgm auth profile list
62
- bgm auth profile use another
63
- bgm --profile another user me
64
- ```
65
-
66
- `bgm --profile <name> <command>` runs a single command as that account without switching; it is a read-only override and never writes to disk.
67
-
68
55
  ### Proxy
69
56
 
70
57
  If your network needs a proxy to reach the Bangumi API reliably, configure an HTTP/HTTPS proxy for all CLI requests:
@@ -103,24 +90,6 @@ bgm trending subjects --type anime --limit 5
103
90
  bgm --json user me
104
91
  ```
105
92
 
106
- ### Paste A Link
107
-
108
- Hand a Bangumi web link straight to `bgm` and it resolves to the matching command:
109
-
110
- ```bash
111
- bgm "https://bangumi.tv/group/topic/469977#post_4029724" # that single reply -> bgm group post 4029724
112
- bgm url https://bgm.tv/subject/253/characters # -> bgm subject characters 253
113
- bgm --url https://bgm.tv/anime/list/sai/collect --dry-run # resolve only, no request
114
- ```
115
-
116
- - Three equivalent forms: `bgm <url>`, `bgm url <url>`, `bgm --url <url>` (`-url` also works).
117
- - Hosts: `bgm.tv`, `bangumi.tv`, `chii.in`, `next.bgm.tv`, `api.bgm.tv`; the `https://` and `www.` prefixes are optional.
118
- - Resolution is read-only, so a link never triggers a write. `--dry-run` prints the resolution and stops.
119
- - A `#post_<id>` anchor resolves to that single reply; `?page=n` becomes `--offset`.
120
- - Extra flags are forwarded to the resolved command, and `--json` output carries a `resolvedFrom` field.
121
- - Quote links containing `#` so the shell does not truncate them.
122
- - Run `bgm url --help` for the full list of supported link shapes.
123
-
124
93
  ## Documentation Index
125
94
 
126
95
  - This project also ships installable Skills for AI or agent workflows around `bgm-cli`.
package/README.md CHANGED
@@ -52,19 +52,6 @@ bgm auth set-token YOUR_ACCESS_TOKEN
52
52
  bgm auth token-status
53
53
  ```
54
54
 
55
- ### 多账户
56
-
57
- 可以把当前凭据存成命名 profile,在多个账户之间快捷切换:
58
-
59
- ```bash
60
- bgm auth profile save main
61
- bgm auth profile list
62
- bgm auth profile use another
63
- bgm --profile another user me
64
- ```
65
-
66
- `bgm --profile <name> <command>` 只在单条命令内临时使用该账户,不切换、不写盘。
67
-
68
55
  ### 代理
69
56
 
70
57
  如果你所在网络访问 Bangumi API 不稳定,可以为所有 CLI 请求设置 HTTP/HTTPS 代理:
@@ -110,24 +97,6 @@ bgm status --site bgm.tv
110
97
  bgm --json user me
111
98
  ```
112
99
 
113
- ### 粘贴链接直接查询
114
-
115
- 把 Bangumi 网页链接直接交给 `bgm`,它会解析成对应命令并输出同样的结果:
116
-
117
- ```bash
118
- bgm "https://bangumi.tv/group/topic/469977#post_4029724" # 定位到该楼 -> bgm group post 4029724
119
- bgm url https://bgm.tv/subject/253/characters # -> bgm subject characters 253
120
- bgm --url https://bgm.tv/anime/list/sai/collect --dry-run # 只看解析结果,不发请求
121
- ```
122
-
123
- - 三种写法等价:`bgm <url>`、`bgm url <url>`、`bgm --url <url>`(`-url` 亦可)。
124
- - 支持 `bgm.tv`、`bangumi.tv`、`chii.in`、`next.bgm.tv`、`api.bgm.tv`,可省略 `https://` 与 `www.`。
125
- - 解析是只读的,链接永远不会触发写操作;`--dry-run` 只打印解析结果。
126
- - `#post_<id>` 锚点会精确定位到该楼回复;`?page=n` 会换算成 `--offset`。
127
- - 多余的参数会透传给解析出的命令,`--json` 输出会附带 `resolvedFrom` 溯源字段。
128
- - 链接含 `#` 时请加引号,否则会被 shell 截断。
129
- - 完整支持列表见 `bgm url --help`。
130
-
131
100
  ## 文档索引
132
101
 
133
102
  - 本项目同时提供可安装的 Skills,适合让 AI / Agent 直接安装并操作 `bgm-cli`。
package/README.zh-TW.md CHANGED
@@ -52,19 +52,6 @@ bgm auth set-token YOUR_ACCESS_TOKEN
52
52
  bgm auth token-status
53
53
  ```
54
54
 
55
- ### 多帳戶
56
-
57
- 可以把當前憑據存成命名 profile,在多個帳戶之間快捷切換:
58
-
59
- ```bash
60
- bgm auth profile save main
61
- bgm auth profile list
62
- bgm auth profile use another
63
- bgm --profile another user me
64
- ```
65
-
66
- `bgm --profile <name> <command>` 只在單條命令內臨時使用該帳戶,不切換、不寫盤。
67
-
68
55
  ### 代理
69
56
 
70
57
  如果你所在網路存取 Bangumi API 不穩定,可以為所有 CLI 請求設定 HTTP/HTTPS 代理:
@@ -103,24 +90,6 @@ bgm trending subjects --type anime --limit 5
103
90
  bgm --json user me
104
91
  ```
105
92
 
106
- ### 貼上連結直接查詢
107
-
108
- 把 Bangumi 網頁連結直接交給 `bgm`,它會解析成對應命令並輸出同樣的結果:
109
-
110
- ```bash
111
- bgm "https://bangumi.tv/group/topic/469977#post_4029724" # 定位到該樓 -> bgm group post 4029724
112
- bgm url https://bgm.tv/subject/253/characters # -> bgm subject characters 253
113
- bgm --url https://bgm.tv/anime/list/sai/collect --dry-run # 只看解析結果,不發請求
114
- ```
115
-
116
- - 三種寫法等價:`bgm <url>`、`bgm url <url>`、`bgm --url <url>`(`-url` 亦可)。
117
- - 支援 `bgm.tv`、`bangumi.tv`、`chii.in`、`next.bgm.tv`、`api.bgm.tv`,可省略 `https://` 與 `www.`。
118
- - 解析是唯讀的,連結永遠不會觸發寫入操作;`--dry-run` 只印出解析結果。
119
- - `#post_<id>` 錨點會精確定位到該樓回覆;`?page=n` 會換算成 `--offset`。
120
- - 多餘的參數會透傳給解析出的命令,`--json` 輸出會附帶 `resolvedFrom` 溯源欄位。
121
- - 連結含 `#` 時請加引號,否則會被 shell 截斷。
122
- - 完整支援列表見 `bgm url --help`。
123
-
124
93
  ## 文件索引
125
94
 
126
95
  - 本專案同時提供可安裝的 Skills,適合讓 AI / Agent 直接安裝並操作 `bgm-cli`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aronnaxlin/bgm-cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Command-line client for Bangumi.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "aronnaxlin",
@@ -1172,7 +1172,23 @@ export class BangumiClient {
1172
1172
  throw new CommandError("Missing username. Pass a username or log in first.");
1173
1173
  }
1174
1174
 
1175
- const result = await this.request(`/p1/users/${encodeURIComponent(String(username))}/collections/subjects`, {
1175
+ let isMe = false;
1176
+ try {
1177
+ const me = await this.getMe();
1178
+ const meUsername = typeof me?.username === "string" ? me.username.trim() : "";
1179
+ if (meUsername && meUsername.toLowerCase() === String(username).trim().toLowerCase()) {
1180
+ isMe = true;
1181
+ }
1182
+ } catch {
1183
+ isMe = false;
1184
+ }
1185
+
1186
+ const path = isMe
1187
+ ? "/p1/collections/subjects"
1188
+ : `/p1/users/${encodeURIComponent(String(username))}/collections/subjects`;
1189
+
1190
+ const result = await this.request(path, {
1191
+ auth: true,
1176
1192
  query: normalizeSubjectCollectionQuery(query),
1177
1193
  });
1178
1194
  return normalizeSubjectCollectionPage(result);