bookfere / Ebook-Translator-Calibre-Plugin

A Calibre plugin to translate ebook into a specified language.
https://translator.bookfere.com
GNU General Public License v3.0
1.72k stars 114 forks source link

自定义翻译引擎,使用第三方chatgpt api,总是会出现很多错误提示:urllib.error.URLError: <urlopen error The read operation timed out> #135

Closed GoTop closed 1 year ago

GoTop commented 1 year ago

如果设置“合并翻译”,不管数量设置成多少,几乎都无法翻译成功。所以只能取消“合并翻译”

会出现很多urllib.error.URLError: 的错误,然后经过一天的翻译,现在还剩1200多条,不管这么重新翻译多少次,都提示无法翻译了 我用python代码测试了第三方的chatgpt的apikey,还是可以正常使用的。

自定义设置:

{
    "name": "OpenKEY ChatGPT",
    "languages": {
        "source": {
            "English": "English"
        },
        "target": {
            "中文": "Chinese"
        }
    },
    "request": {
        "url": "https://openkey.cloud/v1/chat/completions",
        "method": "POST",
        "headers": {
            "User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)",
            "Content-Type": "application/json",
            "Authorization": "Bearer sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
        },
        "data": {
            "model": "gpt-3.5-turbo-0613",
            "temperature": 0.8,
            "messages": [{"role":"system","content": "You are a professional  translator proficient in 简体中文, with a writing style of short, concise, easy-to-understand sentences.you will Translate the input sentences in 简体中文 , consider the context and aim for a translation that is idiomatic, concise, and easy to understand, rather than a direct word-for-word translation."
},
{
                "role": "user",
                "content": "Translate the content to <target>: <text>"
            }]
        }
    },
    "response": "response['choices'][0]['message']['content']"
}

错误信息:

==============================
Original: His addiction started with horse racing but eventually progressed to card games. Blackjack. Baccarat. Pai Gow. You name it, he had played it. I had never heard of some of these games, but my grandfather knew them well. And he bet like it too. $25 a hand. $50 a hand. Sometimes $75 a hand. Sizeable sums of money to throw away on gambling at cards.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: The book is divided into two sections—saving and investing. Saving will cover all the aspects of saving money including: how much to save, how to save more, how to spend money guilt-free, and so forth. Investing will cover the many facets of putting your money to work including: why you should invest, what you should invest in, how often you should invest, and much more.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: “Nick Maggiulli clearly delights in flouting the received wisdom about how people should manage their money. The end result is a book that’s full of both aha moments and practical takeaways. As a fellow writer about personal finance, I felt a creeping sense of jealousy in what I was reading. Nick takes the tired topics of how to save and invest well and managed to make them utterly fresh and even quite a bit of fun.”
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: “Nick has a genuine gift—while he uses rigorous empirical evidence to make his case, he manages to tell the story in such a way to keep the reader’s attention and give them practical, actionable advice. He also has just enough of a mischievous streak to challenge some long-held assumptions about investing, but in a manner that makes the empirical data a fresh, interesting story. Investors, new and old, will benefit from Nick’s practical approach to investing.”
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: My late grandfather was addicted to gambling on horse races. When I was a kid we used to go to the Los Angeles County Fair and watch thoroughbreds with names like Magnificent Marks and Jail Break gallop around the track. What I saw then as a form of mild entertainment I later learned was a lifelong struggle for my grandfather.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
bookfere commented 1 year ago

从你提供的错误信息看只是单纯的网络连接问题。你之前在 Issue #133 曾提到过设置了 HTTP 代理,你用 Python 脚本测试的时候也用代理了吗?如果你用的第三方服务不需要代理的话,可以关掉代理再试试看。

GoTop commented 1 year ago

从你提供的错误信息看只是单纯的网络连接问题。你之前在 Issue #133 曾提到过设置了 HTTP 代理,你用 Python 脚本测试的时候也用代理了吗?如果你用的第三方服务不需要代理的话,可以关掉代理再试试看。

感谢您的分析,我似乎找到点原因了

我在Ebook-Translator-Calibre插件中没有启用代理 屏幕截图 2023-09-24 222326

但是电脑上V2rayN开启“自动配置系统代理”,所以Calibre会使用设置的系统代理,不知道这个有没有影响? 现在我已经把V2rayN设置为“清除系统代理”了,Calibre里也显示没有使用代理: 屏幕截图 2023-09-24 222800

再次运行Ebook-Translator-Calibre插件,Log里开始显示成功翻译了,不过Errors里还是显示很多无法连接的错误。

Log:

