[rhythmbox] Remove album purchase option.



commit 2fd3ab9ab052becb880508f629b242448ebd69c2
Author: Adam Zimmerman <adam zimmerman85 gmail com>
Date:   Thu Dec 24 14:33:34 2009 -0800

    Remove album purchase option.
    
    Magnatune no longer supports buying albums with a credit card over their API.
    This patch just sends the user to a page so they can purchase the albums. The
    purchase/download code is left in because it will be used when download
    accounts are added in a few commits.

 data/rhythmbox.schemas                          |   11 ----------
 plugins/magnatune/magnatune/MagnatuneSource.py  |   24 ++++++----------------
 plugins/magnatune/magnatune/TrackListHandler.py |    4 +--
 plugins/magnatune/magnatune/__init__.py         |    9 +------
 4 files changed, 10 insertions(+), 38 deletions(-)
---
diff --git a/data/rhythmbox.schemas b/data/rhythmbox.schemas
index e9d22fd..66b0b1d 100644
--- a/data/rhythmbox.schemas
+++ b/data/rhythmbox.schemas
@@ -1143,17 +1143,6 @@
 	</locale>
       </schema>
       <schema>
-        <key>/schemas/apps/rhythmbox/plugins/magnatune/pay</key>
-        <applyto>/apps/rhythmbox/plugins/magnatune/pay</applyto>
-        <owner>rhythmbox</owner>
-        <type>int</type>
-        <default>8</default>
-        <locale name="C">
-        <short>US Dollar amount to pay by default for an album.</short>
-	<long>US Dollar amount to pay by default for an album.</long>
-	</locale>
-      </schema>
-      <schema>
         <key>/schemas/apps/rhythmbox/plugins/magnatune/sorting</key>
         <applyto>/apps/rhythmbox/plugins/magnatune/sorting</applyto>
         <owner>rhythmbox</owner>
diff --git a/plugins/magnatune/magnatune/MagnatuneSource.py b/plugins/magnatune/magnatune/MagnatuneSource.py
index 5067880..359a13e 100644
--- a/plugins/magnatune/magnatune/MagnatuneSource.py
+++ b/plugins/magnatune/magnatune/MagnatuneSource.py
@@ -51,6 +51,7 @@ magnatune_partner_id = "rhythmbox"
 
 # URIs
 magnatune_song_info_uri = "http://magnatune.com/info/song_info_xml.zip";
+magnatune_buy_album_uri = "https://magnatune.com/buy/choose?";
 
 magnatune_in_progress_dir = os.path.join(rb.user_data_dir(), 'magnatune')
 magnatune_cache_dir = os.path.join(rb.user_cache_dir(), 'magnatune')
@@ -77,7 +78,6 @@ class MagnatuneSource(rb.BrowserSource):
 		# track data
 		self.__sku_dict = {}
 		self.__home_dict = {}
-		self.__buy_dict = {}
 		self.__art_dict = {}
 
 		# catalogue stuff
@@ -205,31 +205,20 @@ class MagnatuneSource(rb.BrowserSource):
 				gtk.show_uri(screen, url, gtk.gdk.CURRENT_TIME)
 				urls.add(url)
 
-	def buy_cd(self):
+	def purchase_album(self):
 		screen = self.props.shell.props.window.get_screen()
 		tracks = self.get_entry_view().get_selected_entries()
 		urls = set([])
 
 		for tr in tracks:
 			sku = self.__sku_dict[self.__db.entry_get(tr, rhythmdb.PROP_LOCATION)]
-			url = self.__buy_dict[sku]
+			url = magnatune_buy_album_uri + urllib.urlencode({ 'sku': sku })
 			if url not in urls:
 				gtk.show_uri(screen, url, gtk.gdk.CURRENT_TIME)
 				urls.add(url)
-
-	def radio_toggled(self, builder):
-		gc = builder.get_object("radio_gc").get_active()
-		builder.get_object("remember_cc_details").set_sensitive(not gc)
-		builder.get_object("name_entry").set_sensitive(not gc)
-		builder.get_object("cc_entry").set_sensitive(not gc)
-		builder.get_object("mm_entry").set_sensitive(not gc)
-		builder.get_object("yy_entry").set_sensitive(not gc)
-		
-		builder.get_object("gc_entry").set_sensitive(gc)
-		if not gc:
-			builder.get_object("gc_entry").set_text("")
 	
-	def purchase_album(self):
+	# This method isn't called at the moment. We'll need it later to add download accounts though...
+	def download_album(self):
 		try:
 			library_location = self.__client.get_list("/apps/rhythmbox/library_locations", gconf.VALUE_STRING)[0] # Just use the first library location
 		except IndexError, e:
