count interesting posts in an rss feed with the feed reader canto

the rss feed reader canto can be extended quite easily with own python functions. i’ve given the keys z and x a meaning: z opens the story in the browser and increases the number of interesting stories by one, x does not open the story and increases the number of uninteresting stories by one. the results are saved over different sessions so that you can make a statistic evaluation at the end of the year…

~/.canto/conf.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from canto.extra import *
 
link_handler("firefox \"%u\"")
image_handler("eog \"%u\"", text=True, fetch=True)
filters=[show_unread, None]
never_discard("unread")
colors[1] = ("yellow", "black") # unread
colors[2] = ("blue", "black") # read
 
def my_start_hook(gui):
    import os
    import pickle
    try:
        a = open(os.path.dirname(gui.cfg.path)+'/interesting.py', 'r')
        gui.interest = pickle.load(a)
        a.close()
    except:
        gui.interest = {}
 
start_hook = my_start_hook
 
def my_end_hook(gui):
    import os
    import pickle
    a = open(os.path.dirname(gui.cfg.path)+'/interesting.py', 'w')
    pickle.dump(gui.interest, a)
    a.close()
 
end_hook = my_end_hook
 
def interesting(gui):
    journal = gui.sel["tag"].tag.encode('ascii', 'ignore')
    if journal not in gui.interest:
        gui.interest[journal] = {"interesting": 1, "not interesting": 0}
    else:
        gui.interest[journal]["interesting"] += 1
    gui.goto()
    gui.just_read()
    gui.next_item()
 
keys['z'] = interesting
 
def uninteresting(gui):
    journal = gui.sel["tag"].tag.encode('ascii', 'ignore')
    if journal not in gui.interest:
        gui.interest[journal] = {"interesting": 0, "not interesting": 1}
    else:
        gui.interest[journal]["not interesting"] += 1
    gui.just_read()
    gui.next_item()
 
keys['x'] = uninteresting
 
add("http://feeds2.feedburner.com/DilbertDailyStrip?format=xml", tags=["Dilbert Daily Strip"])
add("http://www.arcamax.com/cgi-bin/news/page/1007/channelfeed", tags=["Garfield"])
add("http://www.phdcomics.com/gradfeed_justcomics.php", tags=["PHD Comics"])

Leave a Reply