Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/05.audio-library/01.protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ Access-Control-Allow-Origin: *
"protocol_version": "0.2.1",
// 音频仓库最近一次数据更新时间
// 用于客户端缓存 `/albums` 请求结果
"last_update": 1639631487
"last_update": 1639631487,
// 用于提供元数据的 `Annim` 服务器 URL
"meta_server": "https://annim.example.com"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分可以参考一下另一个pr,我找一下

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annim 应该是 required ,而 repo 和预构建 db 都应该用 annim 提供(?

@Yesterday17 Yesterday17 Apr 14, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Annim 是 repo 的延伸,这样 repo 和 Annim 就是一对多的。Annim 和 db 一个是动态的数据源,一个是静态的数据源,也应该是平级的。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annim 某种意义上来说是对 repo 的封装,为什么是平级的。而且要让客户端处理 git 也很麻烦

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哦,上面写错了, annim 和 db 是平级的

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要解决的其实是:

  1. 不管最终 repo 以什么形态出现,我们肯定会保留一种备份并公开元数据仓库的手段。
  2. 从这份公开的元数据备份中 Host 一个 Annim 并添加到客户端之后,我们需要让支持的所有 Annil 都自动选用这个 Annim,而不是每个用了这个 repo 的服务器都要单独配置一遍。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那问题就是现在元数据的来源是抽象的,没有一个可用的 identifier 。

@Yesterday17 Yesterday17 Apr 18, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我们给 repo 加一个 uuid?然后给版本加一个 hash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那我们给 repo 加一个 uuid?然后给版本加一个 hash

参考 nix flake 的 input?

}
```

Expand Down
20 changes: 20 additions & 0 deletions src/06.anniv/03.playlist.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,23 @@ type PatchedPlaylistInfo = Partial<Omit<PlaylistInfo, "id" | "owner">>;
| -------- | -------------- |
| `103002` | 播放列表不存在 |
| `103003` | 非法修改类型 |

## 搜素播放列表
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated

### Endpoint

`GET /api/playlist/search`

### 请求

#### 请求参数

| 参数名 | 详情 |
| --------- | -------------- |
| `keyword` | 搜索关键词 |
| `limit` | 最多返回条目数 |
| `offset` | 跳过条目数 |

### 响应

返回一个 `PlaylistInfo[]` ,按相关程度降序排序。
28 changes: 0 additions & 28 deletions src/06.anniv/09.search.md

This file was deleted.

7 changes: 7 additions & 0 deletions src/08.annim/00.readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Annim

> ⚠️️ 目前的 `Annim` 仍处于 `Draft` 状态,尚未完全定稿。欢迎随时提出意见或建议。

> ⚠️️ 目前 `Annim` 协议的版本为 `1`。

`Annim` 是独立的元数据服务,每一个 `Annil` 都需要指定一个对应的 `Annim` 服务提供元数据。
105 changes: 105 additions & 0 deletions src/08.annim/01.protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Annim 元数据协议

Annim 元数据协议用于向客户端提供元数据服务。所有接口均使用 [Anni 信息导出格式](../06.anniv/07.export-format.md)。
Comment thread
SeraphJACK marked this conversation as resolved.

## 元数据

### 获取 Tag 列表

`GET /tags`

#### 返回

返回包含所有 `Tag` 的数组,类型为 `TagInfo[]` 。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

元数据相关的类型定义可以从 Anniv 里移出来了

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anniv 的分享还是会用到导出格式的

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

指放在 annim 里,anniv 也引这边的类型


### 专辑信息

通过 `album_id` 获得专辑元数据的接口。支持同时获取多张专辑的元数据信息。

#### Endpoint
Comment thread
SeraphJACK marked this conversation as resolved.

`GET /albums`
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated

#### 请求参数

| 参数名 | 说明 |
| ------ | ---------------------------- |
| `id[]` | 待获取元数据的专辑 `ID` 列表 |

#### 返回

返回以 `album_id` 为键,专辑元数据或空为值的 `Object`。

当查询成功时,值为专辑的 `AlbumDetail`,否则为 `null`。

### 按 Tag 检索专辑
Comment thread
SeraphJACK marked this conversation as resolved.

通过 Tag 检索归属于该 Tag 下的专辑列表。

该接口属于检索接口,标签使用「向上合并」的语义。即计算专辑标签时,需要取专辑内所有专辑标签、光盘标签和音轨标签的**并集**。具体定义见 [专辑信息 - 标签](../02.metadata-repository/02.album-information.md#标签)。

#### Endpoint

`GET /albums/by-tag`
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated

### 参数

| 参数名 | 类型 | 说明 |
| ----------- | --------- | ----------------------------- |
| `tag` | `string` | Tag 名 |
| `recursive` | `boolean` | 是否递归检索子 Tag 所包含专辑 |

#### 返回

`AlbumDetail[]`

#### 错误列表

| 错误代码 | 详情 |
| -------- | ------------ |
| `902000` | `Tag` 不存在 |

### 获取 Tag 关系

`GET /tag-graph`
Comment thread
SeraphJACK marked this conversation as resolved.

#### 返回

返回 `tag` 依赖关系的邻接表,类型表示为 `Record<string, string[]>` 。

`Key-Value` 对应的是标签与其所包含的子标签。字符串格式为 `<EDITION>:<NAME>`,标签类型不可省略。

## 搜索

### Endpoint

`GET /search`

### 请求参数

| 参数名 | 类型 | 说明 |
| --------------- | -------- | ------------------------ |
| `search_albums` | `bool` | 是否搜索专辑 |
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated
| `search_tracks` | `bool` | 是否搜索音轨 |
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated
| `keyword` | `string` | 搜索关键字 |
| `limit` | `number` | 最多返回条目数 |
| `offset` | `number` | 跳过多少条记录,缺省为 0 |

### 返回

返回 `SearchResult` ,结果按 `score` 降序排序。

#### 参数列表

```ts
interface Result<T> {
Comment thread
SeraphJACK marked this conversation as resolved.
Outdated
content: T;
// 归一化的 score ,必须为属于 [0, 100] 的浮点数
score: number;
}

