From: stephendenham Date: Wed, 15 Aug 2012 20:18:28 +0000 (+0000) Subject: Fix next play. X-Git-Url: https://git.hcoop.net/clinton/xbmc-groove.git/commitdiff_plain/f7eadea20b484447c752f649c9b0a269ec63f670 Fix next play. git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@76 2dec19e3-eb1d-4749-8193-008c8bba0994 --- diff --git a/addon.xml b/addon.xml index 47d1b63..1a77971 100644 --- a/addon.xml +++ b/addon.xml @@ -1,6 +1,6 @@ + version="1.0.6" provider-name="Stephen Denham"> diff --git a/changelog.txt b/changelog.txt index cd8bc87..064b934 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +1.0.6 + +Fix play next issue. + +1.0.5 + +Fix IP address. + 1.0.4 Fix playlist name encoding bug. diff --git a/default.py b/default.py index ab1f436..73d6629 100644 --- a/default.py +++ b/default.py @@ -482,21 +482,22 @@ class Grooveshark: global player player.stop() if item != None: + # Get stream as it could have expired url = '' songid = item.getProperty('songid') - duration = int(self._getSongDuration(songid)) stream = groovesharkApi.getSubscriberStreamKey(songid) if stream != False: url = stream['url'] key = stream['StreamKey'] server = stream['StreamServerID'] - duration = self._setDuration(stream['uSecs']) + duration = int(self._setDuration(stream['uSecs'])) if url != '': item.setPath(url) xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item) if __debugging__ : xbmc.log("Grooveshark playing: " + url) # Wait for play then start timer + xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item) seconds = 0 while seconds < STREAM_TIMEOUT: try: @@ -517,24 +518,35 @@ class Grooveshark: # Make a song directory item def songItem(self, songid, name, album, artist, coverart, trackLabelFormat=ARTIST_ALBUM_NAME_LABEL): - songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image") - if int(trackLabelFormat) == NAME_ALBUM_ARTIST_LABEL: - trackLabel = name + " - " + album + " - " + artist - else: - trackLabel = artist + " - " + album + " - " + name - duration = self._getSongDuration(songid) - item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg) - item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist, "duration": duration} ) - item.setProperty('mimetype', 'audio/mpeg') - item.setProperty("IsPlayable", "true") - item.setProperty('songid', str(songid)) - item.setProperty('coverart', songImg) - item.setProperty('title', name) - item.setProperty('album', album) - item.setProperty('artist', artist) - item.setProperty('duration', str(duration)) - return item + stream = groovesharkApi.getSubscriberStreamKey(songid) + if stream != False: + url = stream['url'] + key = stream['StreamKey'] + server = stream['StreamServerID'] + duration = self._setDuration(stream['uSecs']) + songImg = self._get_icon(coverart, 'song-' + str(songid) + "-image") + if int(trackLabelFormat) == NAME_ALBUM_ARTIST_LABEL: + trackLabel = name + " - " + album + " - " + artist + else: + trackLabel = artist + " - " + album + " - " + name + item = xbmcgui.ListItem(label = trackLabel, thumbnailImage=songImg, iconImage=songImg) + item.setPath(url) + item.setInfo( type="music", infoLabels={ "title": name, "album": album, "artist": artist, "duration": duration} ) + item.setProperty('mimetype', 'audio/mpeg') + item.setProperty("IsPlayable", "true") + item.setProperty('songid', str(songid)) + item.setProperty('coverart', songImg) + item.setProperty('title', name) + item.setProperty('album', album) + item.setProperty('artist', artist) + item.setProperty('duration', str(duration)) + item.setProperty('key', str(key)) + item.setProperty('server', str(server)) + return item + else: + xbmc.log("No song URL") + return None # Next page of songs def songPage(self, offset, trackLabelFormat, playlistid = 0, playlistname = ''): @@ -701,15 +713,6 @@ class Grooveshark: dialog.ok(__language__(30008), __language__(30069), __language__(30070)) return 0 - # Get a song directory item - def _get_song_item(self, song, trackLabelFormat): - name = song[0] - songid = song[1] - album = song[2] - artist = song[4] - coverart = song[6] - return self.songItem(songid, name, album, artist, coverart, trackLabelFormat) - # File download def _get_icon(self, url, songid): if url != 'None': @@ -754,10 +757,13 @@ class Grooveshark: items = end - start while n < end: song = songs[n] + name = song[0] songid = song[1] - duration = self._getSongDuration(songid) - if duration != -1: - item = self._get_song_item(song, trackLabelFormat) + album = song[2] + artist = song[4] + coverart = song[6] + item = self.songItem(songid, name, album, artist, coverart, trackLabelFormat) + if item != None: coverart = item.getProperty('coverart') songname = song[0] songalbum = song[2] @@ -906,46 +912,6 @@ class Grooveshark: xbmc.log("An error occurred saving songs") pass - def _getSongDuration(self, songid): - id = int(songid) - duration = -1 - durations = [] - path = os.path.join(cacheDir, 'duration.dmp') - try: - f = open(path, 'rb') - durations = pickle.load(f) - for song in durations: - if song[0] == id: - duration = song[1] - break; - f.close() - except: - pass - - # Not in cache - if duration < 0: - stream = groovesharkApi.getSubscriberStreamKey(songid) - if stream != False and stream['url'] != '': - duration = self._setDuration(stream['uSecs']) - song = [id, duration] - self._setSongDuration(song, durations) - - return duration - - def _setSongDuration(self, song, durations): - try: - durations.append(song) - # Create the cache directory if it doesn't exist. - if not os.path.exists(cacheDir): - os.makedirs(cacheDir) - path = os.path.join(cacheDir, 'duration.dmp') - f = open(path, 'wb') - pickle.dump(durations, f, protocol=pickle.HIGHEST_PROTOCOL) - f.close() - except: - xbmc.log("An error occurred saving duration") - pass - # Duration to seconds def _setDuration(self, usecs): if usecs < 60000000: diff --git a/description.xml b/description.xml index efe80eb..6dfe92e 100644 --- a/description.xml +++ b/description.xml @@ -18,7 +18,7 @@ Grooveshark XBMC - 1.0.4 + 1.0.6