@audiofool/moondog 0.3.0-beta.8 → 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.
Files changed (66) hide show
  1. package/README.md +40 -12
  2. package/package.json +5 -4
  3. package/scripts/moondog.mjs +47 -9
  4. package/src/core/apple-projection-domain-services.mjs +4 -0
  5. package/src/core/capability-catalog.mjs +46 -14
  6. package/src/core/host.mjs +30 -0
  7. package/src/core/library-store.mjs +82 -6
  8. package/src/core/listening-now.mjs +7 -2
  9. package/src/core/listening-profile-domain-services.mjs +4 -0
  10. package/src/core/moondog-application.mjs +412 -144
  11. package/src/i18n/messages/de.mjs +4 -3
  12. package/src/i18n/messages/en.mjs +4 -3
  13. package/src/i18n/messages/es.mjs +4 -3
  14. package/src/i18n/messages/fr.mjs +4 -3
  15. package/src/i18n/messages/it.mjs +4 -3
  16. package/src/i18n/messages/ja.mjs +4 -3
  17. package/src/i18n/messages/ko.mjs +4 -3
  18. package/src/i18n/messages/pt.mjs +4 -3
  19. package/src/i18n/messages/zh-Hant.mjs +4 -3
  20. package/src/i18n/messages/zh.mjs +4 -3
  21. package/src/i18n/screen/es.mjs +52 -6
  22. package/src/i18n/screen/ja.mjs +52 -6
  23. package/src/i18n/screen/pt.mjs +52 -6
  24. package/src/i18n/screen/zh.mjs +52 -6
  25. package/src/importers/zip-reader.mjs +61 -0
  26. package/src/integrations/apple-music/music-app.mjs +3 -2
  27. package/src/integrations/lastfm/history.mjs +2 -1
  28. package/src/integrations/lyrics/lrclib.mjs +1 -1
  29. package/src/integrations/netease/ncm-cli-player.mjs +62 -20
  30. package/src/integrations/open-music-similarity/artist-radio.mjs +3 -3
  31. package/src/integrations/playlist-links.mjs +114 -0
  32. package/src/integrations/public-playlists.mjs +41 -8
  33. package/src/integrations/spotify/account-data-history.mjs +63 -57
  34. package/src/integrations/spotify/authentication.mjs +2 -22
  35. package/src/integrations/spotify/extended-streaming-history.mjs +48 -40
  36. package/src/integrations/spotify/history-archive.mjs +2 -13
  37. package/src/integrations/spotify/service.mjs +88 -58
  38. package/src/integrations/spotify/web-api-client.mjs +12 -4
  39. package/src/integrations/user-agent.mjs +6 -0
  40. package/src/integrations/web/codex-web.mjs +3 -1
  41. package/src/integrations/web/deepseek-web.mjs +1 -1
  42. package/src/integrations/web/web-research.mjs +84 -17
  43. package/src/integrations/web/web-result.mjs +60 -12
  44. package/src/integrations/youtube-music/takeout.mjs +11 -16
  45. package/src/profile/history-import.mjs +3 -1
  46. package/src/profile/listening-history-store.mjs +55 -1
  47. package/src/profile/listening-profile-projection.mjs +1 -1
  48. package/src/profile/music-import-bundle.mjs +3 -1
  49. package/src/profile/music-providers.mjs +3 -0
  50. package/src/runtime/pi/agent-runtime.mjs +244 -146
  51. package/src/runtime/pi/configured-runtime.mjs +3 -0
  52. package/src/runtime/pi/image-input.mjs +148 -0
  53. package/src/runtime/pi/model-roles.mjs +121 -0
  54. package/src/runtime/pi/model-settings.mjs +112 -6
  55. package/src/runtime/pi/model-transport.mjs +9 -0
  56. package/src/runtime/pi/moondog-model.mjs +158 -0
  57. package/src/runtime/pi/next-songs.mjs +71 -0
  58. package/src/runtime/pi/persistent-credential-store.mjs +2 -0
  59. package/src/runtime/pi/public-model-catalog.mjs +10 -3
  60. package/src/runtime/pi/runtime-settings.mjs +7 -3
  61. package/src/surfaces/cli/brand-components.mjs +1 -1
  62. package/src/surfaces/cli/command-completions.mjs +43 -3
  63. package/src/surfaces/cli/format-output.mjs +19 -7
  64. package/src/surfaces/cli/invite-command.mjs +65 -0
  65. package/src/surfaces/cli/model-roles-command.mjs +60 -0
  66. package/src/surfaces/cli/tui.mjs +87 -5
