diff --git a/README.md b/README.md index 69d9333..6c170b4 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,22 @@ docker run -d \ hisatri/lrcapi:1.5.2 ``` +一个Docker-compose配置如下 + +```yaml +services: + lrcapi: + image: hisatri/lrcapi:latest + container_name: lrcapi + ports: + - "28883:28883" + volumes: + - /home/user/music:/music + environment: + - API_AUTH=自定义一个鉴权key + restart: always +``` + 如果你正在使用Navidrome Docker,请将 `/home/user/music:/music` 中的 `/home/user/music` 修改为你在Navidrome中映射的主机路径; 换句话说,`-v` 参数与Navidrome保持一致即可。 @@ -102,7 +118,7 @@ docker run -d \ 支持使用Nginx或Apache进行反向代理与SSL。 -## Tag修改接口 +## 音乐元数据修改接口 ### 接口详情 diff --git a/README_EN.md b/README_EN.md index 02f2fc7..4b630a2 100644 --- a/README_EN.md +++ b/README_EN.md @@ -6,7 +6,9 @@ A Flask API For [StreamMusic](https://github.com/gitbobobo/StreamMusic) -![LrcApi](https://socialify.git.ci/HisAtri/LrcApi/image?description=1&font=Source%20Code%20Pro&forks=1&language=1&name=1&owner=1&pattern=Circuit%20Board&stargazers=1&theme=Light) +> Welcome more music services to integrate with this API, and frontend developers are welcome to propose new API adaptation requirements. + +> [JetBrains](https://www.jetbrains.com/) provides free open-source licenses for this project.

@@ -21,78 +23,102 @@ A Flask API For [StreamMusic](https://github.com/gitbobobo/StreamMusic) 中文 | English -## Functions +## Features -Supports using KuGou API and Multi API to get lyrics. +Supports fetching LRC lyrics via Kugou/Aggregated API Supports text/json API -Supports obtaining music/album/artist covers +Supports fetching music/album/artist covers -Default listening on port 28883, with API addresses as follows: API `http://0.0.0.0:28883/lyrics` ;New version API `http://0.0.0.0:28883/jsonapi` ;Cover API `http://0.0.0.0:28883/cover` 。 +Listens on port 28883 by default, API address `http://0.0.0.0:28883/lyrics`; new API address `http://0.0.0.0:28883/jsonapi`; cover API address `http://0.0.0.0:28883/cover`. -### Launch Parameters +### Startup Parameters -| Parameter | Type | Default Value | -| -------- | -------- | -------- | -| `--port` | int | 28883 | -| `--auth` | str | | +| Parameter | Type | Default Value | +|-----------|------|---------------| +| `--port` | int | 28883 | +| `--auth` | str | | -The `--auth` parameter is used for header authentication. Leave it blank to skip authentication. It validates the `Authorization` or `Authentication` field in the header. If the authentication fails, a 403 response is returned. +The `--auth` parameter is used for header authentication. If left empty, authentication is skipped. It verifies the `Authorization` or `Authentication` field in the header. If authentication fails, a 403 response is returned. -Alternatively, you can define the authentication key using the environment variable `API_AUTH`. Its priority is lower than the `--auth` parameter but is more convenient for deployment in Docker. Use `-e API_AUTH=custom_authentication_key`. +You can also define it using the environment variable `API_AUTH`, which has lower priority than the `--auth` parameter but is easier to deploy in Docker. `-e API_AUTH=custom_auth_key` -## Instructions +## Usage ### Public API -If private deployment is not possible, you can try using the public API first. Note: The public API obtains lyrics through interfaces such as Kugou, and the response may be slow and not completely accurate. +If private deployment is not possible, you can try using the public API first. Note: The public API fetches lyrics via Kugou and other interfaces, which may be slow and not entirely accurate. -Lyrics API: `https://api.lrc.cx/lyrics` +Lyrics API address: `https://api.lrc.cx/lyrics` -CoverAPI: `https://api.lrc.cx/cover` +Cover API address: `https://api.lrc.cx/cover` -### Executable File +### Binary File -Upload to the running directory. `./lrcapi --port 8080 --auth {your_privat_key}` +Upload to the runtime directory, `./lrcapi --port 8080 --auth custom_auth_key` ### Python Source File -Pull this project; or download it and upload it to the running directory, and unzip `tar.gz` file. +Pull this project; or download and upload to the runtime directory, then unzip the tar.gz -Install requirements: `pip install -r requirements.txt` +Install dependencies: `pip install -r requirements.txt` -Start the service: `python3 app.py --port 8080 --auth 自定义一个鉴权key` +Start the service: `python3 app.py --port 8080 --auth custom_auth_key` -### Deploy via Docker +### Docker Deployment ```bash -docker run -d -p 28883:28883 -v /home/user/music:/music hisatri/lrcapi:latest +docker run -d \ + -p 28883:28883 \ + -v /home/user/music:/music \ + -e API_AUTH=custom_auth_key \ + hisatri/lrcapi:latest ``` -Alternatively, you can specify a Tag (recommended) +Alternatively, specify a tag (recommended) ```bash -docker run -d -p 28883:28883 -v /home/user/music:/music hisatri/lrcapi:alpine-py1.5.2 +docker run -d \ + -p 28883:28883 \ + -v /home/user/music:/music \ + -e API_AUTH=custom_auth_key \ + hisatri/lrcapi:1.5.2 +``` + +A Docker-compose configuration is as follows + +```yaml +services: + lrcapi: + image: hisatri/lrcapi:latest + container_name: lrcapi + ports: + - "28883:28883" + volumes: + - /home/user/music:/music + environment: + - API_AUTH=custom_auth_key + restart: always ``` -If you are using Navidrome Docker, please modify `/home/user/music:/music` by replacing `/home/user/music` with the host path you have mapped in Navidrome; +If you are using Navidrome Docker, modify `/home/user/music:/music` to the host path you mapped in Navidrome; -In other words, keep the `-v` parameter consistent with the path mapped in Navidrome. +In other words, keep the `-v` parameter consistent with Navidrome. -If you are using Navidrome without Docker, map your music directory to the corresponding Docker directory. For example, if your music is stored in `/www/path/music`, modify the mapping in the startup command to `/www/path/music:/www/path/music`. +If you are using Navidrome, map your music file directory to the Docker internal directory; for example, if your music storage directory is `/www/path/music`, modify the mapping in the startup command to `/www/path/music:/www/path/music` -Then, access `http://0.0.0.0:28883/lyrics` or the new version API `http://0.0.0.0:28883/jsonapi`. +Then access `http://0.0.0.0:28883/lyrics` or the new API `http://0.0.0.0:28883/jsonapi` -The image API address is `http://0.0.0.0:28883/cover`. +The image API address is `http://0.0.0.0:28883/cover` -Note: Image retrieval currently employs a reverse proxy strategy, which may result in some upstream and downstream traffic consumption and latency. +Note: Image returns currently use a reverse proxy strategy, which may incur some upstream and downstream traffic consumption and latency. -You can reverse proxy or SSL encryption through Nginx or Apache. +Supports reverse proxy and SSL using Nginx or Apache. -## API for Modifying Tags +## Music Metadata Modification Interface -### API Details +### Interface Details - Request Method: POST - Request Path: /tag @@ -100,28 +126,28 @@ You can reverse proxy or SSL encryption through Nginx or Apache. ### Supported Formats -Tested Formats: +Tested: -- FLAC (flac) -- ID3v2 (mp3) -- VorbisComment (ogg) +- FLAC(flac) +- ID3v2(mp3) +- VorbisComment(ogg) ### Supported Tags -- Title: title -- Artist: artist -- Album: album -- Lyrics: lyrics +- title +- artist +- album +- lyrics ### Status Codes - 200 Success -- 404 File Not Found -- 421 Unauthorized -- 422 Parsing Error -- 5xx Execution Error +- 404 File not found +- 421 No permission +- 422 Parsing error +- 5xx Execution error -### Simple Testing Environment +### Simple Test Environment ```python import requests @@ -140,20 +166,19 @@ print(response.text) ## Secondary Development Instructions -This program is based on the GPL-3.0 open-source license, and you are free to use, modify, and distribute it at no cost. When engaging in secondary development, please adhere to the following requirements: - -1. Retain the original copyright and license statements in your derivative works. -2. Clearly document any modifications you make to this program. -3. When distributing, provide the complete source code and distribute your derivative works under the GPL-3.0 license. -4. Any commercial use based on this program must comply with the GPL-3.0 license and maintain free and open access. -5. Components of this project other than the source code (including logos, services, or slogans) are not open-sourced under the GPL 3.0 license. +This program is based on the GPL-3.0 open-source license, and you are free to use, modify, and distribute this program. When developing secondary versions, please comply with the following requirements: +1. Retain the original copyright and license notices in your derivative works. +2. If you have modified this program, clearly state your modifications. +3. When distributing, you need to provide the complete source code and distribute your derivative works under the GPL-3.0 license. +4. Any commercial use based on this program needs to comply with the GPL-3.0 license and remain freely accessible. +5. Other parts of this project (including logos, services, or slogans, etc.) are not open-sourced under the GPL 3.0 agreement. -Please ensure that you thoroughly understand the requirements of the GPL-3.0 license and comply with relevant provisions. +Ensure you fully understand the requirements of the GPL-3.0 license and comply with the relevant regulations. -# Sponsor Me +# Appreciation WeChat reward -[![Star History Chart](https://api.star-history.com/svg?repos=HisAtri/LrcApi&type=Date)](https://star-history.com/#HisAtri/LrcApi&Date) +[![Star History Chart](https://api.star-history.com/svg?repos=HisAtri/LrcApi&type=Date)](https://star-history.com/#HisAtri/LrcApi&Date) \ No newline at end of file diff --git a/mod/searchx/api.py b/mod/searchx/api.py index 3f3b986..31858d5 100644 --- a/mod/searchx/api.py +++ b/mod/searchx/api.py @@ -10,7 +10,7 @@ def search(title='', artist='', album='') -> list: try: url = f"http://cn.lrc.cx:880/jsonapi?title={title}&artist={artist}&album={album}&path=None&limit=1&api=lrcapi" - response = requests.get(url, headers=headers, timeout=15) + response = requests.get(url, headers=headers) return response.json() except Exception as e: print(f"LrcAPI Server - Request failed: {e}")