瀏覽代碼

Rename script to something less weird

Make sure fortunes are short and simple enough for Kodi
master
The Dod 4 年之前
父節點
當前提交
9bba092b9f
共有 3 個檔案被更改,包括 6 行新增27 行删除
  1. 1
    23
      fortune.rss
  2. 4
    3
      fortunefeed.py
  3. 1
    1
      makefortune.sh

+ 1
- 23
fortune.rss 查看文件

@@ -1,23 +1 @@
1
-<rss version="2.0"><channel><title>Fortune</title><link>https://linux.die.net/man/6/fortune</link><description>Random, hopefully interesting, adages</description><item><title>You will stop at nothing to reach your objective, but only because your
2
-brakes are defective.
3
-</title></item><item><title>Let us endeavor so to live that when we come to die even the undertaker will be
4
-sorry.
5
-		-- Mark Twain, "Pudd'nhead Wilson's Calendar"
6
-</title></item><item><title>The lunatic, the lover, and the poet,
7
-Are of imagination all compact...
8
-		-- Wm. Shakespeare, "A Midsummer Night's Dream"
9
-</title></item><item><title>Hain't we got all the fools in town on our side?  And hain't that a big
10
-enough majority in any town?
11
-		-- Mark Twain, "Huckleberry Finn"
12
-</title></item><item><title>You'll be sorry...
13
-</title></item><item><title>Having nothing, nothing can he lose.
14
-		-- William Shakespeare, "Henry VI"
15
-</title></item><item><title>Beware of Bigfoot!
16
-</title></item><item><title>Writing is turning one's worst moments into money.
17
-		-- J.P. Donleavy
18
-</title></item><item><title>Q:	Why is Christmas just like a day at the office?
19
-A:	You do all of the work and the fat guy in the suit
20
-	gets all the credit.
21
-</title></item><item><title>Q:	How many WASPs does it take to change a light bulb?
22
-A:	One.
23
-</title></item></channel></rss>
1
+<rss version="2.0"><channel><title>Fortune</title><link>https://linux.die.net/man/6/fortune</link><description>Random, hopefully interesting, adages</description><item><title>You're at the end of the road again.</title></item><item><title>Courage is your greatest present need.</title></item><item><title>Don't Worry, Be Happy.   -- Meher Baba</title></item></channel></rss>

fortune.rss.py → fortunefeed.py 查看文件

@@ -6,13 +6,14 @@ import xml.etree.ElementTree
6 6
 FEED_LINK = 'https://linux.die.net/man/6/fortune'
7 7
 FEED_TITLE = 'Fortune'
8 8
 FEED_DESCRIPTION = 'Random, hopefully interesting, adages'
9
-NUM_ITEMS = 10
9
+NUM_ITEMS = 3
10
+MAX_LENGTH = 42
10 11
 
11 12
 rss_items = []
12 13
 
13 14
 for i in range(NUM_ITEMS):
14
-    with Popen(['fortune', '-s'], encoding='utf-8', stdout=PIPE) as fortune:
15
-        rss_items.append(gen_item(title=fortune.stdout.read()))
15
+    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',' ')))
16 17
 
17 18
 rss_xml_element = start_rss(
18 19
     title=FEED_TITLE, link=FEED_LINK,

+ 1
- 1
makefortune.sh 查看文件

@@ -1,4 +1,4 @@
1 1
 #!/bin/sh
2 2
 cd "$(dirname "$0")"
3 3
 . venv/bin/activate
4
-python fortune.rss.py > fortune.rss
4
+python fortunefeed.py > fortune.rss

Loading…
取消
儲存