Skip to content
Browse files

Fixes problem after google changed things

  • Loading branch information...
1 parent d831030 commit a7ae915d0cce69d09883c5e732772a6a768a467d Jessica T committed Jan 26, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 Plugins/translate.py
View
5 Plugins/translate.py
@@ -30,11 +30,12 @@ def main(connection, line):
else:
langpair = ("auto", line.split()[4])
try:
- google = urllib2.Request("http://translate.google.com/?text=%s&sl=%s&tl=%s" % ("+".join(line.split()[5:]), langpair[0], langpair[1]))
+ # Bug detection faulty
+ google = urllib2.Request("http://translate.google.com/translate_t?q=%s&sl=%s&tl=%s" % ("+".join(line.split()[5:]), langpair[0], langpair[1]))
google.add_header("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3")
google = urllib2.urlopen(google)
source = google.read()
- langtran = re.findall("<h3 id=headingtext class=\"\">(.+?) to (.+?) translation</h3>", source)[0]
+ langtran = (re.findall("-menu-button-caption\">To: (.+?)</div><div class=\"goog-", source)[0], re.findall("lat-menu-button-caption\">From: (.+?)</div><div class=\"goog-inlin", source)[0])[::-1]
result = re.findall("onmouseout=\"this.style.backgroundColor='#fff'\">(.+?)</span></span></div></div><di", source)[0]
connection.core["privmsg"].main(connection, line.split()[2], "%s: \002[%s to %s]\017 %s" % (line.split()[0][1:].split("!")[0], langtran[0], langtran[1], result))
except:

0 comments on commit a7ae915

Please sign in to comment.
Something went wrong with that request. Please try again.