diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..b3b6461 --- /dev/null +++ b/Home.md @@ -0,0 +1,9 @@ +# lx-music-api-server-python Wiki Page + +你想看点什么? + +是[部署方法](./部署方法.md)? + +还是[返回码说明](./返回码说明.md)? + +还是[备注]? diff --git a/备注.md b/备注.md new file mode 100644 index 0000000..1515286 --- /dev/null +++ b/备注.md @@ -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) + ``` diff --git a/返回码说明.md b/返回码说明.md new file mode 100644 index 0000000..bac0be1 --- /dev/null +++ b/返回码说明.md @@ -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) | \ No newline at end of file diff --git a/部署方法.md b/部署方法.md index 2ab7985..9de77b7 100644 --- a/部署方法.md +++ b/部署方法.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 ``` -4. 获取容器目录并到容器目录里的 `/app` 目录填写 `config.json` +4. 获取容器目录 ```bash docker inspect lx-music-api-server-python ``` + +5. 到容器目录里的 `/app` 目录填写 `config.json`