Tuning.
[clinton/xbmc-groove.git] / default.py
index 7e6b392..7742c24 100644 (file)
@@ -353,7 +353,7 @@ class Grooveshark:
                 artistID = artist[1]
                 if __debugging__ :
                     xbmc.log("Found " + artist[0] + "...")
-                albums = groovesharkApi.getArtistAlbums(artistID, limit = self.albumsearchlimit)
+                albums = groovesharkApi.getArtistAlbums(artistID, self.albumsearchlimit, True)
                 if (len(albums) > 0):
                     self._add_albums_directory(albums, artistID)
                 else:
@@ -440,7 +440,7 @@ class Grooveshark:
     # Show selected artist
     def artist(self, artistid):
         albums = groovesharkApi.getArtistAlbums(artistid, limit = self.albumsearchlimit)
-        self._add_albums_directory(albums, artistid)
+        self._add_albums_directory(albums, artistid, True)
     
     # Show selected playlist
     def playlist(self, playlistid, playlistname):
@@ -797,7 +797,7 @@ class Grooveshark:
         xbmcplugin.setPluginFanart(int(sys.argv[1]), self.fanImg)
     
     # Add albums to directory
-    def _add_albums_directory(self, albums, artistid=0):
+    def _add_albums_directory(self, albums, artistid=0, isverified=False):
         n = len(albums)
         itemsExisting = n
         if __debugging__ :
@@ -806,7 +806,7 @@ class Grooveshark:
         while i < n:
             album = albums[i]
             albumID = album[3]
-            if groovesharkApi.getDoesAlbumExist(albumID):                    
+            if isverified or groovesharkApi.getDoesAlbumExist(albumID):                    
                 albumArtistName = album[0]
                 albumName = album[2]
                 albumImage = self._get_icon(album[4], 'album-' + str(albumID))
@@ -910,7 +910,7 @@ class Grooveshark:
         id = int(songid)
         duration = -1
         durations = []
-        path = os.path.join(cacheDir, 'durations.dmp')
+        path = os.path.join(cacheDir, 'duration.dmp')
         try:
             f = open(path, 'rb')
             durations = pickle.load(f)
@@ -922,12 +922,13 @@ class Grooveshark:
         except:
             pass
 
-        # Not in cache but exists
-        if duration < 0 and groovesharkApi.getDoesSongExist(songid):
+        # Not in cache
+        if duration < 0:
             stream = groovesharkApi.getSubscriberStreamKey(songid)
-            duration = self._setDuration(stream['uSecs'])
-            song = [id, duration]
-            self._setSongDuration(song, durations)
+            if stream != False and stream['url'] != '':
+                duration = self._setDuration(stream['uSecs'])
+                song = [id, duration]
+                self._setSongDuration(song, durations)
 
         return duration
         
@@ -937,7 +938,7 @@ class Grooveshark:
             # Create the cache directory if it doesn't exist.
             if not os.path.exists(cacheDir):
                 os.makedirs(cacheDir)
-            path = os.path.join(cacheDir, 'durations.dmp')
+            path = os.path.join(cacheDir, 'duration.dmp')
             f = open(path, 'wb')
             pickle.dump(durations, f, protocol=pickle.HIGHEST_PROTOCOL)
             f.close()