|
@@ -1,5 +1,6 @@
|
1
|
1
|
import sys
|
2
|
2
|
from subprocess import Popen, PIPE
|
|
3
|
+from datetime import datetime, timedelta
|
3
|
4
|
from min_rss_gen.generator import start_rss, gen_item
|
4
|
5
|
import xml.etree.ElementTree
|
5
|
6
|
|
|
@@ -7,13 +8,16 @@ FEED_LINK = 'https://linux.die.net/man/6/fortune'
|
7
|
8
|
FEED_TITLE = 'Fortune'
|
8
|
9
|
FEED_DESCRIPTION = 'Random, hopefully interesting, adages'
|
9
|
10
|
NUM_ITEMS = 3
|
10
|
|
-MAX_LENGTH = 42
|
|
11
|
+MAX_LENGTH = 69
|
11
|
12
|
|
12
|
13
|
rss_items = []
|
13
|
14
|
|
14
|
15
|
for i in range(NUM_ITEMS):
|
15
|
16
|
with Popen(['fortune', '-s', '-n', str(MAX_LENGTH)], encoding='utf-8', stdout=PIPE) as fortune:
|
16
|
|
- rss_items.append(gen_item(title=fortune.stdout.read().strip().replace('\n',' ').replace('\t',' ')))
|
|
17
|
+ rss_items.append(gen_item(
|
|
18
|
+ title=fortune.stdout.read().strip().replace('\n',' ').replace('\t',' '),
|
|
19
|
+ link=FEED_LINK,
|
|
20
|
+ pubDate=(datetime.now()-timedelta(minutes=i)).isoformat()))
|
17
|
21
|
|
18
|
22
|
rss_xml_element = start_rss(
|
19
|
23
|
title=FEED_TITLE, link=FEED_LINK,
|