提交 9393ce14 编写于 作者: a865501259's avatar a865501259

Use: diskdb

上级 58a146d6
......@@ -93,7 +93,7 @@ Example
const noDone = [];
let showAsyncnum = 0;
loggerStart('translate running ...');
loggerStart('translate running ... >> ');
async.mapLimit(getList, asyncNum, runTranslate,
(err, IsTranslateS) => {
loggerStop();
......
......@@ -15,6 +15,15 @@ timeWait = configs['timewait'],
getValuesFile = configs['getvalues'],
gotTranslateFile = configs['translate'],
apis = configs['apis'];
// Cache right result
let cache = configs['cache'];
let cacheName = configs['cacheName'];
const {setDisk, getDisk} = require("./util/diskCache")(cacheName)
// Fix china symbal
const fixZhtoEn = require("./Fix/fixZhtoEn.js")
// Fix result.length no equal
......@@ -161,13 +170,23 @@ async function setObjectKey(obj, opts) {
for (let third in chunkTranArray) {
let thisChunkTran = chunkTranArray[third]
let thisChunkTran = chunkTranArray[third]
let thisInfo = ""
let isWork = true
// auto change translate source
allAPi = allAPi.filter(x => x != api)
allAPi.push(api)
let thisResult = []
// get cache disk with chunk result
let cacheRes = getDisk(cacheName, {source:thisChunkTran.join("\n")})
if(cacheRes && cacheRes.result){
thisResult = cacheRes.result
isWork = false
thisInfo = y(`result: come from Cache disk`)
}
if(isWork)
for (let i in allAPi) { // Auto next api
loggerText(`2. ${yow(relaPath(opts.name))} use ${g(api)} ${resultArray.length}/${thisTranArray.length} - ${tips}`)
......@@ -228,7 +247,7 @@ async function setObjectKey(obj, opts) {
}
if (isWork) { // can fetch something result
if (isWork && !errMsg) { // can fetch something result
// Fix use Fix/lengthEqual.js in every Chunk
let markChunkTran = [].concat(thisChunkTran); // mark some emoji, display the split
......@@ -261,10 +280,22 @@ async function setObjectKey(obj, opts) {
resultArray = resultArray.concat(thisResult) // Add result
loggerText(`3. translate loading - ${resultArray.length}/${thisTranArray.length}`)
loggerText(`3. translate loading - ${resultArray.length}/${thisTranArray.length} < ${thisInfo}`)
if(errMsg && !Force){
break;
}else if(!errMsg && cache && !thisInfo){ // cache with cache-name
let cacheStruct = {
time: new Date().getTime(),
api: api,
f:tranF,
t:tranT,
source: thisChunkTran.join("\n"),
result: thisResult
}
setDisk(cacheName, {source:cacheStruct.source}, cacheStruct)
loggerText(`3.1. ${g("cached")} the translate result`)
}
}
......@@ -277,7 +308,7 @@ async function setObjectKey(obj, opts) {
}
if (howManyValNoTran > 0) {
newObj.Error = `no translate number: ${howManyValNoTran}/${thisTranArray.length} ${errMsg}`
newObj.Error = `translated number: ${resultArray.length - howManyValNoTran}/${thisTranArray.length} ${errMsg}`
}
......
[{"time":1543585730090,"api":"baidu","f":false,"t":"zh","source":" is a tiny command-line utility to download media contents (videos, audios, images) from the Web, in case there is no other handy way to do it.\nHere's how you use \n to download a video from \n:\nAnd here's why you might want to use it:\nYou enjoyed something on the Internet, and just want to download them for your own pleasure.\nYou watch your favorite videos online from your computer, but you are prohibited from saving them. You feel that you have no control over your own computer. (And it's not how an open Web is supposed to work.)\nYou want to get rid of any closed-source technology or proprietary JavaScript code, and disallow things like Flash running on your computer.\nYou are an adherent of hacker culture and free software.\nWhat \n can do for you:\nDownload videos / audios from popular websites such as YouTube, Youku, Niconico, and a bunch more. (See the \n)\nStream an online video in your media player. No web browser, no more ads.\nDownload images (of interest) by scraping a web page.\nDownload arbitrary non-HTML contents, i.e., binary files.\nInterested? \n now and \n.\nAre you a Python programmer? Then check out \n and fork it!\nThe following dependencies are required and must be installed separately, unless you are using a pre-built package or chocolatey on Windows:\n (strongly recommended) or \n(Optional) \nThe official release of \n is distributed on \n, and can be installed easily from a PyPI mirror via the \n package manager. Note that you must use the Python 3 version of \n:","result":["这是一个很小的命令行实用程序,用于从Web下载媒体内容(视频、音频、图像),以防没有其他方便的方法这样做。","以下是你如何使用","下载视频",":","这就是为什么你可能想要使用它:","你喜欢网上的东西,只是想自己下载。","你在网上看你最喜欢的视频,但你被禁止保存。你觉得你无法控制自己的电脑。(这不是开放的网络应该如何工作。)","您希望摆脱任何封闭源代码技术或专有的JavaScript代码,并且不允许诸如Flash之类的东西在计算机上运行。","你是黑客文化和自由软件的拥护者。","什么","可以为你做:","从流行网站下载视频/音频,比如YouTube、优酷、Niconico等等。(见",")","流媒体播放器中的在线视频。没有网络浏览器,没有广告。","通过浏览网页下载感兴趣的图片。","下载任意的非HTML内容,即二进制文件。","感兴趣?","现在和",".","你是Python程序员吗?然后退房","把它叉起来!","除非您在Windows上使用预先构建的包或巧克力,否则需要并必须单独安装以下依赖项:","(强烈推荐)","(可选)","官方发布","分布在","可以通过PyPI反射镜轻松安装","包装经理。注意,必须使用Python 3版本",":"],"_id":"ebd25976a0d44655807e89d1df82044d"},{"time":1543585730094,"api":"baidu","f":false,"t":"zh","source":"Add the following line to your \n:\nDownload the \n (standalone) or \n (all dependencies included) from: \n.\nYou may either download the \n (identical with the latest release on PyPI) or the \n (more hotfixes, unstable features) branch of \n. Unzip it, and put the directory containing the \n script into your \n.\nAlternatively, run\nOr\nto install \n to a permanent path.\nThis is the recommended way for all developers, even if you don't often code in Python.\nThen put the cloned directory into your \n, or run \n to install \n to a permanent path.\nYou can install \n easily via:\nYou can install \n easily via:\nCompletion definitions for Bash, Fish and Zsh can be found in \n. Please consult your shell's manual for how to take advantage of them.\nBased on which option you chose to install \n, you may upgrade it via:","result":["将下列行添加到您的",":","下载","(独立)或","(包括所有依赖项):",".","你可以下载","(与PYPI上的最新版本相同)","(更多的热修复,不稳定的特征)分支",". 解压它,并将目录包含","脚本进入你的",".","或者,运行","或","安装","通向永恒的道路。","这是所有开发人员的推荐方法,即使您不经常使用Python进行编码。","然后把克隆目录放进你的","或运行","安装","通向永恒的道路。","你可以安装","容易通过:","你可以安装","容易通过:","BASH、FISH和ZSH的完成定义可以在",". 请参阅您的壳牌手册如何利用它们。","基于您选择安装的选项","您可以通过以下方式升级:"],"_id":"39552ca854fb4ae18c3e6faf5272fd15"},{"time":1543585819204,"api":"baidu","f":false,"t":"zh-CN","source":"or download the latest release via:\nor use \n:\nIn order to get the latest \n branch without messing up the PIP, you can try:\nWhen you get a video of interest, you might want to use the \n/\n option to see all available quality and formats:\nThe format marked with \n is the one you will get by default. If that looks cool to you, download it:\n(If a YouTube video has any closed captions, they will be downloaded together with the video file, in SubRip subtitle format.)\nOr, if you prefer another format (mp4), just use whatever the option \n shows to you:\nNote:\nAt this point, format selection has not been generally implemented for most of our supported sites; in that case, the default format to download is the one with the highest quality.\n is a required dependency, for downloading and joining videos streamed in multiple parts (e.g. on some sites like Youku), and for YouTube videos of 1080p or high resolution.\nIf you don't want \n to join video parts after downloading them, use the \n/\n option.\nIf you already have the URL of the exact resource you want, you can download it directly with:\nOtherwise, \n will scrape the web page and try to figure out if there's anything interesting to you:\nNote:\nThis feature is an experimental one and far from perfect. It works best on scraping large-sized images from popular websites like Tumblr and Blogger, but there is really no universal pattern that can apply to any site on the Internet.\nYou can pass literally anything to \n. If it isn't a valid URL, \n will do a Google search and download the most relevant video for you. (It might not be exactly the thing you wish to see, but still very likely.)\nYou may use ","result":["或通过以下方式下载最新版本:","或使用",":","为了得到最新的","分支没有弄乱PIP,您可以尝试:","当您获得感兴趣的视频时,您可能希望使用","/","选择查看所有可用的质量和格式:","标记的格式","是默认情况下得到的。如果你看起来很酷,下载它:","(如果YouTube视频有任何关闭的标题,它们将和视频文件一起以SubRip字幕格式下载。)","或者,如果你喜欢另一种格式(MP4),只需使用任何选项","向你展示:","注:","此时,大多数受支持的站点通常没有实现格式选择;在这种情况下,要下载的默认格式是最高质量的格式。","对于下载和连接以多个部分(例如,在优酷等一些网站上)流传输的视频以及1080p或高分辨率的YouTube视频来说,是必需的依赖项。","如果你不想要","在下载视频部分后,使用","/","选择权。","如果您已经拥有所需的确切资源的URL,则可以直接使用:","否则,","将刮掉网页,并试图找出是否有什么有趣的你:","注:","这个特点是实验性的,还远远不够完善。它最适合从Tumblr和Blogger等流行网站上刮取大型图像,但是实际上没有一种通用的模式可以应用于互联网上的任何站点。","你可以随便传递任何东西",". 如果它不是一个有效的URL,","会做谷歌搜索并下载最相关的视频给你。(这可能不是你想看到的,但还是很有可能的。)","您可以使用"],"_id":"c39b539f775b4761803d0f74beaee6e6"},{"time":1543585820535,"api":"baidu","f":false,"t":"zh-CN","source":"Ctrl\n+\nC\n to interrupt a download.\nA temporary \n file is kept in the output directory. Next time you run \n with the same arguments, the download progress will resume from the last session. In case the file is completely downloaded (the temporary \n extension is gone), \n will just skip the download.\nTo enforce re-downloading, use the \n/\n option. (\nWarning:\n doing so will overwrite any existing file or temporary file with the same name!)\nUse the \n/\n option to set the path, and \n/\n to set the name of the downloaded file:\nTips:\nThese options are helpful if you encounter problems with the default video titles, which may contain special characters that do not play well with your current shell / operating system / filesystem.\nThese options are also helpful if you write a script to batch download files and put them into designated folders with designated names.\nYou may specify an HTTP proxy for \n to use, via the \n/\n option:\nHowever, the system proxy setting (i.e. the environment variable \n) is applied by default. To disable any proxy, use the \n option.","result":["Ctrl键","+","C","中断下载。","暂时的","文件保存在输出目录中。下次你跑步","使用相同的参数,下载进度将从上一个会话恢复。在文件完全下载的情况下(临时)","延期了,","只会跳过下载。","要强制重新下载,请使用","/","选择权。(","警告:","这样做将覆盖任何现有文件或同名的临时文件!","使用","/","设置路径的选项,以及","/","设置下载文件的名称:","提示:","如果遇到默认视频标题的问题,这些选项很有用,这些默认视频标题可能包含与当前shell/操作系统/文件系统不匹配的特殊字符。","如果您编写脚本来批量下载文件,并将它们放入具有指定名称的指定文件夹,这些选项也会很有帮助。","您可以指定一个HTTP代理","使用,通过","/","选项:","但是,系统代理设置(即环境变量)","默认情况下应用。若要禁用任何代理,请使用","选择权。"],"_id":"8930db293c9b4bd0a78c74a2377a5a65"},{"time":1543585822071,"api":"baidu","f":false,"t":"zh-CN","source":"Tips:\nIf you need to use proxies a lot (in case your network is blocking certain sites), you might want to use \n with \n and set \n (in Bash).\nFor some websites (e.g. Youku), if you need access to some videos that are only available in mainland China, there is an option of using a specific proxy to extract video information from the site: \n/\n.\nUse the \n/\n option to feed the video into your media player of choice, e.g. \n or \n, instead of downloading it:\nOr, if you prefer to watch the video in a browser, just without ads or comment section:\nTips:\nIt is possible to use the \n option to start another download manager, e.g., \n, though they may not play together very well.\nNot all videos are publicly available to anyone. If you need to log in your account to access something (e.g., a private video), it would be unavoidable to feed the browser cookies to \n via the \n/\n option.\nNote:\nAs of now, we are supporting two formats of browser cookies: Mozilla \n and Netscape \n.\nUse \n/\n to get a list of downloadable resource URLs extracted from the page. Use ","result":["提示:","如果需要大量使用代理(如果网络阻塞了某些站点),则可能需要使用","具有","并设置","(巴什)","对于一些网站(例如,优酷),如果您需要访问一些只在中国大陆可用的视频,可以使用特定的代理从网站中提取视频信息:","/",".","使用","/","选项将视频输入到您选择的媒体播放器中,例如","或","而不是下载它:","或者,如果您喜欢在浏览器中观看视频,只需要没有广告或评论部分:","提示:","有可能使用","启动另一下载管理器的选项,例如","虽然他们不能一起玩得很好。","不是所有的视频都可以公开给任何人。如果您需要登录帐户来访问某些内容(例如,私有视频),那么将不可避免地将浏览器cookie提供给","通过","/","选择权。","注:","截至目前,我们支持两种格式的浏览器cookies:Mozilla","Netscape",".","使用","/","获取从页面中提取的可下载资源URL列表。使用"],"_id":"4534464e934e4f409c709b7101473f53"},{"time":1543585823425,"api":"baidu","f":false,"t":"zh-CN","source":" to get an abstract of extracted data in the JSON format.\nWarning:\nFor the time being, this feature has \nNOT\n been stabilized and the JSON schema may have breaking changes in the future.\nSite\nURL\nVideos?\nImages?\nAudios?\nYouTube\n\nTwitter\n\n\nVK\n\n\nVine\n\nVimeo\n\nVidto\n\nVideomega\n\nVeoh\n\nTumblr","result":["以JSON格式获取提取数据的摘要。","警告:","目前,这个特性已经","不是","稳定了,JSON模式在未来可能会有突破性的变化。","现场","统一资源定位地址","视频?","图像?","音频?","YouTube","γ","推特","γ","γ","维生素K","γ","γ","藤","γ","维米欧","γ","维多","γ","电视摄像机","γ","维尔欧","γ","图布雷尔"],"_id":"a5ff7578e6f6418bab629946e31ec3b1"},{"time":1543585824630,"api":"baidu","f":false,"t":"zh-CN","source":"✓\n\n\nTED\n\nSoundCloud\n\nSHOWROOM\n\nPinterest\n\nMusicPlayOn\n\nMTV81\n\nMixcloud\n\nMetacafe\n\nMagisto\n\nKhan Academy\n\nInternet Archive\n\nInstagram\n\n\nInfoQ","result":["γ","γ","γ","特德","γ","声云","γ","陈列室","γ","Pinterest","γ","音乐播放","γ","MTV811","γ","混合云","γ","梅塔卡菲","γ","马吉斯托","γ","汗学院","γ","网络档案","γ","一款图片分享应用","γ","γ","信息输入法"],"_id":"8fa1b9a5d3ca447c814104e2ab2ea3ea"},{"time":1543585826883,"api":"baidu","f":false,"t":"zh-CN","source":"✓\nImgur\n\nHeavy Music Archive\n\nGoogle+\n\n\nFreesound\n\nFlickr\n\n\nFC2 Video\n\nFacebook\n\neHow\n\nDailymotion\n\nCoub\n\nCBS\n\nBandcamp\n\nAliveThai\n✓","result":["γ","Imgur","γ","重音乐档案","γ","谷歌+","γ","γ","自由的","γ","弗里克","γ","γ","FC2视频","γ","脸谱网","γ","埃沃","γ","昼夜运动","γ","库布","γ","哥伦比亚广播公司","γ","音乐营","γ","意大利泰语","γ"],"_id":"0527b8cc44724e3297231c361d473011"},{"time":1543585828622,"api":"baidu","f":false,"t":"zh-CN","source":"interest.me\n\n755\nナナゴーゴー\n\n\nniconico\nニコニコ動画\n\n163\n网易视频\n网易云音乐\n\n\n56网\n\nAcFun\n\nBaidu\n百度贴吧\n\n\n爆米花网\n\nbilibili\n哔哩哔哩\n\nDilidili\n✓","result":["intest.me","小编","755","娜娜丽","小编","小编","niconico","NICONICO动画","小编","163","网易视频","网易云音乐","小编","小编","56网","小编","机动战士","小编","Baidu","百度贴吧","小编","小编","爆米花网","小编","bilavili","慢走","小编","Dilidili","小编"],"_id":"92e885ebe3ef48aca70728fec20f19fa"}]
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册