[rhythmbox] context: use urllib.quote_plus to quote URL arguments correctly
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] context: use urllib.quote_plus to quote URL arguments correctly
- Date: Sun, 1 Nov 2009 06:01:24 +0000 (UTC)
commit 71959bed7385e24c8d899a011bc348d0e0cdb0ce
Author: Jonathan Matthew <jonathan fibula d14n org>
Date: Sun Nov 1 14:30:11 2009 +1000
context: use urllib.quote_plus to quote URL arguments correctly
plugins/context/context/AlbumTab.py | 14 +++++++++-----
plugins/context/context/ArtistTab.py | 5 +++--
2 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/plugins/context/context/AlbumTab.py b/plugins/context/context/AlbumTab.py
index 8748d28..2c90cd0 100644
--- a/plugins/context/context/AlbumTab.py
+++ b/plugins/context/context/AlbumTab.py
@@ -29,6 +29,7 @@ import gtk, gobject
import webkit
import os
import cgi
+import urllib
from mako.template import Template
import xml.dom.minidom as dom
import LastFM
@@ -170,11 +171,12 @@ class AlbumDataSource (gobject.GObject):
return
self.artist = artist
+ qartist = urllib.quote_plus (artist)
self.error = None
url = "%sartist.gettopalbums&artist=%s&api_key=%s" % (LastFM.URL_PREFIX,
- artist.replace(" ", "+"),
+ qartist,
LastFM.API_KEY)
- cachekey = 'lastfm:artist:gettopalbums:%s' % artist
+ cachekey = 'lastfm:artist:gettopalbums:%s' % qartist
self.ranking_cache.fetch(cachekey, url, self.parse_album_list, artist)
def parse_album_list (self, data, artist):
@@ -218,10 +220,12 @@ class AlbumDataSource (gobject.GObject):
return self.albums
def fetch_album_info (self, artist, album, index):
- cachekey = "lastfm:album:getinfo:%s:%s" % (artist, album)
+ qartist = urllib.quote_plus (artist)
+ qalbum = urllib.quote_plus (album)
+ cachekey = "lastfm:album:getinfo:%s:%s" % (qartist, qalbum)
url = "%salbum.getinfo&artist=%s&album=%s&api_key=%s" % (LastFM.URL_PREFIX,
- artist.replace(" ", "+"),
- album.replace(" ", "+"),
+ qartist,
+ qalbum,
LastFM.API_KEY)
self.info_cache.fetch(cachekey, url, self.fetch_album_tracklist, album, index)
diff --git a/plugins/context/context/ArtistTab.py b/plugins/context/context/ArtistTab.py
index ba6bf5c..82c44bb 100644
--- a/plugins/context/context/ArtistTab.py
+++ b/plugins/context/context/ArtistTab.py
@@ -28,6 +28,7 @@ import rb, rhythmdb
import gtk, gobject
import re, os
import cgi
+import urllib
import xml.dom.minidom as dom
import LastFM
@@ -204,7 +205,7 @@ class ArtistDataSource (gobject.GObject):
if LastFM.user_has_account() is False:
return
- artist = artist.replace (" ", "+")
+ artist = urllib.quote_plus (artist)
function = self.artist['top_tracks']['function']
cache = self.artist['top_tracks']['cache']
cachekey = "lastfm:artist:%s:%s" % (function, artist)
@@ -226,7 +227,7 @@ class ArtistDataSource (gobject.GObject):
return
self.error = None
- artist = artist.replace(" ", "+")
+ artist = urllib.quote_plus (artist)
for key, value in self.artist.items():
cachekey = "lastfm:artist:%s:%s" % (value['function'], artist)
url = '%sartist.%s&artist=%s&api_key=%s' % (LastFM.URL_PREFIX,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]