[kupfer] google_search: Unquote URLs and titles of search results
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] google_search: Unquote URLs and titles of search results
- Date: Fri, 4 Mar 2011 16:26:23 +0000 (UTC)
commit 804bd44cfe66742d68dd7b25d82cbd9f74f2df29
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Mar 3 22:58:26 2011 +0100
google_search: Unquote URLs and titles of search results
This API is deprecated according to Google so the plugin needs
update sooner or later. Google has a planned deprecation time of 3
years after the deprecation date in the autumn of 2010.
kupfer/plugin/google_search.py | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/plugin/google_search.py b/kupfer/plugin/google_search.py
index bd9b20a..716de51 100644
--- a/kupfer/plugin/google_search.py
+++ b/kupfer/plugin/google_search.py
@@ -48,6 +48,11 @@ class CustomDescriptionUrl (UrlLeaf):
def get_description(self):
return self.description
+def _xml_unescape(ustr):
+ """Unescape & to &, < to <, > to >"""
+ # important to replace & last here
+ return ustr.replace("<", "<").replace(">", ">").replace("&", "&")
+
class SearchResults (Source):
def __init__(self, query):
Source.__init__(self, _('Results for "%s"') % query)
@@ -80,7 +85,8 @@ class SearchResults (Source):
total_results = data['cursor'].get('estimatedResultCount', 0)
for h in data['results']:
uq_url = urllib.unquote(h['url'])
- yield UrlLeaf(uq_url, h['titleNoFormatting'])
+ uq_title = _xml_unescape(h['titleNoFormatting'])
+ yield UrlLeaf(uq_url, uq_title)
yield CustomDescriptionUrl(more_results_url,
_('Show More Results For "%s"') % self.query,
_("%s total found") % total_results)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]