script translates title too
This commit is contained in:
parent
6f9fbc8d81
commit
19ba70fd4f
resources/scripts/scrapers
src/librssguard
@ -51,6 +51,11 @@ def process_article(article):
|
||||
contents = article.find("description")
|
||||
contents.text = translate_string(" ".join(contents.itertext()))
|
||||
|
||||
# Translate title.
|
||||
title = rss_document.find(".//channel").find("title")
|
||||
title.text = translate_string(title.text)
|
||||
|
||||
# Translate articles.
|
||||
if parallel:
|
||||
with ThreadPoolExecutor(max_workers = 2) as executor:
|
||||
futures = []
|
||||
|
@ -282,6 +282,17 @@ bool DatabaseQueries::markImportantMessagesReadUnread(const QSqlDatabase& db, in
|
||||
return q.exec();
|
||||
}
|
||||
|
||||
bool DatabaseQueries::markUnreadMessagesRead(const QSqlDatabase& db, int account_id) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
q.setForwardOnly(true);
|
||||
q.prepare("UPDATE Messages SET is_read = :read "
|
||||
"WHERE is_read = 0 AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;");
|
||||
q.bindValue(QSL(":read"), 1);
|
||||
q.bindValue(QSL(":account_id"), account_id);
|
||||
return q.exec();
|
||||
}
|
||||
|
||||
bool DatabaseQueries::markMessagesReadUnread(const QSqlDatabase& db, const QStringList& ids, RootItem::ReadStatus read) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
@ -1444,6 +1455,28 @@ bool DatabaseQueries::cleanImportantMessages(const QSqlDatabase& db, bool clean_
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseQueries::cleanUnreadMessages(const QSqlDatabase& db, int account_id) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
q.setForwardOnly(true);
|
||||
q.prepare(QSL("UPDATE Messages SET is_deleted = :deleted "
|
||||
"WHERE is_deleted = 0 AND is_pdeleted = 0 AND is_read = 0 AND account_id = :account_id;"));
|
||||
|
||||
q.bindValue(QSL(":deleted"), 1);
|
||||
q.bindValue(QSL(":account_id"), account_id);
|
||||
|
||||
if (!q.exec()) {
|
||||
qWarningNN << LOGSEC_DB
|
||||
<< "Cleaning of unread messages failed: '"
|
||||
<< q.lastError().text()
|
||||
<< "'.";
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseQueries::cleanFeeds(const QSqlDatabase& db, const QStringList& ids, bool clean_read_only, int account_id) {
|
||||
QSqlQuery q(db);
|
||||
|
||||
|
@ -42,6 +42,7 @@ class DatabaseQueries {
|
||||
// Message operators.
|
||||
static bool markLabelledMessagesReadUnread(const QSqlDatabase& db, Label* label, RootItem::ReadStatus read);
|
||||
static bool markImportantMessagesReadUnread(const QSqlDatabase& db, int account_id, RootItem::ReadStatus read);
|
||||
static bool markUnreadMessagesRead(const QSqlDatabase& db, int account_id);
|
||||
static bool markMessagesReadUnread(const QSqlDatabase& db, const QStringList& ids, RootItem::ReadStatus read);
|
||||
static bool markMessageImportant(const QSqlDatabase& db, int id, RootItem::Importance importance);
|
||||
static bool markFeedsReadUnread(const QSqlDatabase& db, const QStringList& ids, int account_id, RootItem::ReadStatus read);
|
||||
@ -114,6 +115,7 @@ class DatabaseQueries {
|
||||
static bool deleteAccountData(const QSqlDatabase& db, int account_id, bool delete_messages_too);
|
||||
static bool cleanLabelledMessages(const QSqlDatabase& db, bool clean_read_only, Label* label);
|
||||
static bool cleanImportantMessages(const QSqlDatabase& db, bool clean_read_only, int account_id);
|
||||
static bool cleanUnreadMessages(const QSqlDatabase& db, int account_id);
|
||||
static bool cleanFeeds(const QSqlDatabase& db, const QStringList& ids, bool clean_read_only, int account_id);
|
||||
static bool storeAccountTree(const QSqlDatabase& db, RootItem* tree_root, int account_id);
|
||||
static void createOverwriteFeed(const QSqlDatabase& db, Feed* feed, int account_id, int parent_id);
|
||||
|
@ -35,10 +35,14 @@ void UnreadNode::updateCounts(bool including_total_count) {
|
||||
}
|
||||
|
||||
bool UnreadNode::cleanMessages(bool clean_read_only) {
|
||||
if (clean_read_only) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ServiceRoot* service = getParentServiceRoot();
|
||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||
|
||||
if (DatabaseQueries::cleanImportantMessages(database, clean_read_only, service->accountId())) {
|
||||
if (DatabaseQueries::cleanUnreadMessages(database, service->accountId())) {
|
||||
service->updateCounts(true);
|
||||
service->itemChanged(service->getSubTree());
|
||||
service->requestReloadMessageList(true);
|
||||
@ -50,6 +54,11 @@ bool UnreadNode::cleanMessages(bool clean_read_only) {
|
||||
}
|
||||
|
||||
bool UnreadNode::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
if (status == RootItem::ReadStatus::Unread) {
|
||||
// NOTE: We do not need to mark already unread messages as unread.
|
||||
return true;
|
||||
}
|
||||
|
||||
ServiceRoot* service = getParentServiceRoot();
|
||||
auto* cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
|
||||
@ -59,7 +68,7 @@ bool UnreadNode::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
|
||||
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
|
||||
|
||||
if (DatabaseQueries::markImportantMessagesReadUnread(database, service->accountId(), status)) {
|
||||
if (DatabaseQueries::markUnreadMessagesRead(database, service->accountId())) {
|
||||
service->updateCounts(false);
|
||||
service->itemChanged(service->getSubTree());
|
||||
service->requestReloadMessageList(status == RootItem::ReadStatus::Read);
|
||||
|
Loading…
x
Reference in New Issue
Block a user