mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 14:57:52 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80f63f1174 | ||
|
|
2ced7ee49b | ||
|
|
684ecb4221 | ||
|
|
62027d38fb | ||
|
|
491a2e7e5e | ||
|
|
c4e7565703 | ||
|
|
bbf535e97b | ||
|
|
f9f378e7eb | ||
|
|
d0310450e5 | ||
|
|
80aaa94b06 | ||
|
|
62befe706c | ||
|
|
b429e451dd |
@@ -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 }}
|
|
||||||
|
|||||||
@@ -6,14 +6,17 @@ on:
|
|||||||
- dev
|
- dev
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Use docker.io for Docker Hub if empty
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
# github.repository as <account>/<repo>
|
# github.repository as <account>/<repo>
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
DOCKER_IMAGE_NAME: missuo/deeplx
|
||||||
|
GHCR_IMAGE_NAME: ${{ github.repository }}
|
||||||
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
GHCR_TOKEN: ${{ secrets.GT_Token }}
|
||||||
|
GHCR_USERNAME: ${{ github.repository_owner }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
docker_build:
|
docker_build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
@@ -34,27 +37,35 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: docker.io
|
||||||
|
username: ${{ env.DOCKER_USERNAME }}
|
||||||
|
password: ${{ env.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ env.GHCR_USERNAME }}
|
||||||
password: ${{ secrets.GT_Token }}
|
password: ${{ env.GHCR_TOKEN }}
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
# list of Docker images to use as base name for tags
|
# list of Docker images to use as base name for tags
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: |
|
||||||
|
docker.io/${{ env.DOCKER_IMAGE_NAME }}
|
||||||
|
ghcr.io/${{ env.GHCR_IMAGE_NAME }}
|
||||||
# generate Docker tags based on the following events/attributes
|
# generate Docker tags based on the following events/attributes
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
type=pep440,pattern={{raw}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
type=pep440,pattern={{raw}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||||
tpye=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
|
||||||
- name: Build dev branch and push
|
- name: Build and push
|
||||||
if: github.ref == 'refs/heads/dev'
|
|
||||||
uses: docker/build-push-action@v3
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -64,15 +75,3 @@ jobs:
|
|||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: Build release and push
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
name: Docker Image CI Dockerhub
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- dev
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
env:
|
|
||||||
# Use docker.io for Docker Hub if empty
|
|
||||||
REGISTRY: docker.io
|
|
||||||
# github.repository as <account>/<repo>
|
|
||||||
IMAGE_NAME: missuo/deeplx
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
docker_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
with:
|
|
||||||
platforms: all
|
|
||||||
|
|
||||||
- name: Set up docker buildx
|
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
registry: docker.io
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
# list of Docker images to use as base name for tags
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
# generate Docker tags based on the following events/attributes
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
||||||
type=pep440,pattern={{raw}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
||||||
tpye=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
|
||||||
|
|
||||||
- name: Build dev branch and push
|
|
||||||
if: github.ref == 'refs/heads/dev'
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Build release and push
|
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
@@ -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-16 20:24:59
|
* @LastEditTime: 2023-04-23 13:49:08
|
||||||
* @FilePath: /DeepLX/README.md
|
* @FilePath: /DeepLX/README.md
|
||||||
* @Telegram: https://t.me/missuo
|
* @Telegram: https://t.me/missuo
|
||||||
*
|
*
|
||||||
@@ -11,11 +11,12 @@
|
|||||||
# DeepL X
|
# DeepL X
|
||||||
Permanently free DeepL API written in Golang
|
Permanently free DeepL API written in Golang
|
||||||
|
|
||||||
|
**Added Python Package: [OwO-Network/PyDeepLX](https://github.com/OwO-Network/PyDeepLX)**
|
||||||
|
|
||||||
## 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
|
||||||
@@ -36,6 +37,13 @@ Permanently free DeepL API written in Golang
|
|||||||
"id": 8300079001
|
"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
|
||||||
@@ -51,7 +59,10 @@ docker run -itd -p 1188:1188 missuo/deeplx:latest
|
|||||||
mkdir deeplx
|
mkdir deeplx
|
||||||
cd deeplx
|
cd deeplx
|
||||||
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/docker-compose.yaml
|
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/docker-compose.yaml
|
||||||
|
# docker compose v1
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
# or docker compose v2
|
||||||
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run on Linux Server
|
### Run on Linux Server
|
||||||
@@ -61,6 +72,7 @@ bash <(curl -Ls https://cpp.li/deeplx)
|
|||||||
|
|
||||||
### Run on Mac
|
### Run on Mac
|
||||||
#### Homebrew (Recommended)
|
#### Homebrew (Recommended)
|
||||||
|
**For unknown reasons v0.7.8 does not work properly with Homebrew, so we are still using v0.7.7 for our version of Homebrew, it has no bugs and it is almost perfect.**
|
||||||
```bash
|
```bash
|
||||||
brew tap owo-network/brew
|
brew tap owo-network/brew
|
||||||
brew install deeplx
|
brew install deeplx
|
||||||
@@ -121,6 +133,23 @@ systemctl enable deeplx
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## 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
|
||||||
docker run -itd -p 1188:80 missuo/deeplx-bk
|
docker run -itd -p 1188:80 missuo/deeplx-bk
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/OwO-Network/deepl-api
|
module github.com/OwO-Network/DeepLX
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -225,5 +239,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
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