mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 14:57:52 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
491a2e7e5e | ||
|
|
c4e7565703 | ||
|
|
bbf535e97b | ||
|
|
f9f378e7eb | ||
|
|
d0310450e5 | ||
|
|
80aaa94b06 | ||
|
|
62befe706c | ||
|
|
b429e451dd | ||
|
|
cbd1507335 | ||
|
|
db722920cd | ||
|
|
a5b256d7ad | ||
|
|
6befe9c53d | ||
|
|
1ecf4480d6 | ||
|
|
6d4f38c051 | ||
|
|
b35c1d6622 |
@@ -0,0 +1 @@
|
|||||||
|
custom: https://paypal.me/missuo
|
||||||
@@ -25,5 +25,3 @@ jobs:
|
|||||||
draft: false
|
draft: false
|
||||||
files: |
|
files: |
|
||||||
dist/*
|
dist/*
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GT_Token }}
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: Vincent Young
|
* @Author: Vincent Young
|
||||||
* @Date: 2022-10-18 07:32:29
|
* @Date: 2022-10-18 07:32:29
|
||||||
* @LastEditors: Vincent Young
|
* @LastEditors: Vincent Young
|
||||||
* @LastEditTime: 2023-03-03 02:30:52
|
* @LastEditTime: 2023-04-23 13:25:08
|
||||||
* @FilePath: /DeepLX/README.md
|
* @FilePath: /DeepLX/README.md
|
||||||
* @Telegram: https://t.me/missuo
|
* @Telegram: https://t.me/missuo
|
||||||
*
|
*
|
||||||
@@ -12,10 +12,9 @@
|
|||||||
Permanently free DeepL API written in Golang
|
Permanently free DeepL API written in Golang
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
- `deeplx` in only run in port `1188`, later versions will do the specified port.
|
- `DeepLX` is listening to `0.0.0.0:1188` by default. You can modify the listening port by yourself.
|
||||||
- `deeplx` is listening to `0.0.0.0:1188` by default.
|
- `DeepLX` is using `DeepL` Free API.
|
||||||
- `deeplx` is using `DeepL` Free API.
|
- `DeepLX` is unlimited to the number of requests.
|
||||||
- `deeplx` is unlimited to the number of requests.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
### Request Parameters
|
### Request Parameters
|
||||||
@@ -26,15 +25,42 @@ Permanently free DeepL API written in Golang
|
|||||||
### Response
|
### Response
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"alternatives": [
|
||||||
|
"Undisputed",
|
||||||
|
"Unquestionable",
|
||||||
|
"Unquestionably"
|
||||||
|
],
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"data": "Hello world",
|
"data": "Undoubtedly",
|
||||||
"id": 8305092005
|
"id": 8300079001
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
### Specify the port
|
||||||
|
**Thanks to [cijiugechu](https://github.com/cijiugechu) for [his contribution](https://github.com/OwO-Network/DeepLX/commit/4a0920579ea868b0f05ccdff6bceae316bfd5dc8) to make this feature possible for this project!**
|
||||||
|
```bash
|
||||||
|
./deeplx -p 3333
|
||||||
|
# or
|
||||||
|
./deeplx -port 3333
|
||||||
|
```
|
||||||
|
|
||||||
### Run with Docker
|
### Run with Docker
|
||||||
```bash
|
```bash
|
||||||
|
# ghcr.io
|
||||||
docker run -itd -p 1188:1188 ghcr.io/owo-network/deeplx:latest
|
docker run -itd -p 1188:1188 ghcr.io/owo-network/deeplx:latest
|
||||||
|
|
||||||
|
# dockerhub
|
||||||
|
docker run -itd -p 1188:1188 missuo/deeplx:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run with Docker Compose
|
||||||
|
```bash
|
||||||
|
mkdir deeplx
|
||||||
|
cd deeplx
|
||||||
|
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/docker-compose.yaml
|
||||||
|
# docker compose v1
|
||||||
|
docker-compose up -d
|
||||||
|
# or docker compose v2
|
||||||
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run on Linux Server
|
### Run on Linux Server
|
||||||
@@ -58,7 +84,6 @@ brew services restart owo-network/brew/deeplx
|
|||||||
brew list --versions deeplx
|
brew list --versions deeplx
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Manual
|
#### Manual
|
||||||
1. Download the latest release of DeepL X.
|
1. Download the latest release of DeepL X.
|
||||||
```bash
|
```bash
|
||||||
@@ -91,17 +116,36 @@ systemctl enable deeplx
|
|||||||
## Setup on [Bob App](https://bobtranslate.com/)
|
## Setup on [Bob App](https://bobtranslate.com/)
|
||||||
1. Install [bob-plugin-deeplx](https://github.com/missuo/bob-plugin-deeplx) on Bob.
|
1. Install [bob-plugin-deeplx](https://github.com/missuo/bob-plugin-deeplx) on Bob.
|
||||||
|
|
||||||
2. Setup the API.
|
2. Setup the API. (If you use Brew to install locally you can skip this step)
|
||||||

|

|
||||||
|
|
||||||
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
|
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
|
||||||
|
**It is not recommended, because the `immersive-translate` will send many requests in a short time, which will cause the `DeepL API` to block your IP.**
|
||||||
|
|
||||||
1. Install Latest [immersive-translate ](https://github.com/immersive-translate/immersive-translate/releases) on your browser.
|
1. Install Latest [immersive-translate ](https://github.com/immersive-translate/immersive-translate/releases) on your browser.
|
||||||
|
|
||||||
2. Click on **Developer Settings** in the bottom left corner. **Enable Beta experimental features**.
|
2. Click on **Developer Settings** in the bottom left corner. **Enable Beta experimental features**.
|
||||||
|
|
||||||
3. Set the URL.
|
3. Set the URL. (If you are not deploying locally, you need to change 127.0.0.1 to the IP of your server)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Use in Python
|
||||||
|
```python
|
||||||
|
import httpx, json
|
||||||
|
|
||||||
|
deeplx_api = "http://127.0.0.1:1188/translate"
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"text": "Hello World",
|
||||||
|
"source_lang": "EN",
|
||||||
|
"target_lang": "ZH"
|
||||||
|
}
|
||||||
|
|
||||||
|
post_data = json.dumps(data)
|
||||||
|
r = httpx.post(url = deeplx_api, data = post_data).text
|
||||||
|
print(r)
|
||||||
|
```
|
||||||
|
|
||||||
## Backup the Docker Image of zu1k
|
## Backup the Docker Image of zu1k
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
deeplx:
|
||||||
|
image: ghcr.io/owo-network/deeplx:latest
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "1188:1188"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/OwO-Network/deepl-api
|
module github.com/OwO-Network/DeepLX
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-playground/locales v0.14.0 // indirect
|
github.com/go-playground/locales v0.14.0 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg=
|
||||||
|
github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw=
|
||||||
github.com/abadojack/whatlanggo v1.0.1 h1:19N6YogDnf71CTHm3Mp2qhYfkRdyvbgwWdd2EPxJRG4=
|
github.com/abadojack/whatlanggo v1.0.1 h1:19N6YogDnf71CTHm3Mp2qhYfkRdyvbgwWdd2EPxJRG4=
|
||||||
github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH9B/K8tQB2uoc=
|
github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH9B/K8tQB2uoc=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
@@ -17,7 +18,17 @@ import (
|
|||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var port int
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
const (
|
||||||
|
defaultPort = 1188
|
||||||
|
usage = "set up the port to listen on"
|
||||||
|
)
|
||||||
|
|
||||||
|
flag.IntVar(&port, "port", defaultPort, usage)
|
||||||
|
flag.IntVar(&port, "p", defaultPort, usage)
|
||||||
|
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,8 +109,11 @@ type ResData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// parse flags
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
// display information
|
// display information
|
||||||
fmt.Println("DeepL X has been successfully launched! Listening on 0.0.0.0:1188")
|
fmt.Printf("DeepL X has been successfully launched! Listening on 0.0.0.0:%v\n", port)
|
||||||
fmt.Println("Made by sjlleo and missuo.")
|
fmt.Println("Made by sjlleo and missuo.")
|
||||||
|
|
||||||
// create a random id
|
// create a random id
|
||||||
@@ -193,6 +207,7 @@ func main() {
|
|||||||
|
|
||||||
body, _ := io.ReadAll(resp.Body)
|
body, _ := io.ReadAll(resp.Body)
|
||||||
res := gjson.ParseBytes(body)
|
res := gjson.ParseBytes(body)
|
||||||
|
|
||||||
// display response
|
// display response
|
||||||
// fmt.Println(res)
|
// fmt.Println(res)
|
||||||
if res.Get("error.code").String() == "-32600" {
|
if res.Get("error.code").String() == "-32600" {
|
||||||
@@ -210,13 +225,20 @@ func main() {
|
|||||||
"message": "Too Many Requests",
|
"message": "Too Many Requests",
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
var alternatives []string
|
||||||
|
res.Get("result.texts.0.alternatives").ForEach(func(key, value gjson.Result) bool {
|
||||||
|
alternatives = append(alternatives, value.Get("text").String())
|
||||||
|
return true
|
||||||
|
})
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": http.StatusOK,
|
"code": http.StatusOK,
|
||||||
"id": id,
|
"id": id,
|
||||||
"data": res.Get("result.texts.0.text").String(),
|
"data": res.Get("result.texts.0.text").String(),
|
||||||
|
"alternatives": alternatives,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
r.Run(":1188") // listen and serve on 0.0.0.0:1188
|
// by default, listen and serve on 0.0.0.0:1188
|
||||||
|
r.Run(fmt.Sprintf(":%v", port))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user