跳转到主内容

YouTube 音乐

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

功能

显示 YouTube Music Desktop App 中当前播放的歌曲。

设置

你需要在 YouTube Music Desktop App 的设置中启用 Companion API:

  1. 打开应用
  2. 前往 Settings > Integration
  3. 启用以下选项:
  • Companion 服务器

  • 启用 Companion 认证

在命令行中运行以下命令设置认证令牌:

oh-my-posh auth ytmda

设置成功后,即可在提示符中添加 ytm 片段。

速率限制

YouTube Music Desktop App 有较严格的速率限制,强烈建议在配置中设置 cache 属性。 若未设置,该片段将无法正常显示。

示例配置

{
"type": "ytm",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#FF0000",
"options": {
"playing_icon": " ",
"paused_icon": " ",
"stopped_icon": " ",
"ad_icon": " ",
"http_timeout": 1000
},
"cache": {
"duration": "5s",
"strategy": "session"
}
}

选项

NameTypeDefaultDescription
playing_iconstring\uf04b text/icon to show when playing
paused_iconstring\uf04c text/icon to show when paused
stopped_iconstring\uf04d text/icon to show when stopped
ad_iconstring\ueebb text/icon to show when an advertisement is playing
http_timeoutint5000in milliseconds - the timeout for http request

模板 (信息)

默认模板
{{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }}

属性

NameTypeDescription
.Statusstringplayer status (playing, paused, stopped)
.Artiststringcurrent artist
.Trackstringcurrent track
.Iconstringicon (based on .Status)