==============================
Start to translate ebook content
==============================
Total items: 1065
Character count: 220603
==============================
Original: Counter-intuitively, the lower your current savings rate, the more your lifestyle can creep without affecting your current retirement plan. Why? Because those people who save less, by definition, spend more (for the same level of income).
-----------------------------------
Translation: 直观而言,当前储蓄率越低,你的生活方式就越容易扩大,而不会影响你目前的退休计划。为什么呢?因为那些储蓄较少的人在同等收入水平下会更多地消费。
==============================
Original: 77 SPIVA, spglobal.com (June 30, 2020).
-----------------------------------
Translation: 77 SPIVA, spglobal.com (2020年6月30日)。
==============================
Original: 79 West, Geoffrey B., Scale: The Universal Laws of Life, Growth, and Death in Organisms, Cities, and Companies (Harmondsworth: Penguin, 2017).
-----------------------------------
Translation: 79 West, Geoffrey B.所著《规模:有关生物、城市和公司的普遍生命、增长和衰亡定律》(Harmondsworth: Penguin, 2017)。
==============================
Original: 13. How Soon Should You Invest?
-----------------------------------
Translation: 13. 你应该多快投资?
==============================
Original: 81 “The Truth About Top-Performing Money Managers,” Baird Asset Management, White Paper (2014).
-----------------------------------
Translation: 81 《顶级资金管理者的真相》,贝尔德资产管理,白皮书(2014年)。
==============================
Original: 78 Bessembinder, Hendrik, “Do Stocks Outperform Treasury Bills?” Journal of Financial Economics 129:3 (2018), 440–457.
-----------------------------------
Translation: 78 Bessembinder, Hendrik, “Do Stocks Outperform Treasury Bills?” Journal of Financial Economics 129:3 (2018), 440–457.

78 Bessembinder, Hendrik, “股票是否胜过国债?” 《金融经济学杂志》129:3 (2018), 440–457.
==============================
Original: 82 Powell, R., “Bernstein: Free Trading is Like Giving Chainsaws to Toddlers,” The Evidence-Based Investor (March 25, 2021).
-----------------------------------
Translation: 82 Powell, R., “伯恩斯坦:自由交易就像把电锯给婴儿一样”,《基于证据的投资者》(2021年3月25日)。
==============================
Original: Before american pharoah won the Triple Crown in 2015, no one expected much from the horse. But Jeff Seder felt differently.
-----------------------------------
Translation: 在2015年美洲马赛驹赢得三冠之前,没有人对这匹马有太多期望。但是杰夫·席德尔有不同的看法。
==============================
Original: And why earlier is better than later
-----------------------------------
Translation: 为什么早些比晚些更好
==============================
Original: And it was data that he collected. For years Seder measured everything on horses. Nostril size. Excrement weight. Fast-twitch muscle fiber density. And for years he came up empty-handed.
-----------------------------------
Translation: 而那些数据是他收集的。多年来,赛德尔测量了马匹的一切。鼻孔大小。粪便重量。快肌纤维密度。多年来,他一无所获。
==============================
Original: Then, Seder got the idea to measure the size of a horse’s internal organs using a portable ultrasound. Bingo. He hit pay dirt.
-----------------------------------
Translation: 然后,塞德尔想到了使用便携式超声波仪来测量马的内脏器官的大小。正中下怀。他终于找到了宝藏。
==============================
Original: “He found that the size of the heart, and particularly the size of the left ventricle, was a massive predictor of a horse’s success, the single most important variable.”83
-----------------------------------
Translation: 他发现心脏的大小,特别是左心室的大小,是马匹成功的巨大预测因素,也是最重要的变量。
==============================
Original: Seth Stephens-Davidowitz tells of Seder’s discovery in Everybody Lies:
-----------------------------------
Translation: 塞斯·斯蒂芬斯-达维多维茨在《每个人都撒谎》中讲述了塞德尔的发现。
==============================
Original: 80 Kosowski, Robert, Allan Timmermann, Russ Wermers, and Hal White, “Can Mutual Fund ‘Stars’ Really Pick Stocks? New Evidence from a Bootstrap Analysis,” The Journal of Finance 61:6 (2006), 2551–2595.
-----------------------------------
Translation: 80 Kosowski,Robert,Allan Timmermann,Russ Wermers和Hal White,“基金明星真能挑选股票吗?基于Bootstrap分析的新证据”,《金融学杂志》61:6(2006年),2551-2595。
==============================
Original: Seder’s story highlights how deep insight can be gleaned from one useful data point. Hans Rosling echoes this sentiment in Factfulness when he discusses the importance of child mortality in understanding a country’s development:
-----------------------------------
Translation: Seder的故事突出了从一个有用的数据点中可以获得的深入洞察。Hans Rosling在《事实性》中也呼应了这一观点,当他讨论儿童死亡率对理解一个国家的发展的重要性时:
==============================
Original: Rosling’s use of childhood mortality and Seder’s use of heart size exemplify how complex systems can be more easily understood with a single piece of accurate information.
-----------------------------------
Translation: 罗斯林运用儿童死亡率,塞德运用心脏大小,展示了单一准确信息如何更容易理解复杂系统。
==============================
Original: When it comes to how soon you should invest your money, there is also one piece of information that can guide all of your future decisions.
-----------------------------------
Translation: 说到你何时应该投资你的钱,还有一条信息可以指导你未来的所有决策。

Errors:

