From 0eb636572146aa8181d70c0f7ba7e7621f4ae9c2 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 23 Sep 2021 11:25:19 +0200 Subject: [PATCH] new translate script --- resources/scripts/scrapers/translate-feed.py | 20 +++++++++++++++++-- src/librssguard/database/databasequeries.cpp | 2 ++ .../gui/settings/settingsfeedsmessages.ui | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/resources/scripts/scrapers/translate-feed.py b/resources/scripts/scrapers/translate-feed.py index 229aef2b4..433a50249 100644 --- a/resources/scripts/scrapers/translate-feed.py +++ b/resources/scripts/scrapers/translate-feed.py @@ -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")) \ No newline at end of file +out_xml = ET.tostring(rss_document) +out_decoded_xml = out_xml.decode() + +print(out_decoded_xml) \ No newline at end of file diff --git a/src/librssguard/database/databasequeries.cpp b/src/librssguard/database/databasequeries.cpp index fef999a6e..34da56890 100644 --- a/src/librssguard/database/databasequeries.cpp +++ b/src/librssguard/database/databasequeries.cpp @@ -1289,6 +1289,8 @@ QPair 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)); diff --git a/src/librssguard/gui/settings/settingsfeedsmessages.ui b/src/librssguard/gui/settings/settingsfeedsmessages.ui index 3160b80b1..65d8d80f6 100644 --- a/src/librssguard/gui/settings/settingsfeedsmessages.ui +++ b/src/librssguard/gui/settings/settingsfeedsmessages.ui @@ -14,7 +14,7 @@ - 0 + 1