Use song URL for playback.
authorstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Sat, 15 Jan 2011 16:02:17 +0000 (16:02 +0000)
committerstephendenham <stephendenham@2dec19e3-eb1d-4749-8193-008c8bba0994>
Sat, 15 Jan 2011 16:02:17 +0000 (16:02 +0000)
git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@34 2dec19e3-eb1d-4749-8193-008c8bba0994

addon.xml
changelog.txt
default.py
description.xml
resources/lib/GroovesharkAPI.py

index 4cb3f96..d08d6ff 100644 (file)
--- a/addon.xml
+++ b/addon.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="plugin.audio.groove" name="Grooveshark XBMC"
-       version="0.2.0" provider-name="Stephen Denham">
+       version="0.2.1" provider-name="Stephen Denham">
        <requires>
                <import addon="xbmc.python" version="1.0" />
        </requires>
index 622f6dc..fed6214 100644 (file)
@@ -1,3 +1,7 @@
+0.2.1:
+
+Use song URL directly for playback. Much faster.
+
 0.2.0:
 
 Major changes to use new Grooveshark API.
index dee06e3..bf28a07 100644 (file)
@@ -211,12 +211,12 @@ class Groveshark:
     def playSong(self, item):
         songid = item.getProperty('songid')
         song = groovesharkApi.getSongURLFromSongID(songid)
-        if os.path.isfile(song):
+        if song != '':
             item.setPath(song)
             xbmc.log("Playing: " + song)
             xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
         else:
-            xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Cannot play song, 1000, ' + thumbDef + ')')
+            xbmc.executebuiltin('XBMC.Notification(Grooveshark XBMC, Unable to play song, 1000, ' + thumbDef + ')')
     
     # Make a song directory item
     def songItem(self, songid, name, album, artist, coverart):
index a8ccf8b..a1afbe1 100644 (file)
@@ -18,7 +18,7 @@
        <title>Grooveshark XBMC.</title>
 
        <!-- (required) Major.minor.build -->
-       <version>0.2.0</version>
+       <version>0.2.1</version>
 
        <!--
                (required) author name & email. at least one author name is required
index e36ffc2..70eddfd 100644 (file)
@@ -200,19 +200,14 @@ class GrooveSong:
                        "songID": songID}
                self._callRemote("markSongDownloaded", params)
 
-       # Download a song to a temporary file
+       # Get the song URL
        def getSongURL(self, songID):
-               filename = os.path.join(self.cacheDir, songID + SONG_SUFFIX)
-               print "Caching song " + songID + " to " + filename
-               if os.path.isfile(filename) == False:
-                       if self._getStreamDetails(songID) == True:
-                               postData = {"streamKey": self._lastStreamKey}
-                               postData = urllib.urlencode(postData)
-                               urllib.FancyURLopener().retrieve( "http://" + self._lastStreamServer + "/stream.php", filename, data=postData)
-                               self._markSongDownloaded(songID)
-                       else:
-                               return ''
-               return filename
+               if self._getStreamDetails(songID) == True:
+                       postData = {"streamKey": self._lastStreamKey}
+                       postData = urllib.urlencode(postData)
+                       return "http://" + self._lastStreamServer + "/stream.php?" + str(postData)
+               else:
+                       return ''
 
 # Main API
 class GrooveAPI:
@@ -412,7 +407,9 @@ class GrooveAPI:
        # Get the url to link to a song on Grooveshark
        def getSongURLFromSongID(self, songID):
                song = GrooveSong()
-               return song.getSongURL(songID)
+               url = song.getSongURL(songID)
+               print "Got song URL " + url
+               return url
 
        # Get the url to link to a song on Grooveshark
        def getSongInfo(self, songID):