==============================
Original: This is true even though a sizeable chunk of his investments would have been made during one of the worst decades in U.S. stock market history (2000–2009). That wouldn’t have mattered. By continually investing his money month after month, my grandfather could have counteracted his worst financial habits and built wealth. And though you probably don’t have a severe gambling addiction, by following this philosophy, you can build wealth as well.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: My late grandfather was addicted to gambling on horse races. When I was a kid we used to go to the Los Angeles County Fair and watch thoroughbreds with names like Magnificent Marks and Jail Break gallop around the track. What I saw then as a form of mild entertainment I later learned was a lifelong struggle for my grandfather.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: You have to understand that my grandfather was retired and living with his mother (my great-grandmother) at the time. She paid for his food and housing. When he initially retired at age 55, he started getting $1,000 a month from his pension. Seven years later, he began receiving Social Security for an additional $1,200 a month.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: The book is divided into two sections—saving and investing. Saving will cover all the aspects of saving money including: how much to save, how to save more, how to spend money guilt-free, and so forth. Investing will cover the many facets of putting your money to work including: why you should invest, what you should invest in, how often you should invest, and much more.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: His addiction started with horse racing but eventually progressed to card games. Blackjack. Baccarat. Pai Gow. You name it, he had played it. I had never heard of some of these games, but my grandfather knew them well. And he bet like it too. $25 a hand. $50 a hand. Sometimes $75 a hand. Sizeable sums of money to throw away on gambling at cards.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: The answer has to do with rainfall or, rather, the lack of rainfall. Since desert annuals require sufficiently wet conditions in order to sprout and grow, rainfall is what determines their survival. However, in an environment as unpredictable as the desert, dry spells sometimes occur.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error _ssl.c:980: The handshake operation timed out>
==============================
Original: However, what you may not know is how credit cards can help reduce risk for some low-income borrowers. This is most easily demonstrated by what researchers have called the credit card debt puzzle. The credit card debt puzzle is the observation that some people hold credit card debt despite having the ability to pay it off from savings.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: For example, imagine someone with $1,500 in their checking account who also has $1,000 in credit card debt. They could easily pay off that $1,000 debt and still have $500 in their checking account, but they don’t. Their decision to hold onto their debt might seem irrational, but after taking a closer look, it’s just a form of bet hedging.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: Of course, the devil is in the details. If the difference between your expected rate of return and your cost to borrow is too small, then taking out debt could be a risky move. However, when the expected return is large, debt can change your life. One area where this is typically true is in higher education.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: Debt can also be used to decrease uncertainty when locking in a payment stream into the future. For example, if you want to live in a particular area, taking out a mortgage can fix your cost of living for the next few decades. Because of that debt, you no longer have to worry about changing rents or housing security since your future payments are known and unchanging.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: I know I won’t convince every stock picker to change their ways, and that’s a good thing. We need people to keep analyzing companies and deploying their capital accordingly. However, if you are on the fence about it, this is your wake-up call. Don’t keep playing a game with so much luck involved. Life already has enough luck as it is.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: After considering the possible emotional, financial, and existential costs of buying individual stocks, you can see why I prefer investing in index funds and ETFs. The simplicity of indexing allows me to focus my attention on the things in life that are far more important than my portfolio.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: Seder had worked as an analyst at Citigroup before quitting and following his passion to predict the outcome of horse races. Seder wasn’t like other equine researchers because he didn’t care about the thing that other horse breeders obsessed over—pedigree.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: The traditional view among horse breeders was that a horse’s mother, father, and general lineage were the primary determinant of its racing success. However, after looking through historical records, Seder realized pedigree wasn’t a great predictor. Seder needed to find another predictor and to do that he needed data.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
==============================
Original: “Do you know I’m obsessed with the number for the child mortality rate?… Because children are very fragile. There are so many things that can kill them. When only 14 children die out of 1,000 in Malaysia, this means that the other 986 survive. Their parents and their society manage to protect them from all the dangers that could have killed them: germs, starvation, violence and so on.
-----------------------------------
Error: Failed to retrieve data from translate engine API.
Can not parse returned response. Raw data: 
Traceback (most recent call last):
  File "calibre_plugins.ebook_translator.engines.base", line 171, in get_result
  File "mechanize\_mechanize.py", line 257, in open
  File "mechanize\_mechanize.py", line 287, in _mech_open
  File "mechanize\_opener.py", line 193, in open
  File "mechanize\_urllib2_fork.py", line 425, in _open
  File "mechanize\_urllib2_fork.py", line 414, in _call_chain
  File "mechanize\_urllib2_fork.py", line 1283, in https_open
  File "mechanize\_urllib2_fork.py", line 1240, in do_open
urllib.error.URLError: <urlopen error The read operation timed out>
GoTop commented 1 year ago

我测试出问题在哪了。

我将超时时间设置得太短了,只有5s,所以在翻译较长文本时,会提示timed out

而且设置“合并段落“之后,发送的文本量变大,需要调整超时时间为10s设置更久

同时可以将线程设置为0,这样速度会快很多

bookfere commented 1 year ago

谢谢分享经验。如果所用服务的可用性没大问题,超时时间可以设置长一些。