interface SerachResult {
Comment thread
Yesterday17 marked this conversation as resolved.
Outdated
albums?: Result<AlbumDetail>[];
tracks?: Result<TrackInfoWithAlbum>[];
}
```
7 changes: 7 additions & 0 deletions src/08.annim/02.backend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Annim 元数据后端

Annim 不仅需要与客户端约定提供元数据的协议,也需要关于元数据来源的约定,这就是 Annim 元数据后端。

## Git repo 后端

使用 git 仓库作为元数据来源,仓库结构应符合[Anni 元数据仓库](../02.metadata-repository/00.readme.md)标准。
4 changes: 3 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
- [Annil Token 管理](./06.anniv/04.credential.md)
- [信息导出格式](./06.anniv/07.export-format.md)
- [专辑元数据](./06.anniv/08.meta.md)
- [搜索](./06.anniv/09.search.md)
- [分享管理](./06.anniv/05.share.md)
- [播放统计](./06.anniv/06.statistics.md)
- [喜欢](./06.anniv/10.favorite.md)
Expand All @@ -62,6 +61,9 @@
- [两步验证(2fa)](./06.anniv/features/02.2fa.md)
- [禁止注册(close)](./06.anniv/features/03.close.md)
- [预构建数据源(metadata-db)](./06.anniv/features/04.metadata-db.md)
- [Annim 元数据服务](./08.annim/00.readme.md)
- [协议](./08.annim/01.protocol.md)
- [元数据后端](./08.annim/02.backend.md)
- [Annisonic](./07.annisonic/00.readme.md)
- [实现的 API](./07.annisonic/01.apis.md)
- [已测试的客户端](./07.annisonic/02.clients.md)
Expand Down