Mercurial > pidgin.yaz
annotate finch/libgnt/pygnt/example/rss/gntrss.py @ 22217:ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
| author | Sadrul Habib Chowdhury <imadil@gmail.com> |
|---|---|
| date | Sat, 26 Jan 2008 22:33:08 +0000 |
| parents | 80bfc233c9f2 |
| children | 6829aa32b16c |
| rev | line source |
|---|---|
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 |
|
18715
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
3 """ |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
4 gr - An RSS-reader built using libgnt and feedparser. |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
5 |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
6 Copyright (C) 2007 Sadrul Habib Chowdhury <sadrul@pidgin.im> |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
7 |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
8 This application is free software; you can redistribute it and/or |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
9 modify it under the terms of the GNU Lesser General Public |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
10 License as published by the Free Software Foundation; either |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
11 version 2.1 of the License, or (at your option) any later version. |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
12 |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
13 This application is distributed in the hope that it will be useful, |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
16 Lesser General Public License for more details. |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
17 |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
18 You should have received a copy of the GNU Lesser General Public |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
19 License along with this application; if not, write to the Free Software |
|
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18871
diff
changeset
|
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 |
|
18715
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
21 USA |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
22 """ |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
23 |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
24 """ |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
25 This file deals with the rss parsing part (feedparser) of the application |
|
64a7b13d3b8d
Update the license info.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18714
diff
changeset
|
26 """ |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
28 import os |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
29 import tempfile, urllib2 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 import feedparser |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 import gobject |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 import sys |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 import time |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 ## |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 # The FeedItem class. It will update emit 'delete' signal when it's |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 # destroyed. |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 ## |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 class FeedItem(gobject.GObject): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 __gproperties__ = { |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 'unread' : (gobject.TYPE_BOOLEAN, 'read', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 'The unread state of the item.', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 False, gobject.PARAM_READWRITE) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 } |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 __gsignals__ = { |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 'delete' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,)) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 } |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 def __init__(self, item, parent): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 self.__gobject_init__() |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
50 try: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
51 "Apparently some feed items don't have any dates in them" |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
52 self.date = item['date'] |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
53 self.date_parsed = item['date_parsed'] |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
54 except: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
55 item['date'] = self.date = time.ctime() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
56 self.date_parsed = feedparser._parse_date(self.date) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
57 |
|
18871
2e41a68009ba
Fix a few small bugs in the example code.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18731
diff
changeset
|
58 self.title = item['title'].encode('utf8') |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
59 self.summary = item['summary'].encode('utf8') |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 self.link = item['link'] |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 self.parent = parent |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 self.unread = True |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 |
|
19707
44b070f6a3f8
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
64 def __del__(self): |
|
44b070f6a3f8
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
65 pass |
|
44b070f6a3f8
Apparently, if the row-keys don't have a destructor function, things can go
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
66 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 def remove(self): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 self.emit('delete', self.parent) |
|
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
69 if self.unread: |
|
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
70 self.parent.set_property('unread', self.parent.unread - 1) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 def do_set_property(self, property, value): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 if property.name == 'unread': |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 self.unread = value |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 |
|
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
76 def mark_unread(self, unread): |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
77 if self.unread == unread: |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
78 return |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
79 self.set_property('unread', unread) |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
80 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 gobject.type_register(FeedItem) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 def item_hash(item): |
|
18871
2e41a68009ba
Fix a few small bugs in the example code.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18731
diff
changeset
|
84 return str(item['title']) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 |
|
18722
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
86 """ |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
87 The Feed class. It will update the 'link', 'title', 'desc' and 'items' |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
88 attributes if/when they are updated (triggering 'notify::<attr>' signal) |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
89 |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
90 TODO: |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
91 - Add a 'count' attribute |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
92 - Each feed will have a 'uidata', which will be its display window |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
93 - Look into 'category'. Is it something that feed defines, or the user? |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
94 - Have separate refresh times for each feed. |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
95 - Have 'priority' for each feed. (somewhat like category, perhaps?) |
|
8b5082d54c1d
Make the rss-reader look and behave nicer.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18715
diff
changeset
|
96 """ |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 class Feed(gobject.GObject): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 __gproperties__ = { |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 'link' : (gobject.TYPE_STRING, 'link', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 'The web page this feed is associated with.', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 '...', gobject.PARAM_READWRITE), |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 'title' : (gobject.TYPE_STRING, 'title', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 'The title of the feed.', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 '...', gobject.PARAM_READWRITE), |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 'desc' : (gobject.TYPE_STRING, 'description', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 'The description for the feed.', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 '...', gobject.PARAM_READWRITE), |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 'items' : (gobject.TYPE_POINTER, 'items', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 'The items in the feed.', gobject.PARAM_READWRITE), |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 'unread' : (gobject.TYPE_INT, 'unread', |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 'Number of unread items in the feed.', 0, 10000, 0, gobject.PARAM_READWRITE) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 } |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 __gsignals__ = { |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 'added' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_OBJECT,)) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 } |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
117 def __init__(self, feed): |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 self.__gobject_init__() |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
119 url = feed['link'] |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
120 name = feed['name'] |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 self.url = url # The url of the feed itself |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 self.link = url # The web page associated with the feed |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 self.desc = url |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
124 self.title = (name, url)[not name] |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
125 self.customtitle = name |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 self.unread = 0 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 self.items = [] |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 self.hash = {} |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
129 self.pending = False |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
130 self._refresh = {'time' : 30, 'id' : 0} |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 |
|
19940
80bfc233c9f2
Fix a memory corruption.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19707
diff
changeset
|
132 def __del__(self): |
|
80bfc233c9f2
Fix a memory corruption.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19707
diff
changeset
|
133 pass |
|
80bfc233c9f2
Fix a memory corruption.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19707
diff
changeset
|
134 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 def do_set_property(self, property, value): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 if property.name == 'link': |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 self.link = value |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 elif property.name == 'desc': |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 self.desc = value |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 elif property.name == 'title': |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 self.title = value |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 elif property.name == 'unread': |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 self.unread = value |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 pass |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
146 def set_result(self, result): |
|
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
147 # XXX Look at result['bozo'] first, and emit some signal that the UI can use |
|
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
148 # to indicate (dim the row?) that the feed has invalid XML format or something |
|
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
149 |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
150 try: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
151 channel = result['channel'] |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
152 self.set_property('link', channel['link']) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
153 self.set_property('desc', channel['description']) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
154 self.set_property('title', channel['title']) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
155 items = result['items'] |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
156 except: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
157 items = () |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
158 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 tmp = {} |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 for item in self.items: |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 tmp[hash(item)] = item |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 |
|
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
163 unread = self.unread |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 for item in items: |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 try: |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 exist = self.hash[item_hash(item)] |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 del tmp[hash(exist)] |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 except: |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 itm = FeedItem(item, self) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 self.items.append(itm) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 self.emit('added', itm) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 self.hash[item_hash(item)] = itm |
|
18714
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
173 unread = unread + 1 |
|
121d1560346c
A few updates to the rss reader.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18682
diff
changeset
|
174 |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
175 if unread != self.unread: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
176 self.set_property('unread', unread) |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
177 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 for hv in tmp: |
|
18871
2e41a68009ba
Fix a few small bugs in the example code.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18731
diff
changeset
|
179 self.items.remove(tmp[hv]) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 tmp[hv].remove() |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
181 "Also notify the UI about the count change" |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
183 self.pending = False |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 return False |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 def refresh(self): |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
187 if self.pending: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
188 return |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
189 self.pending = True |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
190 FeedReader(self).run() |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
191 return True |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 |
|
18725
1aeda1e812a8
Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18722
diff
changeset
|
193 def mark_read(self): |
|
1aeda1e812a8
Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18722
diff
changeset
|
194 for item in self.items: |
|
1aeda1e812a8
Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18722
diff
changeset
|
195 item.mark_unread(False) |
|
1aeda1e812a8
Make things look nice in both 80x25 and in large screens.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18722
diff
changeset
|
196 |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
197 def set_auto_refresh(self, auto): |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
198 if auto: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
199 if self._refresh['id']: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
200 return |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
201 if self._refresh['time'] < 1: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
202 self._refresh['time'] = 1 |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
203 self.id = gobject.timeout_add(self._refresh['time'] * 1000 * 60, self.refresh) |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
204 else: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
205 if not self._refresh['id']: |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
206 return |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
207 gobject.source_remove(self._refresh['id']) |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
208 self._refresh['id'] = 0 |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
209 |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 gobject.type_register(Feed) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
212 """ |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
213 The FeedReader updates a Feed. It fork()s off a child to avoid blocking. |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
214 """ |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
215 class FeedReader: |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 def __init__(self, feed): |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 self.feed = feed |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
218 |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
219 def reap_child(self, pid, status): |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
220 result = feedparser.parse(self.tmpfile.name) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
221 self.tmpfile.close() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
222 self.feed.set_result(result) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 def run(self): |
|
18728
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
225 self.tmpfile = tempfile.NamedTemporaryFile() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
226 self.pid = os.fork() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
227 if self.pid == 0: |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
228 tmp = urllib2.urlopen(self.feed.url) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
229 content = tmp.read() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
230 tmp.close() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
231 self.tmpfile.write(content) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
232 self.tmpfile.flush() |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
233 # Do NOT close tmpfile here |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
234 os._exit(os.EX_OK) |
|
3db31505e42f
Use pseudo-nonblocking stuff to update the feeds.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18727
diff
changeset
|
235 gobject.child_watch_add(self.pid, self.reap_child) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 feeds = [] |
|
18731
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
238 urls = ( |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
239 {'name': '/.', |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
240 'link': "http://rss.slashdot.org/Slashdot/slashdot"}, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
241 {'name': 'KernelTrap', |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
242 'link': "http://kerneltrap.org/node/feed"}, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
243 {'name': None, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
244 'link': "http://pidgin.im/rss.php"}, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
245 {'name': "F1", |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
246 'link': "http://www.formula1.com/rss/news/latest.rss"}, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
247 {'name': "Freshmeat", |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
248 'link': "http://www.pheedo.com/f/freshmeatnet_announcements_unix"}, |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
249 {'name': "Cricinfo", |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
250 'link': "http://www.cricinfo.com/rss/livescores.xml"} |
|
6976a6dae441
Add support for auto-refreshing. There should be some way to change the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18728
diff
changeset
|
251 ) |
|
18681
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 for url in urls: |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 feed = Feed(url) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 feeds.append(feed) |
|
ef15236a0866
A proof-of-conecpt RSS reader using pygnt.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 |
