跳转到主要内容

有道控制台版本,Youdao API的简单封装

项目描述

有道在线翻译(中文 <-> 英文)服务的简单封装 API,作为StarDict控制台版本(sdcv)的替代品。

注意

本工具已停止提供公共服务。用户若要继续使用,需申请一个私人的有道智云 API Key进行配置。大致步骤为: 翻译实例-创建实例-选“文本翻译”,我的应用-创建应用-接入方式:API-选择绑定刚才创建的自然语言翻译服务-文本翻译实例。得到的应用ID / 应用密钥即为本工具的YDAPPID/YDAPPSEC

本工具可通过环境变量YDCV_YOUDAO_APPIDYDCV_YOUDAO_APPSEC以及ini文件方式配置key。配置文件默认为~/.ydcv,也可用--config指定。配置文件例子:

[YDCV]
YDAPPID=123456
YDAPPSEC=abcd1234

用法

$ ydcv --help
usage: ydcv.py [-h] [-f] [-s] [-S] [-r] [-p {festival,mpg123,sox,mpv}]
               [-a {auto,uk,us}] [-x] [--color {always,auto,never}]
               [-F {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}]
               [-t {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}]
               [words [words ...]]

Youdao Console Version

positional arguments:
  words                 words to lookup, or quoted sentences to translate.

optional arguments:
  -h, --help            show this help message and exit
  -f, --full            print full web reference, only the first 3 results
                        will be printed without this flag.
  -s, --simple          only show explainations. argument "-f" will not take
                        effect.
  -S, --speech          print URL to speech audio.
  -r, --read            read out the word with player provided by "-p" option.
  -p {festival,mpg123,sox,mpv}, --player {festival,mpg123,sox,mpv}
                        read out the word with this play.Default to 'festival'
                        or can be 'mpg123', 'sox', 'mpv'.-S option is required
                        if player is not festival.
  -a {auto,uk,us}, --accent {auto,uk,us}
                        set default accent to read the word in. Default to
                        'auto' or can be 'uk', or 'us'.
  -x, --selection       show explaination of current selection.
  --color {always,auto,never}
                        colorize the output. Default to 'auto' or can be
                        'never' or 'always'.
  -F {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}, --from {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}
                        Translate from specific language. Default: EN
  -t {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}, --to {zh-CHS,ja,EN,ko,fr,ru,pt,es,vi,de,ar,id}
                        Translate to specific language. Default: zh-CHS

支持翻译的语言列表

--from--to 参数可以指定特定语言之间相互翻译,但只有中文结果有词典内容

语言

代码

语言

代码

语言

代码

语言

代码

中文

zh-CHS

葡萄牙文

pt

韩文

ko

德文

de

日文

ja

西班牙文

es

法文

fr

阿拉伯文

ar

英文

EN

越南文

vi

俄文

ru

印尼文

id

安装

pip install ydcv

环境

  • Python ( >=2.7, 3.x )

github上的类似项目

语言

项目

作者

Go

ydgo

boypt

RUST

ydcv-rs

farseerfc

RUST

ydcv-rust

passchaos

Powershell

ydcv.ps1

atupal

BASH

ydcv-bash-version

MasterCsquare

Perl

ydcv

JaHIY

C

cydcv

proudzhu

C++

ydcv-cpp

proudzhu

ViM

ydcv.vim

bennyyip

Erlang

ydcv-el

zhenglinj

Haskell

ydcv-hs

proudzhu

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

ydcv-0.7.tar.gz (21.2 kB 查看散列)

上传时间 源代码

构建分发

ydcv-0.7-py3-none-any.whl (20.4 kB 查看散列)

上传时间 Python 3

支持