forked from sch/Slixfeed
Add missing functions for ad-hoc command Browse.
Set 50 seconds delay between each URL.
This commit is contained in:
parent
ae89521d9b
commit
8d9b060314
6 changed files with 96 additions and 11 deletions
|
@ -290,7 +290,6 @@ def manual(filename, section=None, command=None):
|
|||
elif section:
|
||||
try:
|
||||
cmd_list = []
|
||||
breakpoint()
|
||||
for cmd in cmds[section]:
|
||||
cmd_list.extend([cmd])
|
||||
except KeyError as e:
|
||||
|
|
|
@ -10,8 +10,6 @@ FIXME
|
|||
|
||||
TODO
|
||||
|
||||
0) Improve function http to return sensible value (the list is not good enough)
|
||||
|
||||
1) Support Gemini and Gopher.
|
||||
|
||||
2) Check also for HTML, not only feed.bozo.
|
||||
|
|
|
@ -1122,6 +1122,82 @@ def get_number_of_entries_unread(db_file):
|
|||
return count
|
||||
|
||||
|
||||
def get_entries(db_file, num):
|
||||
"""
|
||||
Extract information from entries.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
db_file : str
|
||||
Path to database file.
|
||||
num : str, optional
|
||||
Number. The default is None.
|
||||
|
||||
Returns
|
||||
-------
|
||||
result : tuple
|
||||
News items.
|
||||
"""
|
||||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: db_file: {} num: {}'
|
||||
.format(function_name, db_file, num))
|
||||
with create_connection(db_file) as conn:
|
||||
cur = conn.cursor()
|
||||
sql = (
|
||||
"""
|
||||
SELECT id, title, link, summary, enclosure, feed_id, timestamp
|
||||
FROM entries
|
||||
UNION ALL
|
||||
SELECT id, title, link, summary, enclosure, feed_id, timestamp
|
||||
FROM archive
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT :num
|
||||
"""
|
||||
)
|
||||
par = (num,)
|
||||
result = cur.execute(sql, par).fetchall()
|
||||
return result
|
||||
|
||||
|
||||
def get_entries_rejected(db_file, num):
|
||||
"""
|
||||
Extract information from rejected entries.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
db_file : str
|
||||
Path to database file.
|
||||
num : str, optional
|
||||
Number. The default is None.
|
||||
|
||||
Returns
|
||||
-------
|
||||
result : tuple
|
||||
News items.
|
||||
"""
|
||||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: db_file: {} num: {}'
|
||||
.format(function_name, db_file, num))
|
||||
with create_connection(db_file) as conn:
|
||||
cur = conn.cursor()
|
||||
sql = (
|
||||
"""
|
||||
SELECT id, title, link, summary, enclosure, feed_id, timestamp
|
||||
FROM entries
|
||||
WHERE reject = 1
|
||||
UNION ALL
|
||||
SELECT id, title, link, summary, enclosure, feed_id, timestamp
|
||||
FROM archive
|
||||
WHERE reject = 1
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT :num
|
||||
"""
|
||||
)
|
||||
par = (num,)
|
||||
result = cur.execute(sql, par).fetchall()
|
||||
return result
|
||||
|
||||
|
||||
def get_unread_entries(db_file, num):
|
||||
"""
|
||||
Extract information from unread entries.
|
||||
|
|
|
@ -284,6 +284,7 @@ async def check_updates(self, jid):
|
|||
urls = sqlite.get_active_feeds_url(db_file)
|
||||
for url in urls:
|
||||
await action.scan(self, jid, db_file, url)
|
||||
await asyncio.sleep(50)
|
||||
val = self.settings['default']['check']
|
||||
await asyncio.sleep(60 * float(val))
|
||||
# Schedule to call this function again in 90 minutes
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
__version__ = '0.1.33'
|
||||
__version_info__ = (0, 1, 33)
|
||||
__version__ = '0.1.34'
|
||||
__version_info__ = (0, 1, 34)
|
||||
|
|
|
@ -959,7 +959,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
options.addOption('All news', 'all')
|
||||
# options.addOption('News by subscription', 'feed')
|
||||
# options.addOption('News by tag', 'tag')
|
||||
options.addOption('Rejected news', 'rejected')
|
||||
options.addOption('Rejected news', 'reject')
|
||||
options.addOption('Unread news', 'unread')
|
||||
session['allow_prev'] = False # Cheogram changes style if that button - which should not be on this form - is present
|
||||
session['has_next'] = True
|
||||
|
@ -980,14 +980,20 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
num = 100
|
||||
match payload['values']['action']:
|
||||
case 'all':
|
||||
results = sqlite.get_entries(db_file, num) # FIXME
|
||||
case 'rejected':
|
||||
results = sqlite.get_entries_rejected(db_file, num) # FIXME
|
||||
results = sqlite.get_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates'.format(num)
|
||||
message = 'There are no news'
|
||||
case 'reject':
|
||||
results = sqlite.get_entries_rejected(db_file, num)
|
||||
subtitle = 'Recent {} updates (rejected)'.format(num)
|
||||
message = 'There are no rejected news'
|
||||
case 'unread':
|
||||
results = sqlite.get_unread_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates (unread)'.format(num)
|
||||
message = 'There are no unread news.'
|
||||
if results:
|
||||
form = self['xep_0004'].make_form('form', 'Updates')
|
||||
form['instructions'] = 'Recent {} updates'.format(num)
|
||||
form['instructions'] = subtitle
|
||||
options = form.add_field(var='update',
|
||||
ftype='list-single',
|
||||
label='News',
|
||||
|
@ -1003,8 +1009,13 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
session['payload'] = form
|
||||
session['prev'] = None # Cheogram works as expected with 'allow_prev' set to False Just in case
|
||||
else:
|
||||
text_info = 'There are no unread news.'
|
||||
text_info = message
|
||||
session['allow_prev'] = True
|
||||
session['has_next'] = False
|
||||
session['next'] = None
|
||||
session['notes'] = [['info', text_info]]
|
||||
session['payload'] = None
|
||||
session['prev'] = self._handle_recent
|
||||
return session
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue