new translate script

This commit is contained in:
Martin Rotter 2021-09-23 11:25:19 +02:00
parent bedfd71752
commit 0eb6365721
3 changed files with 21 additions and 3 deletions

View File

@ -13,12 +13,14 @@
import json
import re
import io
import sys
import time
import html
import requests
import distutils.util
import xml.etree.ElementTree as ET
import itertools as IT
from googletrans import Translator
from bs4 import BeautifulSoup
@ -37,7 +39,18 @@ if parallel:
sys.stdin.reconfigure(encoding = src_enc)
rss_data = sys.stdin.read()
rss_document = ET.fromstring(rss_data)
#print(rss_data)
try:
rss_document = ET.fromstring(rss_data)
except ET.ParseError as err:
lineno, column = err.position
line = next(IT.islice(io.StringIO(rss_data), lineno))
caret = '{:=>{}}'.format('^', column)
err.msg = '{}\n{}\n{}'.format(err, line, caret)
raise
translator = Translator()
atom_ns = {"ns": "http://www.w3.org/2005/Atom"}
@ -109,4 +122,7 @@ else:
for article in rss_document.findall(".//ns:entry", atom_ns):
process_article(article)
print(ET.tostring(rss_document, encoding = "unicode"))
out_xml = ET.tostring(rss_document)
out_decoded_xml = out_xml.decode()
print(out_decoded_xml)

View File

@ -1289,6 +1289,8 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
(!ignore_contents_changes && message.m_contents != contents_existing_message);
if (cond_1 || cond_2 || cond_3 || force_update) {
auto aa = message.m_created.toMSecsSinceEpoch();
// Message exists and is changed, update it.
query_update.bindValue(QSL(":title"), unnulifyString(message.m_title));
query_update.bindValue(QSL(":is_read"), int(message.m_isRead));

View File

@ -14,7 +14,7 @@
<item>
<widget class="QTabWidget" name="m_tabFeedsMessages">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="m_tabFeeds">
<attribute name="title">