Commit Graph
613 Commits
Author SHA1 Message Date
TIANYAO ZHANG a47917afb1 Integrate upstream and honor music-account revocations during FM 2026-11-18 16:55:49 +08:00
TIANYAO ZHANG 0808cde447 Integrate QQ renewal and enforce music account assignment rules 2026-11-18 16:51:32 +08:00
YilingandTIANYAO ZHANG 2792a86a6c fix(netease): support configurable realIP and align playback User-Agent (#190)
* Add configurable NetEase real IP in web settings

* Match NetEase playback User-Agent to cookie platform

* fix(netease): keep playback UA aligned with cookie profile

---------

Co-authored-by: TIANYAO ZHANG <88520881+ZHANGTIANYAO1@users.noreply.github.com>
2026-11-18 16:49:36 +08:00
TIANYAO ZHANG 2b657ae338 Merge pull request #191 from NoSetViolin/codex/fix-bilibili-189
fix(bilibili): 修复部分 CDN 403 并保留视频分 P 参数
2026-11-18 16:49:28 +08:00
TIANYAO ZHANG 35fa3a95df Merge pull request #188 from NoSetViolin/zty-main-pr
feat(qq): 支持 QQ 音乐登录凭据自动续期
2026-11-18 16:49:20 +08:00
TIANYAO ZHANG 568d49f837 Merge pull request #184 from jiayuLian/fix/cookie-normalize
fix(music): cookie 里存的是整条 Set-Cookie,导致 /song/url 一律返回 400
2026-11-18 16:47:31 +08:00
TIANYAO ZHANG f2a72e3162 Merge pull request #178 from zbn297427669/fix/upstream-test-declick-ramp
test: catch bot tests up with the de-click transport ramp
2026-11-18 16:45:49 +08:00
TIANYAO ZHANG 9928035282 Merge cookie normalization into QQ session renewal 2026-11-18 16:43:49 +08:00
TIANYAO ZHANG 79e9cd797c fix(bilibili): read the page query from the pasted video link 2026-11-18 16:40:27 +08:00
TIANYAO ZHANG 51debb915c fix(music): handle multiple cookie headers and invalid saved values 2026-11-18 16:39:42 +08:00
NoSetViolin b7779ab108 fix(bilibili): preserve video pages and CDN playback headers 2026-11-12 18:07:52 +09:00
jiayuLian 91b2533176 fix(qq): import the running shared cookie into the account pool
`import-shared` read the cookie from qq.json, which is only the on-disk
copy. After #188 renews credentials through the managed session that file
goes stale, so this route would seed the pool with a dead cookie.

Prefer the running QQ provider's in-memory cookie and fall back to the
cookie store when no QQ provider is mounted (tests that only register
netease keep the old behaviour). Two regressions: the rotated cookie wins
over the file copy, and a provider without a login 409s instead of
creating a dead row.
2026-11-11 22:35:27 +08:00
NoSetViolin c3d06cb09a fix(qq): preserve login and playback key expiry 2026-11-11 11:09:42 +09:00
NoSetViolin 72e0d3a439 feat(qq): renew music sessions automatically 2026-11-09 23:07:45 +09:00
jiayuLian aceccc93e1 docs(web): spell out that room playback always uses the shared login
The account radio only governs the browser player (search, playlists, the
embedded preview). Playback inside the TeamSpeak room — a web-queued song, a
`!play` from chat, auto-advance — resolves through the bot's injected provider,
which is the shared login, unconditionally.

That is the intended design: membership is shared, library isolation is not.
A member without VIP still gets to hear paid tracks in the channel; they just
do not get their own recommendations in the web UI.

It was not obvious from the UI, though. "共享账号(管理员的)" reads like a
channel-wide switch, and a member who picked it would expect their play history
to land on the admin account everywhere — which it does, but for an unrelated
reason. Two notes now say so: one in the admin feature hint (what the toggle
does and does not affect), one under the member radio (that it is web-only).
2026-11-08 18:17:33 +08:00
jiayuLian d3eb6f2107 feat(music): let a member choose the shared login when their own has no VIP
The order was hardcoded: own account → assigned account → shared. That is the
right default (privacy first), but it leaves one common case stuck: a member's
own NetEase login is real but has no membership, while the admin's does. They
linked their account, so playback keeps using theirs, and every paid track
fails — with no way to say "just use the admin's for playback".

Two things now:

1. An explicit choice — `user_music_prefs` (userId + platform), exposed as
   GET/PUT `/api/me/music/:platform/preference` and a radio in the account
   card. `preferShared: true` outranks EVERYTHING, including `alwaysPersonal`
   (someone who chose membership over their own recommendations wants the
   shared login for FM too). It stores a flag, not a cookie — flipping it back
   restores the personal account untouched.

2. An automatic fallback for people who never touch the switch. Only
   `getSongUrl` is wrapped: if the personal account returns `url: null` or
   throws, the same track is retried once on the shared login. Search,
   playlists and FM stay on the member's own account — that is the point of
   per-user logins, and widening the fallback would leak their library back to
   the admin's.

Details:

- The fallback lives in `resolveProviderForRequest`, so every playback entry
  point (web click, chat !play, auto-advance, playlists) gets it by
  construction, and the shared instance is never mutated.
- `fallbackToShared: false` is available for callers that must stay strictly on
  the member's account; the default is on, because "my account has no VIP" is
  the complaint that produced this feature.
- The status payload now carries `preferShared` and `featureEnabled`, so the UI
  can render the radio without a second round-trip and hide it when the admin
  has the feature off (PUT answers 409 in that case).

13 new tests: preference overrides own + assigned + alwaysPersonal, feature-off
ignored, GET/PUT round-trip, per-platform isolation, stored cookie untouched,
non-boolean rejected, 409 when disabled; fallback on null, on throw, keeps the
personal result when it works, can be disabled, leaves the shared instance
untouched.
2026-11-08 18:10:08 +08:00
jiayuLian 4ac3309e34 fix(music): normalise pasted cookies so /song/url stops answering 400
A cookie file on a live deployment held this:

  MUSIC_A_T=1456043741268; Max-Age=2147483647; Expires=Thu, 25 Nov 2094 ...;
  Path=/api/clientlog;;MUSIC_R_T=...; Max-Age=...; Path=/eapi/feedback; ...

That is a `Set-Cookie` header pasted whole. The cookie is then handed to the
sidecar as `?cookie=<the whole thing>`, so `Max-Age`, `Expires` and `Path` are
read as cookie NAMES and the string grows to several KB before URL-encoding.

Measured on that box (data/logs/bot.log):

- 34 of 34 `/song/url/v1` calls failed with `ERR_BAD_REQUEST` (HTTP 400);
- the same failure is still happening today, e.g. 17:14 and 17:20 local;
- every one surfaced to the user as 「无法播放(区域/版权限制)」.

So the message people were chasing for weeks is not a copyright signal at all
— it is the sidecar rejecting a malformed request.

`normalizeCookie()` drops attribute pairs, the `Set-Cookie:` prefix, CR/LF and
duplicate names, and keeps only real `name=value` pairs. It is applied:

- on `save()`, so nothing malformed reaches the file again;
- on `load()`, and **written back when it differs** — an existing deployment is
  repaired in place without asking anyone to scan a QR code again;
- in `setCookie()` of all four providers, including Kugou, which parses into a
  map and would otherwise store `max-age` as a device field.

jellyfin is excluded: its blob is JSON (accessToken/userId/deviceId), not a
cookie header, and normalising it would shred the payload. A test pins that.

Valid cookies are untouched — `normalizeCookie` is idempotent and byte-exact on
a clean string, and a clean file is not rewritten.

This does not overlap with the play-URL retry PR: that one retries a genuine
`url: null`, this one stops the request from being rejected before it is sent.
Both are needed — retrying a 400 just gets four more 400s.
2026-11-08 17:41:58 +08:00
jiayuLian 1ef80be883 fix(music): default a new pool account to exclusive (capacity = 1)
Sharing one login between members mixes their playback history and
recommendations, which is almost never what an admin means by handing out an
account. Keep 0 (= unlimited) available, but not as the default.
2026-11-08 17:08:51 +08:00
jiayuLian 61c24cc219 feat(music): per-user music accounts with an admin-owned account pool
Every member saw the admin's library: the bot keeps one shared login per
platform (data/cookies/<platform>.json) and search, playlists and playback
URLs all read through it. #164 added a personal NetEase login, but only for
私人FM — the rest still came from the shared account.

On top of that, most members do not own a paid login, so "everyone links their
own" is not enough: the admin has to be able to hand out accounts.

What this adds, behind one admin switch (`perUserMusicAccounts`, default off):

- One login per request, resolved in this order: the caller's OWN linked
  account, then an account an admin ASSIGNED, then the bot's shared login.
- An admin-owned pool (`music_accounts`) plus per-member assignments
  (`music_account_grants`, PK userId+platform = one per platform). Assignments
  are capacity-checked inside a transaction, so an exclusive account cannot be
  handed to two members by two concurrent clicks. `enabled = 0` is an instant
  rollback of every grant without deleting them.
- Own-beats-assigned, and the two live in separate tables: a member scanning
  their own QR code never overwrites an admin's assignment, and unlinking on
  the member side never revokes what the admin granted.
- QQ / Kugou / Bilibili now implement `withCookie`, so all four sources can be
  isolated. Only NetEase exposes QR self-linking (it is the only one with
  `pollQrLogin`); the rest accept an assigned account, which is the workflow
  that actually matters for members without a paid login.
- `/api/music-accounts` is admin-only (`requireAdmin`, not `bot.manage`):
  members must never see which account was handed to whom. Cookies are masked
  in every response.

Switch off = no behaviour change at all, except 私人FM keeps the #164 behaviour
through `alwaysPersonal`.
2026-11-08 17:07:42 +08:00
zbn297427669andClaude Code ba645e5ccb test: catch bot tests up with the de-click transport ramp
Upstream a0f0b49..6f165b5 added the pause/resume fade tail but shipped no
test updates, leaving 5 assertions red (also reproducible on pristine
upstream/main, so not merge-induced).

- instance-recovery/instance harnesses: stub players borrow
  AudioPlayer.prototype.pause/resume, which now call this.setTransportRamp().
  Give the stubs that method or they throw TypeError on pause/resume.
- voice-failure: pausing deliberately emits a fade tail, so the frame count
  no longer freezes at exactly 50. Assert the de-click fade completes, then
  that the scheduler and elapsed clock are genuinely frozen — the actual
  behavior under test.

No production code changed.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-02 15:58:44 +08:00
TIANYAO ZHANG 17008ae52e Merge pull request #177 from EvolvedGhost/fix/audio-declick-seek v1.15.4 2026-10-22 09:00:11 +08:00
EvolvedGhost 6f165b5e88 fix(audio): preserve in-progress pause fade on stop 2026-10-17 23:42:07 +08:00
EvolvedGhost 7ee8b6f986 fix(audio): reset gain after graceful stop 2026-10-17 23:40:20 +08:00
EvolvedGhost 7896c9c9bf fix(audio): fade out on stop command 2026-10-17 23:35:23 +08:00
EvolvedGhost a0f0b49a4e fix(audio): prevent pops during playback controls 2026-10-17 23:30:18 +08:00
TIANYAO ZHANG c26998d296 Merge pull request #176 from NoSetViolin/main
整理设置页分类和创建实例布局,增加主题色与跟随系统外观
v1.15.3
2026-10-14 18:24:20 +08:00
NoSetViolin 8d750d19b0 feat: reorganize settings and add synced appearance preferences 2026-10-12 18:26:53 +09:00
TIANYAO ZHANG 28c128d0c9 fix: harden long-video recovery and voice transport handling (#161) v1.15.2 2026-10-04 01:27:52 +08:00
TIANYAO ZHANG e5879ea106 docs: describe v1.15.1 playback and privacy fixes v1.15.1 2026-10-03 21:03:06 +08:00
TIANYAO ZHANG 44a1457baa fix: isolate embedded music API credential logs 2026-10-03 21:03:05 +08:00
TIANYAO ZHANG a4c0239a59 fix: drain FFmpeg stderr and sanitize playback diagnostics 2026-10-03 21:03:04 +08:00
TIANYAO ZHANG 5258ba951b chore: prepare v1.15.0 release and exclude generated test copies v1.15.0 2026-10-03 17:25:02 +08:00
TIANYAO ZHANG d16aca2ba6 fix: honor artist shuffle permissions and discard stale page requests 2026-10-03 17:25:01 +08:00
TIANYAO ZHANG 9bcddb1881 fix: preserve pause intent and deduplicate stream recovery lookups 2026-10-03 17:17:53 +08:00
TIANYAO ZHANG cf83916f39 fix: serialize artist playback and keep incomplete QQ catalogs retryable 2026-10-03 17:17:35 +08:00
TIANYAO ZHANG f8b03acca3 fix: fence profile updates and check TeamSpeak permission failures 2026-10-03 17:17:35 +08:00
TIANYAO ZHANG b9c79c8138 fix: revoke API keys on password rotation and audit key owners 2026-10-03 17:17:34 +08:00
TIANYAO ZHANG 79fb8443be fix: fence stream recovery and EOF advancement by playback session 2026-10-03 16:55:34 +08:00
TIANYAO ZHANG c904190912 Merge pull request #170 from ZHANGTIANYAO1/fix/issue-161-bilibili-long-stream
# Conflicts:
#	src/bot/instance.test.ts
2026-10-03 16:50:49 +08:00
TIANYAO ZHANG 41b81a6193 Merge pull request #175 from zzstar101/feat/artist-search 2026-10-03 16:50:09 +08:00
TIANYAO ZHANG f495ca0ff4 Merge pull request #174 from razaxq/main 2026-10-03 16:50:09 +08:00
TIANYAO ZHANG bdb33df89d Merge pull request #173 from senlinjun/feat/restapi 2026-10-03 16:50:09 +08:00
TIANYAO ZHANG 3423bf502c docs: plan reviewed PR fixes and release validation 2026-10-03 16:50:08 +08:00
zzstar101 b6ad536bb7 feat(web): artist search, artist pages, and full-catalogue playback
Adds artist support for the NetEase and QQ providers plus the matching UI.

Backend:
- SearchResult gains `artists`; new optional MusicProvider methods
  getArtistDetail / getArtistSongs / getArtistAlbums / getArtistAllSongs.
- NetEase: /cloudsearch type=100 for artist search, /artists, /artist/songs,
  /artist/album and /artist/desc for the artist page.
- QQ: singer search rides along in the existing musicu.fcg batch
  (search_type=1); singer detail via music.web_singer_info_svr. QQ exposes no
  working singer-song paging endpoint, so the full catalogue is built from the
  hot 50 plus every album of the singer (album search filtered by singerMID,
  songs fetched per album, de-duplicated, cached for 10 minutes). A failed
  album sweep is never cached and degrades to the hot list.
- API: GET /api/music/artist/:id and POST /api/player/:botId/play-artist
  (player.control capability, guest flag playCollection); /search/all now
  aggregates artists too.

Frontend:
- Search history in localStorage (max 10, per platform, never shared between
  users), shown as a dropdown under the search box and as 最近搜索 chips.
- Artist row in the search results; new /artist/:id page (portrait, aliases,
  stats, description, top songs, album shelf) with 播放 / 随机播放, which queue
  the singer's whole catalogue.
- playArtist store action.

Tests cover the provider mappers, the new routes, the play-artist collector
(paging, de-duplication, 500-track cap), permission gating and the new views.
2026-10-02 01:36:03 +08:00
razaxq af4ca56fd3 fix(ts6): update the real music client profile 2026-10-01 21:32:21 +08:00
senlinjun bf7858db74 docs(api): document /api/me/music, bilibili parts and personal-FM behavior from v1.14.0
- new /api/me/music section (per-user NetEase account linking, key-compatible)
- GET /api/music/bilibili/parts endpoint
- /api/player/:botId/fm note: prefers the caller's own linked NetEase account
2026-09-29 21:55:53 +08:00
senlinjun e4eea8276a Merge remote-tracking branch 'origin/main' 2026-09-29 21:52:14 +08:00
senlinjun aab8a004ae feat(web): add API-key authentication for the REST API
- api_keys table + hashed key store (src/data/api-keys.ts), tsmb_-prefixed
  plaintext shown once, per-user cap of 20, lastUsedAt tracking
- requireAuth accepts Authorization: Bearer / X-API-Key headers as an
  alternative to the session cookie; key inherits the owner user's
  role/capabilities/bot scope
- csrf origin check skipped for key-only requests (no ambient credentials);
  requests that also carry the session cookie stay gated
- /api/keys management endpoints (session-only, guests excluded, keys
  themselves rejected) with audit logging
- user deletion / password reset cascade-revoke the user's keys
- Settings page: API key management section (create/copy-once/revoke)
- docs: README section + full endpoint reference in docs/API.md
2026-09-29 21:51:43 +08:00
TIANYAO ZHANGandClaude Opus 5.5 87fca6d8b7 docs: add v1.14.0 changelog entry
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
v1.14.0
2026-09-27 23:46:18 +08:00
TIANYAO ZHANG c7b1268281 Merge pull request #172 from ZHANGTIANYAO1/fix/issue-165-install-scripts
fix(install): bring install.sh up to Node 22 and document both Linux scripts (#165)
2026-09-27 23:44:44 +08:00