@@ -351,7 +340,7 @@ class MagnatuneSource(rb.BrowserSource):
 		self.__has_loaded = True
 
 		parser = xml.sax.make_parser()
-		parser.setContentHandler(TrackListHandler(self.__db, self.__entry_type, self.__sku_dict, self.__home_dict, self.__buy_dict, self.__art_dict))
+		parser.setContentHandler(TrackListHandler(self.__db, self.__entry_type, self.__sku_dict, self.__home_dict, self.__art_dict))
 		
 		self.__catalogue_loader = rb.ChunkLoader()
 		self.__catalogue_loader.get_url_chunks(magnatune_song_info, 64*1024, True, self.__catalogue_chunk_cb, parser)
@@ -442,6 +431,7 @@ class MagnatuneSource(rb.BrowserSource):
 
 	#
 	# internal purchasing code
+	# not used at the moment, but it will be used again when we have download accounts...
 	#
 	def __buy_album(self, sku, pay, format, ccnumber, ccyear, ccmonth, name, email, gc, gc_text): # http://magnatune.com/info/api#purchase
 		print "purchasing tracks:", sku, pay, format, name, email
diff --git a/plugins/magnatune/magnatune/TrackListHandler.py b/plugins/magnatune/magnatune/TrackListHandler.py
index 3782bba..cab3db9 100644
--- a/plugins/magnatune/magnatune/TrackListHandler.py
+++ b/plugins/magnatune/magnatune/TrackListHandler.py
@@ -31,13 +31,12 @@ import datetime
 
 class TrackListHandler(xml.sax.handler.ContentHandler):
 
-	def __init__(self, db, entry_type, sku_dict, home_dict, buy_dict, art_dict):
+	def __init__(self, db, entry_type, sku_dict, home_dict, art_dict):
 		xml.sax.handler.ContentHandler.__init__(self)
 		self.__db = db
 		self.__entry_type = entry_type
 		self.__sku_dict = sku_dict
 		self.__home_dict = home_dict
-		self.__buy_dict = buy_dict
 		self.__art_dict = art_dict
 		self.__track = {}
 
@@ -88,7 +87,6 @@ class TrackListHandler(xml.sax.handler.ContentHandler):
 				sku = intern(str(self.__track['albumsku']))
 				self.__sku_dict[key] = sku
 				self.__home_dict[sku] = str(self.__track['home'])
-				self.__buy_dict[sku] = str(self.__track['buy'].replace("buy_album", "buy_cd", 1))
 				self.__art_dict[sku] = str(self.__track['cover_small'])
 
 				self.__db.commit()
diff --git a/plugins/magnatune/magnatune/__init__.py b/plugins/magnatune/magnatune/__init__.py
index 1d50978..2a19ced 100644
--- a/plugins/magnatune/magnatune/__init__.py
+++ b/plugins/magnatune/magnatune/__init__.py
@@ -51,7 +51,6 @@ popup_ui = """
   <popup name="MagnatuneSourceViewPopup">
     <menuitem name="AddToQueueLibraryPopup" action="AddToQueue"/>
     <menuitem name="MagnatunePurchaseAlbum" action="MagnatunePurchaseAlbum"/>
-    <menuitem name="MagnatunePurchaseCD" action="MagnatunePurchaseCD"/>
     <menuitem name="MagnatuneArtistInfo" action="MagnatuneArtistInfo"/>
     <menuitem name="MagnatuneCancelDownload" action="MagnatuneCancelDownload"/>
     <separator/>
@@ -114,16 +113,12 @@ class Magnatune(rb.Plugin):
 		
 		manager = shell.get_player().get_property('ui-manager')
 		# Add the popup menu actions
+		self.action_group = gtk.ActionGroup('MagnatunePluginActions')
+		
 		action = gtk.Action('MagnatunePurchaseAlbum', _('Purchase Album'),
 				_("Purchase this album from Magnatune"),
 				'gtk-save')
 		action.connect('activate', lambda a: self.shell.get_property("selected-source").purchase_album())
-		self.action_group = gtk.ActionGroup('MagnatunePluginActions')
-		self.action_group.add_action(action)
-		action = gtk.Action('MagnatunePurchaseCD', _('Purchase Physical CD'),
-				_("Purchase a physical CD from Magnatune"),
-				'gtk-cdrom')
-		action.connect('activate', lambda a: self.shell.get_property("selected-source").buy_cd())
 		self.action_group.add_action(action)
 		action = gtk.Action('MagnatuneArtistInfo', _('Artist Information'),
 				_("Get information about this artist"),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]