From 71403cda6b5331ea074310630cfa80fd5995726e Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Sat, 6 Apr 2024 19:59:30 +0000 Subject: [PATCH] Fix media (i.e. enclosure) support (Thank you roughnecks). --- slixfeed/action.py | 2 ++ slixfeed/sqlite.py | 18 ++++++++++++++++++ slixfeed/version.py | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/slixfeed/action.py b/slixfeed/action.py index 295139b..8717285 100644 --- a/slixfeed/action.py +++ b/slixfeed/action.py @@ -310,6 +310,8 @@ async def xmpp_send_message(self, jid, num=None): summary = result[3] feed_id = result[4] date = result[5] + enclosure = sqlite.get_enclosure_by_entry_id(db_file, ix) + if enclosure: enclosure = enclosure[0] title_f = sqlite.get_feed_title(db_file, feed_id) title_f = title_f[0] news_digest += await list_unread_entries(self, result, title_f, jid) diff --git a/slixfeed/sqlite.py b/slixfeed/sqlite.py index 54206e5..d894fbc 100644 --- a/slixfeed/sqlite.py +++ b/slixfeed/sqlite.py @@ -1406,6 +1406,24 @@ def get_entries_rejected(db_file, num): return result +def get_enclosure_by_entry_id(db_file, ix): + function_name = sys._getframe().f_code.co_name + logger.debug('{}: db_file: {} ix: {}' + .format(function_name, db_file, ix)) + with create_connection(db_file) as conn: + cur = conn.cursor() + sql = ( + """ + SELECT url + FROM entries_properties_links + WHERE entry_id = :ix AND rel = "enclosure" + """ + ) + par = (ix,) + result = cur.execute(sql, par).fetchone() + return result + + def get_unread_entries(db_file, num): """ Extract information from unread entries. diff --git a/slixfeed/version.py b/slixfeed/version.py index 1c7cbfa..ee1b429 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.54' -__version_info__ = (0, 1, 54) +__version__ = '0.1.55' +__version_info__ = (0, 1, 55)