mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
更新wiki
parent
741c3e6318
commit
7b6af4cee0
9
Home.md
Normal file
9
Home.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# lx-music-api-server-python Wiki Page
|
||||||
|
|
||||||
|
你想看点什么?
|
||||||
|
|
||||||
|
是[部署方法](./部署方法.md)?
|
||||||
|
|
||||||
|
还是[返回码说明](./返回码说明.md)?
|
||||||
|
|
||||||
|
还是[备注]?
|
93
备注.md
Normal file
93
备注.md
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
### 本项目中可能会出现以下优秀代码
|
||||||
|
|
||||||
|
1. 三角形具有稳定性
|
||||||
|
|
||||||
|
```python
|
||||||
|
for a in xxx:
|
||||||
|
if (xxx):
|
||||||
|
if (xxx):
|
||||||
|
if (xxx):
|
||||||
|
for b in xxx:
|
||||||
|
if (xxx):
|
||||||
|
while (xxx):
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 能一行写完那就坚决不多行
|
||||||
|
|
||||||
|
```python
|
||||||
|
sys.stdout.write('\r|'+'=' * (int(dd['pares'].index(ds) / total * 50)) + ' ' * (49 - int(dd['pares'].index(ds) / total * 50)) + f'''|{int(dd['pares'].index(ds) / total * 100)}% xx''' + ds['title']+' ' * 20)
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 不复用重复部分
|
||||||
|
|
||||||
|
```python
|
||||||
|
async def other(method, source, songid, _):
|
||||||
|
try:
|
||||||
|
func = require('modules.' + source + '.' + method)
|
||||||
|
except:
|
||||||
|
return {
|
||||||
|
'code': 1,
|
||||||
|
'msg': '未知的源或不支持的方法',
|
||||||
|
'data': None,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
result = await func(songid)
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': 'success',
|
||||||
|
'data': result
|
||||||
|
}
|
||||||
|
except FailedException as e:
|
||||||
|
return {
|
||||||
|
'code': 2,
|
||||||
|
'msg': e.args[0],
|
||||||
|
'data': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
async def other_with_query(method, source, t, _, query):
|
||||||
|
try:
|
||||||
|
func = require('modules.' + source + '.' + method)
|
||||||
|
except:
|
||||||
|
return {
|
||||||
|
'code': 1,
|
||||||
|
'msg': '未知的源或不支持的方法',
|
||||||
|
'data': None,
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
result = await func(t, query)
|
||||||
|
return {
|
||||||
|
'code': 0,
|
||||||
|
'msg': 'success',
|
||||||
|
'data': result
|
||||||
|
}
|
||||||
|
except FailedException as e:
|
||||||
|
return {
|
||||||
|
'code': 2,
|
||||||
|
'msg': e.args[0],
|
||||||
|
'data': None,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
4. 模块不拆分
|
||||||
|
|
||||||
|
详见[config.py](https://github.com/lxmusics/lx-music-api-server-python/tree/main/common/config.py)
|
||||||
|
|
||||||
|
5. 不明所以的变量名
|
||||||
|
|
||||||
|
```python
|
||||||
|
a = '小明'
|
||||||
|
b = 1
|
||||||
|
c = 2
|
||||||
|
d = b''
|
||||||
|
def e(a, b, c):
|
||||||
|
c = xxx
|
||||||
|
d = xxx
|
||||||
|
f = e(c, b, a)
|
||||||
|
```
|
20
返回码说明.md
Normal file
20
返回码说明.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
接口返回值中`body.code`字段值中的代码含义
|
||||||
|
|
||||||
|
| 内容 | 含义 |
|
||||||
|
| ---- | ------------------------------------- |
|
||||||
|
| 0 | 成功 |
|
||||||
|
| 1 | IP 被封禁或不支持反代 |
|
||||||
|
| 2 | 获取失败 |
|
||||||
|
| 4 | 服务器内部错误(对应 statuscode 500) |
|
||||||
|
| 5 | 请求过于频繁 |
|
||||||
|
| 6 | 参数错误 |
|
||||||
|
|
||||||
|
接口返回的`statuscode`对应的代码含义
|
||||||
|
|
||||||
|
| 内容 | 含义 |
|
||||||
|
| ---- | ---------------------------------- |
|
||||||
|
| 200 | 成功 |
|
||||||
|
| 403 | IP 被封禁 |
|
||||||
|
| 400 | 参数错误 |
|
||||||
|
| 429 | 请求过于频繁 |
|
||||||
|
| 500 | 服务器内部错误(对应 body.code 4) |
|
4
部署方法.md
4
部署方法.md
@ -82,8 +82,10 @@ linux 命令如果为 python3 请自行替换
|
|||||||
docker run --name lx-music-api-server-python -p 9763:9763 -d ikun0014/lx-music-api-server-python:latest
|
docker run --name lx-music-api-server-python -p 9763:9763 -d ikun0014/lx-music-api-server-python:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
4. 获取容器目录并到容器目录里的 `/app` 目录填写 `config.json`
|
4. 获取容器目录
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker inspect lx-music-api-server-python
|
docker inspect lx-music-api-server-python
|
||||||
```
|
```
|
||||||
|
|
||||||
|
5. 到容器目录里的 `/app` 目录填写 `config.json`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user