Handle URLs before translation

This commit is contained in:
Klaus-Uwe Mitterer 2017-03-13 23:36:04 +01:00
parent 94bedf0488
commit 3b8dc335a9

View file

@ -45,7 +45,14 @@ for status in timeline:
for a in accounts: for a in accounts:
two = twitools.twObject(ato=a[1], ase=a[2]) two = twitools.twObject(ato=a[1], ase=a[2])
intext = re.sub(r'https?:\/\/[\S]*', '', text) split = text.split()
intext = ""
for s in split:
if re.match(r'https?:\/\/[\S]*', s):
out = " ".join([out, httptools.shortURL(s)])
else:
out = " ".join([out, s])
tstring = translator.translate(intext, target_language=a[0])['translatedText'].replace("@", "@") tstring = translator.translate(intext, target_language=a[0])['translatedText'].replace("@", "@")
try: try: