Skip to content

Commit

Permalink
添加开放API说明
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Mar 29, 2024
1 parent c67b9d9 commit af54512
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
71 changes: 71 additions & 0 deletions docs/desktop/open-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
id: open-api
title: 开放API服务
---

从 v2.7.0 起支持开放API服务,启用该功能后,将会在本地启动一个http服务,服务将绑定到`localhost`,提供以下接口供第三方软件调用:

### 获取播放器状态

接口地址:`/status`

请求方法:`GET`

响应数据格式:JSON

| 字段名 | 描述 |
| --- | --- |
| `status` | 播放器状态,可能的值为 `playing``paused``error``stoped` |
| `name` | 歌曲名字 |
| `singer` | 歌手名字 |
| `albumName` | 专辑名字 |
| `duration` | 歌曲时长(秒) |
| `progress` | 歌曲进度(秒) |
| `picUrl` | 歌曲封面图片链接,可能为 HTTP链接 或 [Data Url](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) |
| `lyricLineText` | 当前句歌词文本 |

响应数据例子:

```json
{
"status": "playing",
"name": "天使的翅膀",
"singer": "徐誉滕",
"albumName": "李雷和韩梅梅",
"duration": 214.543673,
"progress": 5.051338,
"picUrl": "http://xxx",
"lyricLineText": "徐誉滕 - 天使的翅膀"
}

```

### 获取当前LRC歌词

接口地址:`/lyric`

请求方法:`GET`

响应数据格式:UTF-8编码的LRC文本

响应数据例子:

```txt
[ar:安琥]
[ti:天使的翅膀]
[by:]
[al:全年伤感歌曲大盘点2]
[offset:0]
[00:00.0]徐誉滕 - 天使的翅膀
[00:05.50]词:徐誉滕
[00:10.100]曲:徐誉滕
[00:15.150]落叶随风将要去何方
[00:21.503]只留给天空美丽一场
[00:27.561]曾飞舞的声音
[00:30.723]像天使的翅膀
[00:33.632]划过我幸福的过往
[00:40.799]爱曾经来到过的地方
[00:47.345]依昔留着昨天的芬芳
```

若你想要提供更多API,可以到GitHub开issue讨论 :)
5 changes: 5 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const sidebars = {
id: 'desktop/scheme-url', // document ID
label: 'Scheme URL支持', // sidebar label
},
{
type: 'doc',
id: 'desktop/open-api', // document ID
label: '开放API服务', // sidebar label
},
{
type: 'doc',
id: 'desktop/run-params', // document ID
Expand Down

0 comments on commit af54512

Please sign in to comment.