@@ -22,7 +22,7 @@ export default {
22
22
  "What have you been listening to?": "最近在听什么?",
23
23
  "A song, a playlist, or what to play next.": "一首歌、一个歌单,或者接下来放什么。",
24
24
  "Your personal music agent.": "你的私人音乐助手。",
25
- "# Your listening room\n\n## 01 / Listen and discover\n\nJust type to talk about music, ask for a playlist, or go exploring.\nTo talk, Moondog needs a model: `/auth` signs you in, then `/model` picks one.\nWhile an answer is coming, each step shows in the conversation, and the footer names the one in progress.\n\n- `/taste` - your profile: open any song or artist to see why it's there\n- `/taste report` - the whole picture on one page\n- `/import` - bring in your history, your library, or a playlist\n- `/lyrics` - the lyrics on the sleeve; `/lyrics sync` finds more\n- `/service` - choose where I play music: Spotify, Apple Music, or NetEase\n- `/spotify` - play, queue, and make playlists in Spotify\n- Ask to move playback onto your iPhone, computer, or another Spotify device by name\n- `/web search <query>` or `/web read <url>` - look things up on public music sites\n\n## 02 / Make it yours\n\n- `/profile` - the same profile as `/taste`\n- `/profile corrections` - everything you've told me\n- `/profile retract <id>` - undo one of those\n- `/profile help` - the full set of profile commands\n- `/remember <text>`, `/memory`, `/forget <id>` - what I remember between conversations\n\n## 03 / Around the room\n\n- `/home` - back to the record sleeve; the conversation stays\n- `/theme paper|charcoal|terminal|auto` - change the look\n- `/art braille|ascii|off` - change the artwork\n- `/motion on|off` - turn the animation on or off\n- `/commands` or Ctrl+P - search every command; your message stays put\n- Page Up and Page Down scroll the conversation. The header and your draft stay put\n- Up and Down in the draft recall what you typed in this conversation\n- `/resume` - pick up a saved conversation (type to filter, Enter opens)\n- `/new` - start fresh; this conversation stays saved\n- `/status`, `/sources`, `/tools`, `/doctor` - see what's connected and working\n- `/reload` - reload model settings and sign-ins\n- `/update [--check] [--channel latest|beta]` - check for a release, or close this room and install it\n- `/help all` - every command, including the ones for the shell\n- `/language` - choose the language Moondog uses\n- `/quit` - leave\n\nTab moves to the menu on the home screen. Esc goes back to typing.\nEnter sends, and Shift+Enter starts a new line.\nTab or Enter accepts a suggestion.\nCtrl+C stops a model or web request, or leaves when nothing is running.\nIn the profile, type to filter, Tab switches lists, and Enter shows what you can do.\nCtrl+R refreshes it and Ctrl+O opens the full report.\nYour profile works without a model.\nPut quotes around paths, titles, and names that have spaces.": "# 你的聆听室\n\n## 01 / 听歌与发现\n\n直接输入就能聊音乐、要一个歌单,或者随便逛逛。\n对话需要一个模型:`/auth` 登录,然后用 `/model` 选一个。\n回答生成时,每一步都会显示在对话里,底栏会标出正在进行的那一步。\n\n- `/taste` - 你的资料:打开任意歌曲或艺人,看看它为什么在这里\n- `/taste report` - 一页看完整体情况\n- `/import` - 导入你的历史、曲库或一个歌单\n- `/lyrics` - 封套上的歌词;`/lyrics sync` 找更多\n- `/service` - 选择我在哪里放音乐:Spotify、Apple Music 或网易云音乐\n- `/spotify` - 在 Spotify 里播放、加入队列、建歌单\n- 说出设备名,就能把播放切到你的 iPhone、电脑或其他 Spotify 设备\n- `/web search <关键词>` 或 `/web read <网址>` - 在公开音乐网站上查资料\n\n## 02 / 变成你的\n\n- `/profile` - 和 `/taste` 是同一份资料\n- `/profile corrections` - 你告诉过我的所有选择\n- `/profile retract <id>` - 撤销其中一项\n- `/profile help` - 资料相关的全部命令\n- `/remember <内容>`、`/memory`、`/forget <id>` - 我在对话之间记住的内容\n\n## 03 / 在房间里转转\n\n- `/home` - 回到唱片封套;对话还在\n- `/theme paper|charcoal|terminal|auto` - 换外观\n- `/art braille|ascii|off` - 换插画\n- `/motion on|off` - 打开或关闭动画\n- `/commands` 或 Ctrl+P - 搜索全部命令;你正在写的消息不会丢\n- Page Up 和 Page Down 滚动对话,顶栏和草稿保持不动\n- 在草稿里按上下键,可以找回本次对话中输入过的内容\n- `/resume` - 继续一段保存的对话(输入筛选,Enter 打开)\n- `/new` - 重新开始;这段对话会保存下来\n- `/status`、`/sources`、`/tools`、`/doctor` - 看看哪些已连接、正常工作\n- `/reload` - 重新加载模型设置和登录\n- `/update [--check] [--channel latest|beta]` - 检查新版本,或关闭聆听室并安装\n- `/help all` - 全部命令,包括终端里的\n- `/language` - 选择 Moondog 使用的语言\n- `/quit` - 离开\n\n在首页按 Tab 进入菜单,按 Esc 回到输入。\nEnter 发送,Shift+Enter 换行。\nTab 或 Enter 接受补全建议。\nCtrl+C 停止模型或网页请求;没有任务在运行时则退出。\n在资料页里,输入即可筛选,Tab 切换列表,Enter 查看可做的操作。\nCtrl+R 刷新,Ctrl+O 打开完整报告。\n没有模型,资料页也能用。\n路径、标题和名字里有空格时,请加上引号。",
25
+ "# Your listening room\n\n## 01 / Listen and discover\n\nJust type to talk about music, ask for a playlist, or go exploring.\nTo talk, Moondog needs a model: `/auth` signs you in, then `/model` picks one.\nWhile an answer is coming, each step shows in the conversation, and the footer names the one in progress.\n\n- `/taste` - your profile: open any song or artist to see why it's there\n- `/taste report` - the whole picture on one page\n- `/import` - bring in your history, your library, or a playlist\n- `/library` - your saved songs and playlists\n- `/generation on|off` - let Moondog make music on this Mac, or stop\n- `/onair` - go on air, or come off it\n- `/lyrics` - the lyrics on the sleeve; `/lyrics sync` finds more\n- `/service` - choose where I play music: Spotify, Apple Music, or NetEase\n- `/spotify` - play, queue, and make playlists in Spotify\n- Ask to move playback onto your iPhone, computer, or another Spotify device by name\n- `/web search <query>` or `/web read <url>` - look things up on public music sites\n\n## 02 / Make it yours\n\n- `/profile` - the same profile as `/taste`\n- `/profile corrections` - everything you've told me\n- `/profile retract <id>` - undo one of those\n- `/profile help` - the full set of profile commands\n- `/remember <text>`, `/memory`, `/forget <id>` - what I remember between conversations\n\n## 03 / Around the room\n\n- `/home` - back to the record sleeve; the conversation stays\n- `/theme paper|charcoal|terminal|auto` - change the look\n- `/art braille|ascii|off` - change the artwork\n- `/motion on|off` - turn the animation on or off\n- `/commands` or Ctrl+P - search every command; your message stays put\n- Page Up and Page Down scroll the conversation. The header and your draft stay put\n- Up and Down in the draft recall what you typed in this conversation\n- `/resume` - pick up a saved conversation (type to filter, Enter opens)\n- `/new` - start fresh; this conversation stays saved\n- `/rewind` or Alt+R - edit an earlier message in place; the messages after it are replaced\n- `/branch` - go on from here in a new conversation; this one stays saved\n- `/status`, `/sources`, `/tools`, `/doctor` - see what's connected and working\n- `/reload` - reload model settings and sign-ins\n- `/model roles` - see what side tasks use: the model that reads images and the web search service\n- `/effort` - choose how hard the model thinks\n- `/endpoint add` or `/endpoint remove <id>` - add a model service by its address, or remove it\n- `/update [--check] [--channel latest|beta]` - check for a release, or close this room and install it\n- `/help all` - every command, including the ones for the shell\n- `/language` - choose the language Moondog uses\n- `/quit` - leave\n\nTab moves to the menu on the home screen. Esc goes back to typing.\nEnter sends, and Shift+Enter starts a new line.\nTab or Enter accepts a suggestion.\nCtrl+C stops a model or web request, or leaves when nothing is running.\nIn the profile, type to filter, Tab switches lists, and Enter shows what you can do.\nCtrl+R refreshes it and Ctrl+O opens the full report.\nYour profile works without a model.\nPut quotes around paths, titles, and names that have spaces.": "# 你的聆听室\n\n## 01 / 听歌与发现\n\n直接输入就能聊音乐、要一个歌单,或者随便逛逛。\n对话需要一个模型:`/auth` 登录,然后用 `/model` 选一个。\n回答生成时,每一步都会显示在对话里,底栏会标出正在进行的那一步。\n\n- `/taste` - 你的资料:打开任意歌曲或艺人,看看它为什么在这里\n- `/taste report` - 一页看完整体情况\n- `/import` - 导入你的历史、曲库或一个歌单\n- `/library` - 你收藏的歌和播放列表\n- `/generation on|off` - 让 Moondog 在这台 Mac 上做音乐,或停下\n- `/onair` - 开播,或下播\n- `/lyrics` - 封套上的歌词;`/lyrics sync` 找更多\n- `/service` - 选择我在哪里放音乐:Spotify、Apple Music 或网易云音乐\n- `/spotify` - 在 Spotify 里播放、加入队列、建歌单\n- 说出设备名,就能把播放切到你的 iPhone、电脑或其他 Spotify 设备\n- `/web search <关键词>` 或 `/web read <网址>` - 在公开音乐网站上查资料\n\n## 02 / 变成你的\n\n- `/profile` - 和 `/taste` 是同一份资料\n- `/profile corrections` - 你告诉过我的所有选择\n- `/profile retract <id>` - 撤销其中一项\n- `/profile help` - 资料相关的全部命令\n- `/remember <内容>`、`/memory`、`/forget <id>` - 我在对话之间记住的内容\n\n## 03 / 在房间里转转\n\n- `/home` - 回到唱片封套;对话还在\n- `/theme paper|charcoal|terminal|auto` - 换外观\n- `/art braille|ascii|off` - 换插画\n- `/motion on|off` - 打开或关闭动画\n- `/commands` 或 Ctrl+P - 搜索全部命令;你正在写的消息不会丢\n- Page Up 和 Page Down 滚动对话,顶栏和草稿保持不动\n- 在草稿里按上下键,可以找回本次对话中输入过的内容\n- `/resume` - 继续一段保存的对话(输入筛选,Enter 打开)\n- `/new` - 重新开始;这段对话会保存下来\n- `/rewind` 或 Alt+R - 就地编辑之前的一条消息;之后的消息会被替换\n- `/branch` - 从这里在新对话中继续;这段对话会保留\n- `/status`、`/sources`、`/tools`、`/doctor` - 看看哪些已连接、正常工作\n- `/reload` - 重新加载模型设置和登录\n- `/model roles` - 看看副任务在用什么:读图的模型和网页搜索服务\n- `/effort` - 选择模型思考的程度\n- `/endpoint add` 或 `/endpoint remove <id>` - 按地址添加模型服务,或移除它\n- `/update [--check] [--channel latest|beta]` - 检查新版本,或关闭聆听室并安装\n- `/help all` - 全部命令,包括终端里的\n- `/language` - 选择 Moondog 使用的语言\n- `/quit` - 离开\n\n在首页按 Tab 进入菜单,按 Esc 回到输入。\nEnter 发送,Shift+Enter 换行。\nTab 或 Enter 接受补全建议。\nCtrl+C 停止模型或网页请求;没有任务在运行时则退出。\n在资料页里,输入即可筛选,Tab 切换列表,Enter 查看可做的操作。\nCtrl+R 刷新,Ctrl+O 打开完整报告。\n没有模型,资料页也能用。\n路径、标题和名字里有空格时,请加上引号。",
26
26
  "Listening profile": "聆听资料",
27
27
  "Profile": "资料",
28
28
  "See what your listening reveals. Tell me what I missed.": "看看你的聆听透露了什么,告诉我哪里没看到。",
@@ -164,6 +164,10 @@ export default {
164
164
  "ok": "正常",
165
165
  "not set up (optional)": "未设置(可选)",
166
166
  "not working": "不可用",
167
+ "No library yet": "还没有曲库",
168
+ "waits for your library": "等你的曲库",
169
+ "Type `/import` in `moondog` to bring in your listening from Spotify, Apple Music, Last.fm or a playlist link.": "在 `moondog` 里输入 `/import`,从 Spotify、Apple Music、Last.fm 或一个歌单链接导入你的聆听。",
170
+ "To try it first, `moondog demo-history --output <absolute-file.zip>` makes a fictional Spotify history to import.": "想先试试的话,`moondog demo-history --output <绝对路径.zip>` 会生成一份虚构的 Spotify 历史供导入。",
167
171
  "Talking through `{model}`": "正在通过 `{model}` 对话",
168
172
  "Talking through your chosen model": "正在通过你选择的模型对话",
169
173
  "Not signed in yet. `/auth` fixes that.": "还没有登录。用 `/auth` 登录。",
@@ -176,7 +180,7 @@ export default {
176
180
  "Memory": "记忆",
177
181
  "Right now I can't change anything in your music accounts.": "目前我不能修改你音乐账号里的任何内容。",
178
182
  "I can make changes in your connected accounts, and I always ask first.": "我可以修改你已连接的账号,并且每次都会先问你。",
179
- "# Every command\n\nFrom your shell:\n\n- `moondog --version` - show the installed version\n- `moondog update [--check] [--channel latest|beta]` - check for or install a published release\n- `moondog web status|search|read [arguments] [--json]` - look things up on public music sites through DeepSeek, Brave Search or the Codex CLI\n- `moondog demo-history --output <absolute-file.zip> [--json]` - make a fictional Spotify history ZIP to try the importer with\n- `moondog auth login <provider>` - sign in to a model provider; the key is typed out of sight; `openai --chatgpt` signs in with your ChatGPT subscription\n- `moondog auth status [provider]` - see which sign-ins are saved\n- `moondog auth logout <provider>` - sign out of a provider\n- `moondog spotify help` - set up and control Spotify\n- `moondog spotify login [client-id]` - connect Spotify in your browser\n- `moondog spotify now|devices|queue` - see what Spotify is playing, where, and what's next\n- `moondog spotify recent` - see what you played lately\n- `moondog spotify sync-recent` - add your latest plays to your profile\n- `moondog spotify sync-library` - add your Spotify library to your profile\n- `moondog spotify play|pause|next|previous` - control Spotify playback\n- `moondog listenbrainz import-history <listen-history.json>` - add a ListenBrainz listens file to your profile\n- `moondog catalog latest-single --artist <name> [--known-release <title> | --from <spotify-history.zip>]` - find an artist's latest single on Apple Music (US), no model needed\n- `moondog status [--json]` - see where things stand\n- `moondog taste [--json]` - your listening report\n- `moondog taste --html [--output <file.html>]` - save your report as a web page that works offline\n- `moondog taste --card [--output <file.html>]` - save a short recap you can check before sharing\n- `moondog taste --from <spotify-history.zip> --html` - a one-off report from a Spotify ZIP, without saving it\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - a one-off report from both Spotify exports together\n- `moondog taste --from <spotify-history.zip> --save --html` - save the Spotify history, then show your full report\n- `moondog data inspect --scope <listening|apple|profile>` - see what's stored, and get the code needed to reset it\n- `moondog data export --scope <listening|apple|profile> --output <directory>` - export a copy, leaving the original alone\n- `moondog data reset --scope <listening|apple|profile> --confirm <token>` - set stored data aside (it is archived, not deleted)\n- `moondog profile build [--force]` - build or resume a saved profile with your connected model\n- `moondog profile saved [offset]` - read your saved profile\n- `moondog profile explain <number>` - trace a saved finding to its evidence\n- `moondog profile corrections [--all]` - everything you've told me, including earlier choices\n- `moondog profile correct --artist <name> (--like|--avoid)` - like an artist, or keep them out\n- `moondog profile correct --track <title> --by <artist> (--like|--avoid)` - like a track, or keep it out\n- `moondog profile retract <correction-id>` - undo one of your choices\n- `moondog demo --offline [--json]` - a demo with made-up data, no sign-in needed\n- `moondog demo [prompt] [--json]` - the same demo, talking through your model\n- `moondog ask <prompt>` - ask one question and exit\n- `moondog remember <text>` - ask me to remember something\n- `moondog forget <memory-id>` - forget something\n- `moondog memory reflect [--dry-run] [--json]` - let me think over recent conversations now\n- `moondog` - open the listening room\n\nInside the listening room:\n\n- `/update [--check] [--channel latest|beta]` - check for updates, or save and close this session to install one\n- `/status` or `/sources` - see where things stand\n- `/profile` or `/taste` - your profile, and why each song or artist is there\n- `/taste report` - the whole report on one page\n- `/profile build [--force]` - build or resume a saved reading; Ctrl+C keeps progress\n- `/profile saved [offset]` - read your saved profile\n- `/profile explain <number>` - inspect a saved finding's evidence\n- `/profile corrections [--all]` - everything you've told me\n- `/profile correct --track \"<title>\" --by \"<artist>\" (--like|--avoid)` - like a track, or keep it out\n- `/profile correct --artist \"<name>\" (--like|--avoid)` - like an artist, or keep them out\n- `/profile retract <correction-id>` - undo a choice\n- `/memory` - what I remember\n- `/tools` - what I can do right now\n- `/doctor` - check your setup\n- `/model` - pick the model I talk through\n- `/model <provider> <model>` - switch straight to a model\n- `/model refresh [provider]` - update public model choices; keep the selected model\n- `/auth [provider]` - sign in to a model provider\n- `/web status|search|read` - look things up on public music sites\n- `/import [path]` - bring in your history, library, or a playlist\n- `/language` - choose the language Moondog uses\n- `/service [spotify|apple_music|netease]` - choose where I play music\n- `/spotify` - Spotify commands\n- `/spotify login [client-id]` - connect Spotify\n- `/spotify now|devices|queue` - see what's playing, where, and what's next\n- `/spotify recent|sync-recent` - see or save your latest plays\n- `/spotify import-history \"/path/to/spotify-history.zip\"` - add a Spotify ZIP, no sign-in needed\n- `/skip` or `/stop` - move to the next song preview, or stop them\n- `/reload` - reload model settings and sign-ins\n- `/remember [kind] <text>` - ask me to remember something\n- `/forget <memory-id>` - forget something\n- `/rewind` or Alt+R - edit an earlier message in place; the messages after it are replaced\n- `/branch` - go on from here in a new conversation; this one stays saved\n- `/rewind latest` - edit the most recent message\n- `/resume` - pick up a saved conversation\n- `/resume <session-id>` - go straight to one\n- `/new` - start fresh; the last one stays saved\n- `/quit` - exit\n\nAnything you type that isn't a command goes to the model you picked with `/model`, or the one set in `MOONDOG_PROVIDER` and `MOONDOG_MODEL`.\nSign in with `/auth`, or set the provider's API key in your environment. `/auth openai` signs in with your ChatGPT subscription or an API key.\nOnce your profile is ready, I can search your library, explain what I see, and plan playlists with you.\nI can only control Spotify after `moondog spotify login`, and I never post, send messages, delete anything, or spend money.\nAsk me to move playback onto a device by name, such as your iPhone.": "# 全部命令\n\n在终端里:\n\n- `moondog --version` - 显示已安装的版本\n- `moondog update [--check] [--channel latest|beta]` - 检查或安装已发布的版本\n- `moondog web status|search|read [参数] [--json]` - 通过 DeepSeek、Brave Search 或 Codex CLI 在公开音乐网站上查资料\n- `moondog demo-history --output <绝对路径.zip> [--json]` - 生成一个虚构的 Spotify 历史 ZIP,用来试用导入\n- `moondog auth login <provider>` - 登录模型服务商;密钥输入时不显示,`openai --chatgpt` 用你的 ChatGPT 订阅登录\n- `moondog auth status [provider]` - 查看保存了哪些登录\n- `moondog auth logout <provider>` - 退出某个服务商\n- `moondog spotify help` - 设置并控制 Spotify\n- `moondog spotify login [client-id]` - 在浏览器里连接 Spotify\n- `moondog spotify now|devices|queue` - 查看 Spotify 正在放什么、在哪放、接下来是什么\n- `moondog spotify recent` - 查看你最近听了什么\n- `moondog spotify sync-recent` - 把最近的播放加入你的资料\n- `moondog spotify sync-library` - 把你的 Spotify 曲库加入你的资料\n- `moondog spotify play|pause|next|previous` - 控制 Spotify 播放\n- `moondog listenbrainz import-history <listen-history.json>` - 把 ListenBrainz 收听文件加入你的资料\n- `moondog catalog latest-single --artist <名字> [--known-release <标题> | --from <spotify-history.zip>]` - 在 Apple Music(美区)查找某位艺人的最新单曲,无需模型\n- `moondog status [--json]` - 查看当前状态\n- `moondog taste [--json]` - 你的聆听报告\n- `moondog taste --html [--output <文件.html>]` - 把报告保存为可离线打开的网页\n- `moondog taste --card [--output <文件.html>]` - 保存一份简短回顾,分享前可以先检查\n- `moondog taste --from <spotify-history.zip> --html` - 从一个 Spotify ZIP 生成一次性报告,不保存\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - 从两份 Spotify 导出一起生成一次性报告\n- `moondog taste --from <spotify-history.zip> --save --html` - 保存 Spotify 历史,然后显示完整报告\n- `moondog data inspect --scope <listening|apple|profile>` - 查看保存了什么,并获取重置所需的代码\n- `moondog data export --scope <listening|apple|profile> --output <目录>` - 导出一份副本,原件保持不变\n- `moondog data reset --scope <listening|apple|profile> --confirm <代码>` - 把保存的数据移到一边(归档,不删除)\n- `moondog profile build [--force]` - 用已连接的模型生成或继续生成保存的资料\n- `moondog profile saved [偏移]` - 阅读你保存的资料\n- `moondog profile explain <编号>` - 追溯一条已保存发现的证据\n- `moondog profile corrections [--all]` - 你告诉过我的所有选择,包括早先的\n- `moondog profile correct --artist <名字> (--like|--avoid)` - 标记喜欢某位艺人,或不再推荐\n- `moondog profile correct --track <歌名> --by <艺人> (--like|--avoid)` - 标记喜欢某首歌,或不再推荐\n- `moondog profile retract <correction-id>` - 撤销你的一项选择\n- `moondog demo --offline [--json]` - 用虚构数据的演示,无需登录\n- `moondog demo [提示] [--json]` - 同样的演示,通过你的模型对话\n- `moondog ask <提示>` - 问一个问题后退出\n- `moondog remember <内容>` - 让我记住一件事\n- `moondog forget <memory-id>` - 忘掉一件事\n- `moondog memory reflect [--dry-run] [--json]` - 让我现在回顾最近的对话\n- `moondog` - 打开聆听室\n\n在聆听室里:\n\n- `/update [--check] [--channel latest|beta]` - 检查更新,或保存并关闭本次会话来安装\n- `/status` 或 `/sources` - 查看当前状态\n- `/profile` 或 `/taste` - 你的资料,以及每首歌、每位艺人为什么在这里\n- `/taste report` - 一页看完整份报告\n- `/profile build [--force]` - 生成或继续生成保存的解读;Ctrl+C 会保留进度\n- `/profile saved [偏移]` - 阅读你保存的资料\n- `/profile explain <编号>` - 查看一条已保存发现的证据\n- `/profile corrections [--all]` - 你告诉过我的所有选择\n- `/profile correct --track \"<歌名>\" --by \"<艺人>\" (--like|--avoid)` - 标记喜欢某首歌,或不再推荐\n- `/profile correct --artist \"<名字>\" (--like|--avoid)` - 标记喜欢某位艺人,或不再推荐\n- `/profile retract <correction-id>` - 撤销一项选择\n- `/memory` - 我记住的内容\n- `/tools` - 我现在能做什么\n- `/doctor` - 检查你的设置\n- `/model` - 选择我用来对话的模型\n- `/model <provider> <model>` - 直接切换到某个模型\n- `/model refresh [provider]` - 更新公开的模型列表;保留当前选择\n- `/auth [provider]` - 登录模型服务商\n- `/web status|search|read` - 在公开音乐网站上查资料\n- `/import [路径]` - 导入你的历史、曲库或一个歌单\n- `/language` - 选择 Moondog 使用的语言\n- `/service [spotify|apple_music|netease]` - 选择我在哪里放音乐\n- `/spotify` - Spotify 命令\n- `/spotify login [client-id]` - 连接 Spotify\n- `/spotify now|devices|queue` - 查看正在放什么、在哪放、接下来是什么\n- `/spotify recent|sync-recent` - 查看或保存你最近的播放\n- `/spotify import-history \"/path/to/spotify-history.zip\"` - 加入一个 Spotify ZIP,无需登录\n- `/skip` 或 `/stop` - 跳到下一首试听,或停止试听\n- `/reload` - 重新加载模型设置和登录\n- `/remember [类型] <内容>` - 让我记住一件事\n- `/forget <memory-id>` - 忘掉一件事\n- `/rewind` 或 Alt+R - 就地编辑之前的一条消息;之后的消息会被替换\n- `/branch` - 从这里在新对话中继续;这段对话会保留\n- `/rewind latest` - 编辑最近的一条消息\n- `/resume` - 继续一段保存的对话\n- `/resume <session-id>` - 直接打开某一段\n- `/new` - 重新开始;上一段会保存下来\n- `/quit` - 退出\n\n你输入的非命令内容,会发给你用 `/model` 选的模型,或 `MOONDOG_PROVIDER` 和 `MOONDOG_MODEL` 指定的模型。\n用 `/auth` 登录,或在环境变量里设置服务商的 API 密钥。`/auth openai` 可以用 ChatGPT 订阅登录,也可以填 API 密钥。\n资料准备好之后,我可以搜索你的曲库、解释我看到的内容,并和你一起规划歌单。\n只有在 `moondog spotify login` 之后我才能控制 Spotify,而且我从不发帖、不发消息、不删除任何东西,也不花钱。\n说出设备名,比如你的 iPhone,我就能把播放切过去。",
183
+ "# Every command\n\nFrom your shell:\n\n- `moondog --version` - show the installed version\n- `moondog update [--check] [--channel latest|beta]` - check for or install a published release\n- `moondog web status|search|read [arguments] [--json]` - look things up on public music sites through DeepSeek, Brave Search or the Codex CLI\n- `moondog demo-history --output <absolute-file.zip> [--json]` - make a fictional Spotify history ZIP to try the importer with\n- `moondog auth login <provider>` - sign in to a model provider; the key is typed out of sight; `openai --chatgpt` signs in with your ChatGPT subscription\n- `moondog auth status [provider]` - see which sign-ins are saved\n- `moondog auth logout <provider>` - sign out of a provider\n- `moondog spotify help` - set up and control Spotify\n- `moondog spotify login [client-id]` - connect Spotify in your browser\n- `moondog spotify now|devices|queue` - see what Spotify is playing, where, and what's next\n- `moondog spotify recent` - see what you played lately\n- `moondog spotify sync-recent` - add your latest plays to your profile\n- `moondog spotify sync-library` - add your Spotify library to your profile\n- `moondog spotify play|pause|next|previous` - control Spotify playback\n- `moondog listenbrainz import-history <listen-history.json>` - add a ListenBrainz listens file to your profile\n- `moondog catalog latest-single --artist <name> [--known-release <title> | --from <spotify-history.zip>]` - find an artist's latest single on Apple Music (US), no model needed\n- `moondog status [--json]` - see where things stand\n- `moondog taste [--json]` - your listening report\n- `moondog taste --html [--output <file.html>]` - save your report as a web page that works offline\n- `moondog taste --card [--output <file.html>]` - save a short recap you can check before sharing\n- `moondog taste --from <spotify-history.zip> --html` - a one-off report from a Spotify ZIP, without saving it\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - a one-off report from both Spotify exports together\n- `moondog taste --from <spotify-history.zip> --save --html` - save the Spotify history, then show your full report\n- `moondog data inspect --scope <listening|apple|profile>` - see what's stored, and get the code needed to reset it\n- `moondog data export --scope <listening|apple|profile> --output <directory>` - export a copy, leaving the original alone\n- `moondog data reset --scope <listening|apple|profile> --confirm <token>` - set stored data aside (it is archived, not deleted)\n- `moondog profile build [--force]` - build or resume a saved profile with your connected model\n- `moondog profile saved [offset]` - read your saved profile\n- `moondog profile explain <number>` - trace a saved finding to its evidence\n- `moondog profile corrections [--all]` - everything you've told me, including earlier choices\n- `moondog profile correct --artist <name> (--like|--avoid)` - like an artist, or keep them out\n- `moondog profile correct --track <title> --by <artist> (--like|--avoid)` - like a track, or keep it out\n- `moondog profile retract <correction-id>` - undo one of your choices\n- `moondog demo --offline [--json]` - a demo with made-up data, no sign-in needed\n- `moondog demo [prompt] [--json]` - the same demo, talking through your model\n- `moondog ask <prompt>` - ask one question and exit\n- `moondog remember <text>` - ask me to remember something\n- `moondog forget <memory-id>` - forget something\n- `moondog memory reflect [--dry-run] [--json]` - let me think over recent conversations now\n- `moondog` - open the listening room\n\nInside the listening room:\n\n- `/update [--check] [--channel latest|beta]` - check for updates, or save and close this session to install one\n- `/status` or `/sources` - see where things stand\n- `/profile` or `/taste` - your profile, and why each song or artist is there\n- `/taste report` - the whole report on one page\n- `/profile build [--force]` - build or resume a saved reading; Ctrl+C keeps progress\n- `/profile saved [offset]` - read your saved profile\n- `/profile explain <number>` - inspect a saved finding's evidence\n- `/profile corrections [--all]` - everything you've told me\n- `/profile correct --track \"<title>\" --by \"<artist>\" (--like|--avoid)` - like a track, or keep it out\n- `/profile correct --artist \"<name>\" (--like|--avoid)` - like an artist, or keep them out\n- `/profile retract <correction-id>` - undo a choice\n- `/memory` - what I remember\n- `/tools` - what I can do right now\n- `/doctor` - check your setup\n- `/model` - pick the model I talk through\n- `/model <provider> <model>` - switch straight to a model\n- `/model refresh [provider]` - update public model choices; keep the selected model\n- `/model roles` - see what side tasks use: the model that reads images and the web search service\n- `/model vision auto|<provider> <model>` - choose the model that reads images\n- `/model web auto|deepseek|brave|codex` - choose the web search service\n- `/effort` - choose how hard the model thinks\n- `/auth [provider]` - sign in to a model provider\n- `/endpoint add` or `/endpoint remove <id>` - add a model service by its address, or remove it\n- `/web status|search|read` - look things up on public music sites\n- `/import [path]` - bring in your history, library, or a playlist\n- `/library` - your saved songs and playlists\n- `/library play <name>` - play a playlist\n- `/library save [playlist]` - keep the song playing now\n- `/library import <link>` - copy a playlist from a link\n- `/library export <name>` - send a playlist to Spotify\n- `/generation on|off` - let Moondog make music on this Mac, or stop\n- `/generation download|use|remove|cancel` - set up a Stable Audio 3 model\n- `/onair` - go on air, or come off it\n- `/language` - choose the language Moondog uses\n- `/service [spotify|apple_music|netease]` - choose where I play music\n- `/spotify` - Spotify commands\n- `/spotify login [client-id]` - connect Spotify\n- `/spotify now|devices|queue` - see what's playing, where, and what's next\n- `/spotify recent|sync-recent` - see or save your latest plays\n- `/spotify import-history \"/path/to/spotify-history.zip\"` - add a Spotify ZIP, no sign-in needed\n- `/skip` or `/stop` - move to the next song preview or stream track, or stop them\n- `/home` - back to the record sleeve; the conversation stays\n- `/theme paper|charcoal|terminal|auto` - change the look\n- `/art braille|ascii|off` - change the artwork\n- `/motion on|off` - turn the animation on or off\n- `/lyrics` - the lyrics on the sleeve; `/lyrics sync` finds more\n- `/reload` - reload model settings and sign-ins\n- `/remember [kind] <text>` - ask me to remember something\n- `/forget <memory-id>` - forget something\n- `/rewind` or Alt+R - edit an earlier message in place; the messages after it are replaced\n- `/branch` - go on from here in a new conversation; this one stays saved\n- `/rewind latest` - edit the most recent message\n- `/resume` - pick up a saved conversation\n- `/resume <session-id>` - go straight to one\n- `/new` - start fresh; the last one stays saved\n- `/quit` - exit\n\nAnything you type that isn't a command goes to the model you picked with `/model`, or the one set in `MOONDOG_PROVIDER` and `MOONDOG_MODEL`.\nSign in with `/auth`, or set the provider's API key in your environment. `/auth openai` signs in with your ChatGPT subscription or an API key.\nOnce your profile is ready, I can search your library, explain what I see, and plan playlists with you.\nI can only control Spotify after `moondog spotify login`. I ask before I remove anything from your library, and I never post, send messages, or spend money.\nAsk me to move playback onto a device by name, such as your iPhone.": "# 全部命令\n\n在终端里:\n\n- `moondog --version` - 显示已安装的版本\n- `moondog update [--check] [--channel latest|beta]` - 检查或安装已发布的版本\n- `moondog web status|search|read [参数] [--json]` - 通过 DeepSeek、Brave Search 或 Codex CLI 在公开音乐网站上查资料\n- `moondog demo-history --output <绝对路径.zip> [--json]` - 生成一个虚构的 Spotify 历史 ZIP,用来试用导入\n- `moondog auth login <provider>` - 登录模型服务商;密钥输入时不显示,`openai --chatgpt` 用你的 ChatGPT 订阅登录\n- `moondog auth status [provider]` - 查看保存了哪些登录\n- `moondog auth logout <provider>` - 退出某个服务商\n- `moondog spotify help` - 设置并控制 Spotify\n- `moondog spotify login [client-id]` - 在浏览器里连接 Spotify\n- `moondog spotify now|devices|queue` - 查看 Spotify 正在放什么、在哪放、接下来是什么\n- `moondog spotify recent` - 查看你最近听了什么\n- `moondog spotify sync-recent` - 把最近的播放加入你的资料\n- `moondog spotify sync-library` - 把你的 Spotify 曲库加入你的资料\n- `moondog spotify play|pause|next|previous` - 控制 Spotify 播放\n- `moondog listenbrainz import-history <listen-history.json>` - 把 ListenBrainz 收听文件加入你的资料\n- `moondog catalog latest-single --artist <名字> [--known-release <标题> | --from <spotify-history.zip>]` - 在 Apple Music(美区)查找某位艺人的最新单曲,无需模型\n- `moondog status [--json]` - 查看当前状态\n- `moondog taste [--json]` - 你的聆听报告\n- `moondog taste --html [--output <文件.html>]` - 把报告保存为可离线打开的网页\n- `moondog taste --card [--output <文件.html>]` - 保存一份简短回顾,分享前可以先检查\n- `moondog taste --from <spotify-history.zip> --html` - 从一个 Spotify ZIP 生成一次性报告,不保存\n- `moondog taste --from <account-data.zip> --from <extended-history.zip> --html` - 从两份 Spotify 导出一起生成一次性报告\n- `moondog taste --from <spotify-history.zip> --save --html` - 保存 Spotify 历史,然后显示完整报告\n- `moondog data inspect --scope <listening|apple|profile>` - 查看保存了什么,并获取重置所需的代码\n- `moondog data export --scope <listening|apple|profile> --output <目录>` - 导出一份副本,原件保持不变\n- `moondog data reset --scope <listening|apple|profile> --confirm <代码>` - 把保存的数据移到一边(归档,不删除)\n- `moondog profile build [--force]` - 用已连接的模型生成或继续生成保存的资料\n- `moondog profile saved [偏移]` - 阅读你保存的资料\n- `moondog profile explain <编号>` - 追溯一条已保存发现的证据\n- `moondog profile corrections [--all]` - 你告诉过我的所有选择,包括早先的\n- `moondog profile correct --artist <名字> (--like|--avoid)` - 标记喜欢某位艺人,或不再推荐\n- `moondog profile correct --track <歌名> --by <艺人> (--like|--avoid)` - 标记喜欢某首歌,或不再推荐\n- `moondog profile retract <correction-id>` - 撤销你的一项选择\n- `moondog demo --offline [--json]` - 用虚构数据的演示,无需登录\n- `moondog demo [提示] [--json]` - 同样的演示,通过你的模型对话\n- `moondog ask <提示>` - 问一个问题后退出\n- `moondog remember <内容>` - 让我记住一件事\n- `moondog forget <memory-id>` - 忘掉一件事\n- `moondog memory reflect [--dry-run] [--json]` - 让我现在回顾最近的对话\n- `moondog` - 打开聆听室\n\n在聆听室里:\n\n- `/update [--check] [--channel latest|beta]` - 检查更新,或保存并关闭本次会话来安装\n- `/status` 或 `/sources` - 查看当前状态\n- `/profile` 或 `/taste` - 你的资料,以及每首歌、每位艺人为什么在这里\n- `/taste report` - 一页看完整份报告\n- `/profile build [--force]` - 生成或继续生成保存的解读;Ctrl+C 会保留进度\n- `/profile saved [偏移]` - 阅读你保存的资料\n- `/profile explain <编号>` - 查看一条已保存发现的证据\n- `/profile corrections [--all]` - 你告诉过我的所有选择\n- `/profile correct --track \"<歌名>\" --by \"<艺人>\" (--like|--avoid)` - 标记喜欢某首歌,或不再推荐\n- `/profile correct --artist \"<名字>\" (--like|--avoid)` - 标记喜欢某位艺人,或不再推荐\n- `/profile retract <correction-id>` - 撤销一项选择\n- `/memory` - 我记住的内容\n- `/tools` - 我现在能做什么\n- `/doctor` - 检查你的设置\n- `/model` - 选择我用来对话的模型\n- `/model <provider> <model>` - 直接切换到某个模型\n- `/model refresh [provider]` - 更新公开的模型列表;保留当前选择\n- `/model roles` - 看看副任务在用什么:读图的模型和网页搜索服务\n- `/model vision auto|<provider> <model>` - 选择读图的模型\n- `/model web auto|deepseek|brave|codex` - 选择网页搜索服务\n- `/effort` - 选择模型思考的程度\n- `/auth [provider]` - 登录模型服务商\n- `/endpoint add` 或 `/endpoint remove <id>` - 按地址添加模型服务,或移除它\n- `/web status|search|read` - 在公开音乐网站上查资料\n- `/import [路径]` - 导入你的历史、曲库或一个歌单\n- `/library` - 你收藏的歌和播放列表\n- `/library play <名称>` - 播放一个播放列表\n- `/library save [播放列表]` - 收藏正在放的歌\n- `/library import <链接>` - 从链接复制一个播放列表\n- `/library export <名字>` - 把一个播放列表发到 Spotify\n- `/generation on|off` - 让 Moondog 在这台 Mac 上做音乐,或停下\n- `/generation download|use|remove|cancel` - 设置 Stable Audio 3 模型\n- `/onair` - 开播,或下播\n- `/language` - 选择 Moondog 使用的语言\n- `/service [spotify|apple_music|netease]` - 选择我在哪里放音乐\n- `/spotify` - Spotify 命令\n- `/spotify login [client-id]` - 连接 Spotify\n- `/spotify now|devices|queue` - 查看正在放什么、在哪放、接下来是什么\n- `/spotify recent|sync-recent` - 查看或保存你最近的播放\n- `/spotify import-history \"/path/to/spotify-history.zip\"` - 加入一个 Spotify ZIP,无需登录\n- `/skip` 或 `/stop` - 跳到下一首试听或直播曲目,或停止它们\n- `/home` - 回到唱片封套;对话还在\n- `/theme paper|charcoal|terminal|auto` - 换外观\n- `/art braille|ascii|off` - 换插画\n- `/motion on|off` - 打开或关闭动画\n- `/lyrics` - 封套上的歌词;`/lyrics sync` 找更多\n- `/reload` - 重新加载模型设置和登录\n- `/remember [类型] <内容>` - 让我记住一件事\n- `/forget <memory-id>` - 忘掉一件事\n- `/rewind` 或 Alt+R - 就地编辑之前的一条消息;之后的消息会被替换\n- `/branch` - 从这里在新对话中继续;这段对话会保留\n- `/rewind latest` - 编辑最近的一条消息\n- `/resume` - 继续一段保存的对话\n- `/resume <session-id>` - 直接打开某一段\n- `/new` - 重新开始;上一段会保存下来\n- `/quit` - 退出\n\n你输入的非命令内容,会发给你用 `/model` 选的模型,或 `MOONDOG_PROVIDER` 和 `MOONDOG_MODEL` 指定的模型。\n用 `/auth` 登录,或在环境变量里设置服务商的 API 密钥。`/auth openai` 可以用 ChatGPT 订阅登录,也可以填 API 密钥。\n资料准备好之后,我可以搜索你的曲库、解释我看到的内容,并和你一起规划歌单。\n只有在 `moondog spotify login` 之后我才能控制 Spotify。从你的曲库移除东西之前我会先问你,而且我从不发帖、不发消息,也不花钱。\n说出设备名,比如你的 iPhone,我就能把播放切过去。",
180
184
  "Apple Music library": "Apple Music 曲库",
181
185
  "Model": "模型",
182
186
  "Finding similar music": "查找相似的音乐",
@@ -713,6 +717,8 @@ export default {
713
717
  "Use /taste, or /taste report.": "使用 /taste 或 /taste report。",
714
718
  "Full report above. /taste opens the profile.": "完整报告在上面。/taste 打开资料。",
715
719
  "Web lookups aren't available when Moondog is started this way.": "这种启动方式不支持网页查询。",
720
+ "Model roles aren't available when Moondog is started this way.": "这种启动方式不支持设置模型用途。",
721
+ "Looking at the attached images... Ctrl+C cancels.": "正在看附上的图片…… Ctrl+C 取消。",
716
722
  "/home doesn't take anything after it.": "/home 后面不需要加内容。",
717
723
  "Say anything, or press Tab to look around.": "随便说点什么,或按 Tab 四处看看。",
718
724
  "Use /theme, or /theme paper, charcoal, terminal, or auto.": "使用 /theme,或 /theme paper、charcoal、terminal 或 auto。",
@@ -815,8 +821,8 @@ export default {
815
821
  "Choose the model Moondog talks through": "选择 Moondog 对话使用的模型",
816
822
  "Look things up on public music sites": "在公开音乐网站上查资料",
817
823
  "Connect and control Spotify": "连接并控制 Spotify",
818
- "Skip to the next song preview": "跳到下一首试听",
819
- "Stop the song previews": "停止播放试听",
824
+ "Skip to the next song preview or stream track": "跳到下一首试听或直播曲目",
825
+ "Stop the song previews or the stream": "停止试听或直播",
820
826
  "Reload model settings and sign-ins": "重新加载模型设置和登录",
821
827
  "Ask Moondog to remember something": "让 Moondog 记住一件事",
822
828
  "Forget one memory by ID": "按 ID 忘掉一条记忆",
@@ -903,7 +909,7 @@ export default {
903
909
  "Remove a playlist from your library": "把歌单从你的曲库移除",
904
910
  "Preview a playlist change": "预览歌单修改",
905
911
  "Change a Spotify playlist": "修改 Spotify 歌单",
906
- "Save the playlist to Spotify": "把歌单保存到 Spotify",
912
+ "Save the playlist": "保存歌单",
907
913
  "Choose how hard the model thinks": "选择模型思考的程度",
908
914
  "Use /effort, or /effort <level>.": "使用 /effort,或 /effort <级别>。",
909
915
  "Choose a model with /model first.": "请先用 /model 选择模型。",
@@ -977,6 +983,17 @@ export default {
977
983
  "Saved the {service} key. Web search goes through {provider}.": "已保存 {service} 密钥。网页搜索使用 {provider}。",
978
984
  "Saved the {service} key, but web search still isn't ready. Run `/web status` to see why.": "已保存 {service} 密钥,但网页搜索还不能用。运行 `/web status` 查看原因。",
979
985
  "Add an endpoint by its address": "按地址添加接口",
986
+ "See what side tasks use": "看看副任务在用什么",
987
+ "Choose the model that reads images": "选择读图的模型",
988
+ "Choose the web search service": "选择网页搜索服务",
989
+ "Let the chat model read images when it can": "让聊天模型在能读图时直接读",
990
+ "Take the first service that is set up": "用第一个已设置的服务",
991
+ "Search with DeepSeek": "用 DeepSeek 搜索",
992
+ "Search with Brave Search": "用 Brave Search 搜索",
993
+ "Search with the Codex CLI": "用 Codex CLI 搜索",
994
+ "Play a playlist by name": "按名称播放一个播放列表",
995
+ "Keep the song playing now": "收藏正在放的歌",
996
+ "Copy a playlist from a link": "从链接复制一个播放列表",
980
997
  "Remove an endpoint and its key": "移除接口和它的密钥",
981
998
  "ChatGPT sign-in or API key": "ChatGPT 登录或 API 密钥",
982
999
  "ChatGPT subscription": "ChatGPT 订阅",
@@ -993,6 +1010,16 @@ export default {
993
1010
  "Removed {name} and its key.": "已移除 {name} 和它的密钥。",
994
1011
  "Endpoint removed.": "接口已移除。",
995
1012
  "Add a model service by its address": "按地址添加模型服务",
1013
+ "Use an invite code for Moondog's own model": "用邀请码使用 Moondog 自己的模型",
1014
+ "Invite codes aren't available when Moondog is started this way.": "以这种方式启动 Moondog 时无法使用邀请码。",
1015
+ "Use /invite, /invite <code>, or /invite remove.": "请使用 /invite、/invite <邀请码> 或 /invite remove。",
1016
+ "Removed the invite code.": "已移除邀请码。",
1017
+ "Invite code removed.": "邀请码已移除。",
1018
+ "No invite code is saved. Type `/invite <code>` to use yours.": "还没有保存邀请码。输入 `/invite <邀请码>` 使用你的邀请码。",
1019
+ "Saved. Moondog's own model now answers.": "已保存。现在由 Moondog 自己的模型回答。",
1020
+ "Saved. Type `/model moondog/moondog` to talk through Moondog's own model.": "已保存。输入 `/model moondog/moondog` 可改用 Moondog 自己的模型。",
1021
+ "Invite code saved.": "邀请码已保存。",
1022
+ "An invite code is saved. Moondog's own model can answer.": "已保存邀请码。Moondog 自己的模型可以回答。",
996
1023
  "Whole songs on your Spotify devices": "在你的 Spotify 设备上播放完整歌曲",
997
1024
  "30-second previews, played here": "30 秒试听,就在这里播放",
998
1025
  "Whole songs through ncm-cli": "通过 ncm-cli 播放完整歌曲",
@@ -1131,9 +1158,28 @@ export default {
1131
1158
  "Already in {name}.": "已经在“{name}”里了。",
1132
1159
  "Saved.": "已收藏。",
1133
1160
  "Saved to {name}.": "已收藏到“{name}”。",
1134
- "Use /library, /library play <name>, or /library save [playlist].": "用 /library、/library play <名字> 或 /library save [播放列表]。",
1135
1161
  "Your saved songs and playlists": "你收藏的歌和播放列表",
1136
1162
  "Look in the library": "翻翻资料库",
1137
1163
  "Save to the library": "收进资料库",
1164
+ "Change a playlist": "修改播放列表",
1138
1165
  "Play from the library": "播放资料库里的歌",
1166
+ "Paste a playlist link after /library import.": "在 /library import 后面粘贴歌单链接。",
1167
+ "Reading the playlist…": "正在读取歌单…",
1168
+ "{added} of {total} songs came in.": "{total} 首中导入了 {added} 首。",
1169
+ "{count} songs came in.": { one: "导入了 {count} 首。", other: "导入了 {count} 首。" },
1170
+ "It now shapes your taste.": "它现在会影响你的口味画像。",
1171
+ "It couldn't shape your taste this time.": "这次没能把它加入你的口味画像。",
1172
+ "It doesn't shape your taste; add taste after the link if it should.": "它不会影响你的口味;如果需要,在链接后加 taste。",
1173
+ "Imported {name}.": "已导入“{name}”。",
1174
+ "Use /library, /library play <name>, /library save [playlist], /library import <link>, or /library export <name>.": "用 /library、/library play <名字>、/library save [播放列表]、/library import <链接> 或 /library export <名字>。",
1175
+ "Import a playlist": "导入歌单",
1176
+ "Send a playlist to Spotify": "把一个播放列表发到 Spotify",
1177
+ "Sending {name} to Spotify…": "正在把“{name}”发到 Spotify…",
1178
+ "{name} was changed on Spotify since the last export, so nothing was sent. Add replace after the name to overwrite it there.": "“{name}”在上次导出后在 Spotify 上被改过,所以这次没有发送。在名字后加 replace 可以覆盖那边的内容。",
1179
+ "{name} has no songs to send.": "“{name}”里没有可以发送的歌。",
1180
+ "Updated {name} on Spotify.": "已更新 Spotify 上的“{name}”。",
1181
+ "{name} is now on Spotify.": "“{name}”已发到 Spotify。",
1182
+ "Moondog's tracks stay here; Spotify can't hold them.": "Moondog 做的曲目留在这里,Spotify 放不了它们。",
1183
+ "Export a playlist": "导出歌单",
1184
+ "{count} songs went over.": { one: "发过去 {count} 首。", other: "发过去 {count} 首。" },
1139
1185
  };
@@ -0,0 +1,61 @@
1
+ // Read ZIP members in process on every desktop platform. Nothing is extracted to disk.
2
+ import { crc32 } from "node:zlib";
3
+ import yauzl from "yauzl";
4
+
5
+ /**
6
+ * Opens a ZIP file or buffer once, so several members can be read without reading the central
7
+ * directory again. `names` lists every member in archive order. Call close() when done.
8
+ */
9
+ export async function openZipArchive(source, maximumNameBytes = 1024 * 1024) {
10
+ // The archive stays open after its entries are listed, so members can be read in any order.
11
+ const options = { strictFileNames: true, validateEntrySizes: true, autoClose: false };
12
+ const zip = Buffer.isBuffer(source) ? await yauzl.fromBufferPromise(source, options) : await yauzl.openPromise(source, options);
13
+ const names = [];
14
+ const entries = new Map();
15
+ try {
16
+ let bytes = 0;
17
+ for await (const entry of zip.eachEntry()) {
18
+ if (/[\u0000-\u001f\u007f]/u.test(entry.fileName)) throw new Error("Unsupported ZIP member name.");
19
+ bytes += Buffer.byteLength(entry.fileName, "utf8") + 1;
20
+ if (bytes > maximumNameBytes) throw new Error("ZIP member list exceeds the supported size.");
21
+ names.push(entry.fileName);
22
+ if (!entries.has(entry.fileName)) entries.set(entry.fileName, entry);
23
+ }
24
+ } catch (error) {
25
+ zip.close();
26
+ throw error;
27
+ }
28
+
29
+ async function read(name, maximumBytes) {
30
+ const entry = entries.get(name);
31
+ if (!entry) throw new Error("ZIP member was not found.");
32
+ if (entry.uncompressedSize > maximumBytes) throw new Error("ZIP member exceeds the supported size.");
33
+ const stream = await zip.openReadStreamPromise(entry);
34
+ const chunks = [];
35
+ let bytes = 0;
36
+ let checksum = 0;
37
+ try {
38
+ for await (const chunk of stream) {
39
+ bytes += chunk.length;
40
+ if (bytes > maximumBytes) throw new Error("ZIP member exceeds the supported size.");
41
+ checksum = crc32(chunk, checksum);
42
+ chunks.push(chunk);
43
+ }
44
+ } finally { stream.destroy(); }
45
+ if (checksum !== entry.crc32) throw new Error("ZIP member checksum does not match.");
46
+ return Buffer.concat(chunks, bytes);
47
+ }
48
+
49
+ return { names, read, close: () => zip.close() };
50
+ }
51
+
52
+ export async function listZipMembers(source, maximumBytes = 1024 * 1024) {
53
+ const zip = await openZipArchive(source, maximumBytes);
54
+ zip.close();
55
+ return zip.names;
56
+ }
57
+
58
+ export async function readZipMember(source, name, maximumBytes) {
59
+ const zip = await openZipArchive(source);
60
+ try { return await zip.read(name, maximumBytes); } finally { zip.close(); }
61
+ }
@@ -172,8 +172,9 @@ function nowPlayingOf(answer) {
172
172
  };
173
173
  }
174
174
 
175
- export function createMusicAppPlayer({ platform = process.platform, run = osascript, now = Date.now } = {}) {
176
- const available = platform === "darwin";
175
+ export function createMusicAppPlayer({ platform = process.platform, environment = process.env, run = osascript, now = Date.now } = {}) {
176
+ // Disposable desktop checks can opt out of the listener's system Music app as well as local data.
177
+ const available = platform === "darwin" && environment.MOONDOG_SYSTEM_MUSIC !== "off";
177
178
  let refusedAt = null;
178
179
  const covers = new Map();
179
180
 
@@ -2,6 +2,7 @@ import { setTimeout as delay } from "node:timers/promises";
2
2
 
3
3
  import { musicHash, musicText, prepareMusicBundle } from "../../profile/music-import-bundle.mjs";
4
4
  import { readLastfmConfiguration } from "./settings.mjs";
5
+ import { MOONDOG_USER_AGENT } from "../user-agent.mjs";
5
6
 
6
7
  // A listener's scrobbles (every play Last.fm counted) and loved tracks, read by username.
7
8
  // Last.fm lists scrobbles newest first; the read stops at the moment it started, so new
@@ -75,7 +76,7 @@ async function lastfmCall({ root, apiKey, method, params, fetchImpl, signal, sle
75
76
  try {
76
77
  response = await fetchImpl(url, {
77
78
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout,
78
- headers: { "User-Agent": "Moondog (+https://github.com/Audiofool934/moondog)" },
79
+ headers: { "User-Agent": MOONDOG_USER_AGENT },
79
80
  });
80
81
  body = await response.json().catch(() => null);
81
82
  } catch (error) {
@@ -1,7 +1,7 @@
1
1
  import { lyricIdentity } from "../../core/lyric-profile.mjs";
2
+ import { MOONDOG_USER_AGENT as userAgent } from "../user-agent.mjs";
2
3
 
3
4
  const origin = "https://lrclib.net";
4
- const userAgent = "Moondog/0.1.0 (https://github.com/Audiofool934/moondog)";
5
5
 
6
6
  export class LyricsProviderError extends Error {
7
7
  constructor(message, retryAfterMs = 60_000) {
@@ -4,9 +4,11 @@
4
4
  // original recordings, NetEase marks songs as not playable (`visible: false`), most often for
5
5
  // copyright, and no membership changes that.
6
6
  import { execFile } from "node:child_process";
7
- import { access, constants, stat } from "node:fs/promises";
7
+ import { access, constants, readFile, stat } from "node:fs/promises";
8
8
  import path from "node:path";
9
9
 
10
+ import { environmentPathKey } from "../../core/host.mjs";
11
+
10
12
  const COMMAND_TIMEOUT_MS = 20_000;
11
13
  // Where Homebrew and npm put ncm-cli, the node it runs on, and mpv, for a PATH that lacks them.
12
14
  const EXTRA_FOLDERS = ["/opt/homebrew/bin", "/usr/local/bin"];
@@ -22,37 +24,59 @@ const KNOWN_SONGS = 300;
22
24
  const failure = (code, message) => Object.assign(new Error(message), { code });
23
25
 
24
26
  const folders = (value) => String(value ?? "").split(path.delimiter).filter((folder) => path.isAbsolute(folder));
25
- const searchPath = (environment) => [...new Set([...folders(environment.PATH), ...EXTRA_FOLDERS])];
27
+ const searchPath = (environment, platform) => [...new Set([...folders(environment[environmentPathKey(environment)]),
28
+ ...(platform === "win32" ? (environment.APPDATA ? [path.join(environment.APPDATA, "npm")] : []) : EXTRA_FOLDERS)])];
29
+
30
+ async function executable(file) {
31
+ try {
32
+ if (!(await stat(file)).isFile()) return false;
33
+ await access(file, constants.X_OK);
34
+ return true;
35
+ } catch { return false; }
36
+ }
26
37
 
27
- async function findIn(places) {
38
+ async function findIn(places, platform) {
28
39
  for (const folder of places) {
29
- const file = path.join(folder, "ncm-cli");
30
- try {
31
- if (!(await stat(file)).isFile()) continue;
32
- await access(file, constants.X_OK);
33
- return file;
34
- } catch {}
40
+ const file = path.join(folder, platform === "win32" ? "ncm-cli.exe" : "ncm-cli");
41
+ if (await executable(file)) return { file, args: [] };
42
+ if (platform !== "win32") continue;
43
+ // npm's Windows launcher is a .cmd file. Run its package entry with Node directly so
44
+ // artist names and queries never pass through cmd.exe's quoting and expansion rules.
45
+ for (const packageRoot of [path.join(folder, "node_modules", "@music163", "ncm-cli"), path.resolve(folder, "..", "@music163", "ncm-cli")]) {
46
+ try {
47
+ const metadata = JSON.parse(await readFile(path.join(packageRoot, "package.json"), "utf8"));
48
+ const bin = typeof metadata.bin === "string" ? metadata.bin : metadata.bin?.["ncm-cli"];
49
+ if (typeof bin !== "string") continue;
50
+ const entry = path.resolve(packageRoot, bin);
51
+ if (!(await stat(entry)).isFile()) continue;
52
+ for (const nodeFolder of [folder, ...places]) {
53
+ const node = path.join(nodeFolder, "node.exe");
54
+ if (await executable(node)) return { file: node, args: [entry] };
55
+ }
56
+ } catch {}
57
+ }
35
58
  }
36
59
  return null;
37
60
  }
38
61
 
39
62
  // Opened from Finder, the app has its login shell's PATH, which lacks the folders ~/.zshrc adds,
40
63
  // such as nvm's for npm's global commands. There, the listener's shell as Terminal opens it says.
41
- function terminalPath(environment) {
64
+ function terminalPath(environment, platform) {
65
+ if (platform === "win32") return Promise.resolve([]);
42
66
  return new Promise((resolve) => {
43
- execFile(environment.SHELL || "/bin/zsh", ["-ilc", 'printf "\\n__MOONDOG_PATH__%s\\n" "$PATH"'], { env: environment, timeout: 5_000 },
67
+ execFile(environment.SHELL || (platform === "darwin" ? "/bin/zsh" : "/bin/sh"), ["-ilc", 'printf "\\n__MOONDOG_PATH__%s\\n" "$PATH"'], { env: environment, timeout: 5_000 },
44
68
  (_error, stdout) => resolve(folders(String(stdout ?? "").match(/__MOONDOG_PATH__(.+)/u)?.[1])));
45
69
  });
46
70
  }
47
71
 
48
72
  /** ncm-cli and the PATH to run it with, which has the node it runs on, or null. */
49
- async function findNcmCli(environment) {
50
- const places = searchPath(environment);
51
- const file = await findIn(places);
52
- if (file) return { file, places };
53
- const terminal = await terminalPath(environment);
54
- const found = await findIn(terminal);
55
- return found ? { file: found, places: [...new Set([...terminal, ...places])] } : null;
73
+ export async function findNcmCli(environment, platform = process.platform) {
74
+ const places = searchPath(environment, platform);
75
+ const command = await findIn(places, platform);
76
+ if (command) return { ...command, places };
77
+ const terminal = await terminalPath(environment, platform);
78
+ const found = await findIn(terminal, platform);
79
+ return found ? { ...found, places: [...new Set([...terminal, ...places])] } : null;
56
80
  }
57
81
 
58
82
  // Runs one ncm-cli command and parses its JSON. ncm-cli reports most failures as
@@ -64,9 +88,9 @@ function cliRunner({ environment }) {
64
88
  return async (args) => {
65
89
  found ??= await findNcmCli(environment);
66
90
  if (!found) throw failure("netease_cli_missing", "ncm-cli is not installed. Install it with: npm install -g @music163/ncm-cli");
67
- const env = { ...environment, PATH: found.places.join(path.delimiter) };
91
+ const env = { ...environment, [environmentPathKey(environment)]: found.places.join(path.delimiter) };
68
92
  const stdout = await new Promise((resolve, reject) => {
69
- execFile(found.file, args, { env, timeout: COMMAND_TIMEOUT_MS, maxBuffer: 8 * 1024 * 1024 }, (error, out) =>
93
+ execFile(found.file, [...found.args, ...args], { env, windowsHide: true, timeout: COMMAND_TIMEOUT_MS, maxBuffer: 8 * 1024 * 1024 }, (error, out) =>
70
94
  (error && !out ? reject(failure("netease_failed", `ncm-cli ${args[0]} failed: ${String(error.message).slice(0, 200)}`)) : resolve(String(out ?? ""))));
71
95
  });
72
96
  const start = stdout.indexOf("{");
@@ -305,6 +329,24 @@ export function createNeteasePlayer({
305
329
  await beforePlay?.();
306
330
  await playAt(index + 1);
307
331
  },
332
+ /** One playable song for a title and artist, matched as play() matches, or null. play() takes it back by id. */
333
+ async find({ title, artist, intent } = {}) {
334
+ const wanted = { title: String(title ?? ""), artist: String(artist ?? "") };
335
+ if (!wanted.title.trim()) return null;
336
+ const result = pick(await player.search({ query: `${wanted.title} ${wanted.artist}`.trim(), limit: 10, intent }), wanted);
337
+ return result.song && !result.other_artist ? result.song : null;
338
+ },
339
+ // A song in Up next, counted from the one after this (1 is the next): it plays now, past the ones before it.
340
+ async jump({ ahead, beforePlay } = {}) {
341
+ if (!Number.isInteger(ahead) || ahead < 1 || index + ahead >= queue.length) throw failure("netease_failed", "That song is no longer queued.");
342
+ await beforePlay?.();
343
+ await playAt(index + ahead);
344
+ },
345
+ // A song taken out of Up next, counted the same way. The one playing stays.
346
+ remove({ ahead } = {}) {
347
+ if (!Number.isInteger(ahead) || ahead < 1 || index + ahead >= queue.length) return;
348
+ queue = [...queue.slice(0, index + ahead), ...queue.slice(index + ahead + 1)];
349
+ },
308
350
  // Back to the start of the song, or to the one before when it has only just begun.
309
351
  async previous({ beforePlay } = {}) {
310
352
  const now = await state();
@@ -1,4 +1,5 @@
1
1
  import { uuidV5 } from "../../core/uuid-v5.mjs";
2
+ import { MOONDOG_USER_AGENT } from "../user-agent.mjs";
2
3
 
3
4
  export const LISTENBRAINZ_RECORDING_TRACK_NAMESPACE =
4
5
  "1ea3cad6-a0a2-58a5-a584-64953336f69f";
@@ -15,7 +16,6 @@ export const OPEN_MUSIC_SIMILARITY_LIMITS = Object.freeze({
15
16
 
16
17
  const wikidataOrigin = "https://www.wikidata.org";
17
18
  const listenBrainzOrigin = "https://api.listenbrainz.org";
18
- const defaultUserAgent = "Moondog/0.1 (https://ai.ruc.edu.cn/)";
19
19
  const uuidPattern =
20
20
  /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
21
21
  const modes = new Set(["easy", "medium", "hard"]);
@@ -209,7 +209,7 @@ export function createWikidataArtistResolver({
209
209
  fetchImpl = globalThis.fetch,
210
210
  now = Date.now,
211
211
  cacheTtlMs = OPEN_MUSIC_SIMILARITY_LIMITS.identityCacheTtlMs,
212
- userAgent = defaultUserAgent,
212
+ userAgent = MOONDOG_USER_AGENT,
213
213
  } = {}) {
214
214
  if (typeof fetchImpl !== "function") {
215
215
  throw new TypeError("A fetch implementation is required.");
@@ -437,7 +437,7 @@ export function createListenBrainzArtistRadioClient({
437
437
  fetchImpl = globalThis.fetch,
438
438
  now = Date.now,
439
439
  cacheTtlMs = OPEN_MUSIC_SIMILARITY_LIMITS.cacheTtlMs,
440
- userAgent = defaultUserAgent,
440
+ userAgent = MOONDOG_USER_AGENT,
441
441
  } = {}) {
442
442
  if (typeof fetchImpl !== "function") {
443
443
  throw new TypeError("A fetch implementation is required.");
@@ -0,0 +1,114 @@
1
+ // Playlist links the listener pastes into the library: Spotify, Apple Music, NetEase Music and QQ Music.
2
+ // Each link is read for its name and songs only; nothing signs in to a service it doesn't already have,
3
+ // and nothing but the official hosts is ever fetched.
4
+ import { fetchPublicPlaylist } from "./public-playlists.mjs";
5
+
6
+ const fail = (code, message) => { throw Object.assign(new Error(message), { code }); };
7
+ const PUBLIC_HOSTS = new Set(["y.qq.com", "c.y.qq.com", "i.y.qq.com", "m.y.qq.com", "music.163.com", "y.music.163.com", "163cn.tv"]);
8
+ const APPLE_PAGE_MAX = 12 * 1024 * 1024;
9
+
10
+ /** The one playlist link in some text: { provider, id, url } for Spotify and Apple Music, or { provider: "public", url } for NetEase and QQ. */
11
+ export function parsePlaylistLink(text) {
12
+ const value = String(text ?? "").trim();
13
+ const uri = /^spotify:playlist:([A-Za-z0-9]{10,40})$/u.exec(value);
14
+ if (uri) return { provider: "spotify", id: uri[1], url: `https://open.spotify.com/playlist/${uri[1]}` };
15
+ const links = value.match(/https?:\/\/[^\s<>"“”]+/gu) ?? [];
16
+ if (links.length !== 1) fail("playlist_link_missing", "Paste one playlist link: Spotify, Apple Music, NetEase Music or QQ Music.");
17
+ let url;
18
+ try { url = new URL(links[0]); } catch { fail("playlist_link_missing", "That link can't be read."); }
19
+ if (url.username || url.password || url.port) fail("playlist_link_unsupported", "That link can't be read.");
20
+ if (url.hostname === "open.spotify.com") {
21
+ const match = /^\/(?:intl-[a-z-]+\/)?playlist\/([A-Za-z0-9]{10,40})\/?$/u.exec(url.pathname);
22
+ if (match) return { provider: "spotify", id: match[1], url: `https://open.spotify.com/playlist/${match[1]}` };
23
+ }
24
+ if (url.hostname === "music.apple.com" || url.hostname === "embed.music.apple.com") {
25
+ const match = /^\/([a-z]{2})\/playlist\/(?:[^/]+\/)?(pl\.[A-Za-z0-9.-]{6,80})\/?$/u.exec(url.pathname);
26
+ if (match) return { provider: "apple_music", id: match[2], storefront: match[1], url: `https://music.apple.com/${match[1]}/playlist/${match[2]}` };
27
+ }
28
+ if (PUBLIC_HOSTS.has(url.hostname)) return { provider: "public", url: url.href };
29
+ fail("playlist_link_unsupported", "Moondog reads playlist links from Spotify, Apple Music, NetEase Music and QQ Music.");
30
+ }
31
+
32
+ // The page's text, bounded, from Apple's own host only and never through a redirect elsewhere.
33
+ async function applePage(url, fetchImpl, signal) {
34
+ let response;
35
+ try {
36
+ response = await fetchImpl(url, { redirect: "follow", signal: AbortSignal.any([AbortSignal.timeout(20_000), ...(signal ? [signal] : [])]),
37
+ headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Moondog playlist import)", "Accept-Language": "en" } });
38
+ } catch (error) {
39
+ if (signal?.aborted) throw error;
40
+ fail("playlist_unreachable", "Couldn't reach Apple Music. Check your connection and try the link again.");
41
+ }
42
+ if (response.url && new URL(response.url).hostname !== "music.apple.com") fail("playlist_unavailable", "Apple Music answered from another address.");
43
+ if (!response.ok) { await response.body?.cancel(); fail("playlist_unavailable", "Apple Music didn't show this playlist. Check that it opens in a browser without signing in."); }
44
+ const chunks = [];
45
+ let size = 0;
46
+ for await (const chunk of response.body) {
47
+ size += chunk.length;
48
+ if (size > APPLE_PAGE_MAX) fail("playlist_too_large", "This playlist page is too large to read.");
49
+ chunks.push(chunk);
50
+ }
51
+ return Buffer.concat(chunks).toString("utf8");
52
+ }
53
+
54
+ const text = (value, maximum = 200) => (typeof value === "string" ? Array.from(value.replace(/\s+/gu, " ").trim()).slice(0, maximum).join("") : "");
55
+
56
+ /**
57
+ * An Apple Music playlist from its public page: its name, how many songs it has, and the songs the page
58
+ * lists with their Apple Music ids and covers, and the playlist's own square cover (the page's og:image is a
59
+ * wide share card). A long playlist's page may list only its first songs;
60
+ * read and total say how many.
61
+ */
62
+ export async function readApplePlaylist({ id, url }, { fetchImpl = fetch, signal } = {}) {
63
+ const html = await applePage(url, fetchImpl, signal);
64
+ const block = (pattern) => { const match = pattern.exec(html); try { return match ? JSON.parse(match[1]) : null; } catch { return null; } };
65
+ const schema = block(/<script[^>]*id=schema:music-playlist[^>]*>([\s\S]*?)<\/script>/u) ?? block(/<script[^>]*application\/ld\+json[^>]*>([\s\S]*?)<\/script>/u);
66
+ const data = block(/<script[^>]*id="serialized-server-data"[^>]*>([\s\S]*?)<\/script>/u);
67
+ const tracks = [];
68
+ const seen = new Set();
69
+ const artworkAt = (node, size) => {
70
+ const url = node.artwork?.dictionary?.url;
71
+ return typeof url === "string" && url.startsWith("https://") ? url.replace("{w}x{h}", `${size}x${size}`).replace("{c}", "").replace("{f}", "jpg") : null;
72
+ };
73
+ // The playlist's own entry in the server data. A listener's own playlist has no schema block, and its og:title
74
+ // reads "Name by Listener on Apple Music", so this entry's title and count come first.
75
+ let own = null;
76
+ let cover = null;
77
+ // The server data lists each song as a track lockup with its title, its artist and its catalog id.
78
+ const walk = (node, depth) => {
79
+ if (!node || typeof node !== "object" || depth > 12 || tracks.length >= 2000) return;
80
+ if (Array.isArray(node)) { for (const each of node) walk(each, depth + 1); return; }
81
+ const catalog = node.contentDescriptor?.identifiers?.storeAdamID;
82
+ // The page's intent carries the same id with no title or artwork, and comes first.
83
+ if (!own && node.contentDescriptor?.kind === "playlist" && catalog === id && typeof node.title === "string") { own = node; cover = artworkAt(node, 600); }
84
+ if (typeof node.title === "string" && typeof node.artistName === "string" && node.contentDescriptor?.kind === "song" && catalog) {
85
+ const key = String(catalog);
86
+ if (!seen.has(key)) {
87
+ seen.add(key);
88
+ const artwork = artworkAt(node, 300);
89
+ tracks.push({ id: key, title: text(node.title), artist: text(node.artistName), ...(artwork ? { artwork } : {}) });
90
+ }
91
+ return;
92
+ }
93
+ for (const value of Object.values(node)) walk(value, depth + 1);
94
+ };
95
+ walk(data, 0);
96
+ const name = text(own?.title) || text(schema?.name) || text(/<meta property="og:title" content="([^"]+)"/u.exec(html)?.[1]) || "Apple Music playlist";
97
+ const count = schema?.numTracks ?? own?.trackCount;
98
+ const total = count !== null && count !== undefined && Number.isSafeInteger(Number(count)) ? Number(count) : null;
99
+ if (!tracks.length) fail("playlist_unavailable", "Apple Music didn't list the songs of this playlist. Check that it is shared publicly.");
100
+ return { provider: "apple_music", id, url, name, ...(cover ? { cover } : {}), total: total !== null && total >= tracks.length ? total : null, tracks: tracks.filter((track) => track.title && track.artist) };
101
+ }
102
+
103
+ /** A NetEase Music or QQ Music playlist through its public share link, as library songs. */
104
+ export async function readPublicPlaylistLink({ url }, { fetchImpl = fetch } = {}) {
105
+ // The public reader explains itself in words; the library's surfaces also need its kind, to say it in their language.
106
+ const playlist = await fetchPublicPlaylist({ input: url, fetchImpl }).catch((error) => {
107
+ // Only the link checks' own refusals are about the link; any answer the service gave is about the playlist.
108
+ const aboutLink = /^(Paste a QQ Music|Use a playlist link|Open this share link|This link belongs to another service)/u;
109
+ if (!error.code) error.code = /^Could not reach/u.test(error.message) ? "playlist_unreachable" : aboutLink.test(error.message) ? "playlist_link_unsupported" : "playlist_unavailable";
110
+ throw error;
111
+ });
112
+ return { provider: playlist.provider, id: playlist.id, url: playlist.url, name: playlist.name, total: playlist.total, ...(playlist.cover ? { cover: playlist.cover } : {}),
113
+ tracks: playlist.rows.map((row) => ({ id: row.id, title: row.title, artist: row.artist, ...(row.album ? { album: row.album } : {}), ...(row.artwork ? { artwork: row.artwork } : {}) })).filter((track) => track.artist) };
114
+ }