Add :first to NOT sort items by date

master
pictuga 2020-07-06 11:39:08 +02:00
parent c1b1f5f58a
commit 15951d228c
3 changed files with 16 additions and 3 deletions

View File

@ -91,6 +91,7 @@ The arguments are:
- `debug`: to have some feedback from the script execution. Useful for debugging
- `force`: force refetch the rss feed and articles
- `silent`: don't output the final RSS (useless on its own, but can be nice when debugging)
- `first`: return the feed items in the order they initially appear in the feed (morss ohterwise shows the newest items first)
- http server only
- `callback=NAME`: for JSONP calls
- `cors`: allow Cross-origin resource sharing (allows XHR calls from other servers)

View File

@ -343,8 +343,15 @@ def FeedGather(rss, url, options):
if options.cache:
max_time = 0
now = datetime.now(tz.tzutc())
sorted_items = sorted(rss.items, key=lambda x:x.updated or x.time or now, reverse=True)
if options.first:
# :first to just take the first items in the feed (in sequence)
sorted_items = rss.items
else:
# otherwise, take the _newest_, i.e. sort by time
now = datetime.now(tz.tzutc())
sorted_items = sorted(rss.items, key=lambda x:x.updated or x.time or now, reverse=True)
for i, item in enumerate(sorted_items):
if time.time() - start_time > lim_time >= 0 or i + 1 > lim_item >= 0:
log('dropped')

View File

@ -190,7 +190,12 @@
<option value="">standard</option>
<option value=":firstlink" title="Pull the article from the first available link in the description, instead of the standard link. Useful for Twitter feeds for example, to get the articles referred to in tweets rather than the tweet itself">first (?)</option>
</select>
link and
link of the
<select>
<option value="">newest</option>
<option value=":first" title="Return the feed items in the order they appear in the feed (morss ohterwise shows the newest items first)">first (?)</option>
</select>
items and
<select>
<option value="">keep</option>
<option value=":nolink:noref">remove</option>