YouTube 音乐
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
功能
显示 YouTube Music Desktop App 中当前播放的歌曲。
设置
你需要在 YouTube Music Desktop App 的设置中启用 Companion API:
- 打开应用
- 前往
Settings > Integration - 启用以下选项:
-
Companion 服务器
-
启用 Companion 认证
在命令行中运行以下命令设置认证令牌:
oh-my-posh auth ytmda
设置成功后,即可在提示符中添加 ytm 片段。
速率限制
YouTube Music Desktop App 有较严格的速率限制,强烈建议在配置中设置 cache 属性。
若未设置,该片段将无法正常显示。
示例配置
- json
- yaml
- toml
{
"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"
}
}
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
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"
选项
| Name | Type | Default | Description |
|---|---|---|---|
playing_icon | string | \uf04b | text/icon to show when playing |
paused_icon | string | \uf04c | text/icon to show when paused |
stopped_icon | string | \uf04d | text/icon to show when stopped |
ad_icon | string | \ueebb | text/icon to show when an advertisement is playing |
http_timeout | int | 5000 | in milliseconds - the timeout for http request |
模板 (信息)
默认模板
{{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }}
属性
| Name | Type | Description |
|---|---|---|
.Status | string | player status (playing, paused, stopped) |
.Artist | string | current artist |
.Track | string | current track |
.Icon | string | icon (based on .Status) |