20
20
GCONF_DELICIOUS_USER = GconfStore.GCONF_DIR+"/desklicious/user"
22
DEFAULT_QUERY_TAG = 'http://del.icio.us/rss/%s/%s'
22
DEFAULT_QUERY_TAG = 'http://feeds.delicious.com/rss/%s/%s'
24
24
HANDLERS = ["DeliciousHandler"]
26
26
class DeliciousAction(ShowUrlAction):
67
67
LOGGER.info( "Asking del.icio.us tags for %s", tag )
68
68
posts = self._delicious.get_posts_by_tag(tag)
71
#self.check_query_changed (timeout=QUERY_DELAY)
72
70
LOGGER.info('Returning del.icio.us result')
73
71
self.set_priority_for_matches( posts )
74
72
self._emit_query_ready(tag, posts )
133
131
if self._user == None:
137
135
#Get the info from del.icio.us and parse
138
136
url = DEFAULT_QUERY_TAG % (urllib.quote_plus(self._user), urllib.quote_plus(tag))
140
138
LOGGER.debug("Opening URL %s", url)
144
stream = urllib.urlopen(url, proxies=deskbar.core.Utils.get_proxy())
145
dom = xml.dom.minidom.parse(stream)
147
LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
149
except ExpatError, e:
141
stream = urllib.urlopen(url, proxies=deskbar.core.Utils.get_proxy())
143
LOGGER.error("Could not open URL %s: %s, %s", url, msg[0], msg[1])
147
dom = xml.dom.minidom.parse(stream)
148
except ExpatError, e:
156
155
#And return the results
159
158
for item in dom.getElementsByTagName("item"):
160
title_node = item.getElementsByTagName("title")[0]
161
url_node = item.getElementsByTagName("link")[0]
162
subject_node = item.getElementsByTagName("dc:subject")[0]
163
creator_node = item.getElementsByTagName("dc:creator")[0]
165
# There might be no tags
166
if (subject_node.hasChildNodes()):
167
tags = subject_node.firstChild.nodeValue.split(" ")
159
title_nodes = item.getElementsByTagName("title")
160
url_nodes = item.getElementsByTagName("link")
162
# Check if we have expected content at all
163
if len(title_nodes) == 0 or len(url_nodes) == 0:
166
item_title = title_nodes[0].firstChild.nodeValue
167
item_url = url_nodes[0].firstChild.nodeValue
169
# by default we have no tags
171
subject_nodes = item.getElementsByTagName("dc:subject")
172
if len(subject_nodes) > 0:
173
subject_node = subject_nodes[0]
174
# There might be no tags
175
if (subject_node.hasChildNodes()):
176
tags = subject_node.firstChild.nodeValue.split(" ")
178
creator_nodes = item.getElementsByTagName("dc:creator")
179
if len(creator_nodes) > 0:
180
creator_node = creator_nodes[0]
181
creator = creator_node.firstChild.nodeValue
173
name=title_node.firstChild.nodeValue,
174
url=url_node.firstChild.nodeValue,
176
author=creator_node.firstChild.nodeValue,
178
192
except DOMException, e:
179
193
LOGGER.exception(e)