- songid = self._setItem(item)
- # Wait for play then start timer
- seconds = 0
- while seconds < STREAM_TIMEOUT:
- try:
- if player.isPlayingAudio() == True:
- if playTimer != None:
- playTimer.cancel()
- songMarkTime = 0
- stream = self._getSongStream(songid)
- duration = stream['duration']
- playTimer = PlayTimer(1, markSong, duration, [songid, duration, stream['streamKey'], stream['streamServerID']])
- playTimer.start()
- break
- except: pass
- time.sleep(1)
- seconds = seconds + 1
-
- # If not playing after a few seconds try to refresh the URL
- if (player.isPlayingAudio() == False and seconds == STREAM_RETRY):
- if __debug__:
- xbmc.log("Refreshing URL")
- item.setProperty('url', '')
- self._setItem(item)
+ songid = item.getProperty('songid')
+ duration = self._getSongDuration(songid)
+ url = ''
+ stream = groovesharkApi.getSubscriberStreamKey(songid)
+ if stream != False:
+ url = stream['url']
+ if url != '':
+ item.setPath(url)
+ xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
+ if __debuggui__ == True:
+ xbmc.log("Grooveshark playing: " + url)
+ # Wait for play then start timer
+ seconds = 0
+ while seconds < STREAM_TIMEOUT:
+ try:
+ if player.isPlayingAudio() == True:
+ if playTimer != None:
+ playTimer.cancel()
+ songMarkTime = 0
+ playTimer = PlayTimer(1, markSong, duration, [songid, duration, stream['streamKey'], stream['streamServerID']])
+ playTimer.start()
+ break
+ except: pass
+ time.sleep(1)
+ seconds = seconds + 1
+ else:
+ xbmc.log("No song URL")