new translate script
This commit is contained in:
parent
bedfd71752
commit
0eb6365721
3 changed files with 21 additions and 3 deletions
|
|
@ -13,12 +13,14 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import html
|
import html
|
||||||
import requests
|
import requests
|
||||||
import distutils.util
|
import distutils.util
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
import itertools as IT
|
||||||
from googletrans import Translator
|
from googletrans import Translator
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
@ -37,7 +39,18 @@ if parallel:
|
||||||
|
|
||||||
sys.stdin.reconfigure(encoding = src_enc)
|
sys.stdin.reconfigure(encoding = src_enc)
|
||||||
rss_data = sys.stdin.read()
|
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()
|
translator = Translator()
|
||||||
|
|
||||||
atom_ns = {"ns": "http://www.w3.org/2005/Atom"}
|
atom_ns = {"ns": "http://www.w3.org/2005/Atom"}
|
||||||
|
|
@ -109,4 +122,7 @@ else:
|
||||||
for article in rss_document.findall(".//ns:entry", atom_ns):
|
for article in rss_document.findall(".//ns:entry", atom_ns):
|
||||||
process_article(article)
|
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)
|
||||||
|
|
@ -1289,6 +1289,8 @@ QPair<int, int> DatabaseQueries::updateMessages(QSqlDatabase db,
|
||||||
(!ignore_contents_changes && message.m_contents != contents_existing_message);
|
(!ignore_contents_changes && message.m_contents != contents_existing_message);
|
||||||
|
|
||||||
if (cond_1 || cond_2 || cond_3 || force_update) {
|
if (cond_1 || cond_2 || cond_3 || force_update) {
|
||||||
|
auto aa = message.m_created.toMSecsSinceEpoch();
|
||||||
|
|
||||||
// Message exists and is changed, update it.
|
// Message exists and is changed, update it.
|
||||||
query_update.bindValue(QSL(":title"), unnulifyString(message.m_title));
|
query_update.bindValue(QSL(":title"), unnulifyString(message.m_title));
|
||||||
query_update.bindValue(QSL(":is_read"), int(message.m_isRead));
|
query_update.bindValue(QSL(":is_read"), int(message.m_isRead));
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="m_tabFeedsMessages">
|
<widget class="QTabWidget" name="m_tabFeedsMessages">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="m_tabFeeds">
|
<widget class="QWidget" name="m_tabFeeds">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue