libDir = xbmc.translatePath(os.path.join(resDir, 'lib'))
imgDir = xbmc.translatePath(os.path.join(resDir, 'img'))
thumbDir = os.path.join('special://masterprofile/addon_data/', os.path.join(os.path.basename(os.getcwd()), 'thumb'))
-favoritesCache = xbmc.translatePath('special://masterprofile/addon_data/', os.path.join(os.path.basename(os.getcwd()), 'favorites.dmp'))
+favoritesCache = xbmc.translatePath(os.path.join('special://masterprofile/addon_data/', os.path.join(os.path.basename(os.getcwd()), 'favorites.dmp')))
sys.path.append (libDir)
from GrooveAPI import *
def similarSong(self, songid):
userid = self._get_login()
if (userid != 0):
- xbmc.log("Frown playSong: " + str(songid))
- if groovesharkApi.radioSong(songId = songid) and groovesharkApi.radioStartSongs() == True:
+ xbmc.log("Add song: " + str(songid))
+ if groovesharkApi.radioSong(songId = songid) != False and groovesharkApi.radioStartSongs() == True:
self.playNext()
else:
dialog = xbmcgui.Dialog()
def similarArtist(self, artistId):
userid = self._get_login()
if (userid != 0):
- xbmc.log("Add radio artist of playSong: " + str(artistId))
- if groovesharkApi.radioArtist(artistId = artistId) and groovesharkApi.radioStartArtists() == True:
+ xbmc.log("Add radio artist: " + str(artistId))
+ if groovesharkApi.radioArtist(artistId = artistId) != False and groovesharkApi.radioStartArtists() == True:
self.playNext()
else:
dialog = xbmcgui.Dialog()
def songItem(self, id, name, album, artist, duration, thumb, image):
url = groovesharkApi.getStreamURL(id)
- songImg = self._get_icon(image, 'song-' + str(id) + "-image")
- songThm = self._get_icon(thumb, 'song-' + str(id) + "-thumb")
+ # Only try to get the image
+ if image != "":
+ songImg = self._get_icon(image, 'song-' + str(id) + "-image")
+ songThm = songImg
+ else:
+ songThm = self._get_icon(thumb, 'song-' + str(id) + "-thumb")
+ songImg = songThm
item = xbmcgui.ListItem(label = artist + " - " + album + " - " + name, path=url, thumbnailImage=songThm, iconImage=songImg)
item.setInfo( type="music", infoLabels={ "title": name, "duration": duration, "album": album, "artist": artist} )
item.setProperty('mimetype', 'audio/mpeg')
def _get_favorites(self):
favorites = []
# if the cache does not exist or is older than x hours then reload
- if (os.path.isfile(favoritesCache) == False) or (time.gmtime() - os.path.gmtime(favoritesCache) > 3*60*60):
+ if (os.path.isfile(favoritesCache) == False) or (time.time() - os.path.getmtime(favoritesCache) > 3*60*60):
xbmc.log("Refresh favorites cache")
userid = self._get_login()
if (userid != 0):
# File download
def _get_icon(self, url, id):
localThumb = os.path.join(xbmc.translatePath(os.path.join(thumbDir, str(id)))) + '.tbn'
- xbmc.log('Downloading ' + url + ' to ' + localThumb)
try:
if os.path.isfile(localThumb) == False:
+ xbmc.log('Downloading ' + url + ' to ' + localThumb)
loc = urllib.URLopener()
loc.retrieve(url, localThumb)
except:
+"&image="+urllib.quote_plus(songimage)
fav=sys.argv[0]+"?url="+urllib.quote_plus(songurl)+"&mode="+str(MODE_FAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid)
unfav=sys.argv[0]+"?url="+urllib.quote_plus(songurl)+"&mode="+str(MODE_UNFAVORITE)+"&name="+urllib.quote_plus(songname)+"&id="+str(songid)
- similarArtist=sys.argv[0]+"?mode="+str(MODE_SIMILAR_ARTIST)+"&id="+str(songartistid)
- similarSong=sys.argv[0]+"?mode="+str(MODE_SIMILAR_SONG)+"&id="+str(songid)
- frown=sys.argv[0]+"?mode="+str(MODE_FROWN)+"&id="+str(songid)
+ #similarArtist=sys.argv[0]+"?mode="+str(MODE_SIMILAR_ARTIST)+"&id="+str(songartistid)
+ #similarSong=sys.argv[0]+"?mode="+str(MODE_SIMILAR_SONG)+"&id="+str(songid)
+ #frown=sys.argv[0]+"?mode="+str(MODE_FROWN)+"&id="+str(songid)
menuItems = []
menuItems.append(("Grooveshark Favorite", "XBMC.RunPlugin("+fav+")"))
menuItems.append(("Not Grooveshark Favorite", "XBMC.RunPlugin("+unfav+")"))
- menuItems.append(("Listen to similar artist", "XBMC.RunPlugin("+similarArtist+")"))
- menuItems.append(("Listen to similar song", "XBMC.RunPlugin("+similarSong+")"))
- menuItems.append(("No thanks!", "XBMC.RunPlugin("+frown+")"))
+ #menuItems.append(("Listen to similar artist", "XBMC.RunPlugin("+similarArtist+")"))
+ #menuItems.append(("Listen to similar song", "XBMC.RunPlugin("+similarSong+")"))
+ #menuItems.append(("No thanks!", "XBMC.RunPlugin("+frown+")"))
item.addContextMenuItems(menuItems, replaceItems=False)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=False)
i = i + 1
return False
result = self.callRemote("autoplay.startWithArtistIDs", {"artistIDs": radio['seedArtists']})
if 'fault' in result:
+ print "Cannot autoplay artists"
self.radioEnabled = False
else:
self.radioEnabled = True
return False
result = self.callRemote("autoplay.start", {"songIDs": radio['seedSongs']})
if 'fault' in result:
+ print "Cannot autoplay songs"
self.radioEnabled = False
else:
self.radioEnabled = True
radio['seedArtists'].remove(artistId)
except: pass
radio['seedArtists'].append(artistId)
+ print "Saved radio"
return self.saveRadio(radio = radio)
else:
+ print "Failed to get radio"
return False
def radioSong(self, songId = None):
radio['seedSongs'].remove(songId)
except: pass
radio['seedSongs'].append(songId)
+ print "Saved radio"
return self.saveRadio(radio = radio)
else:
+ print "Failed to get radio"
return False
def radioTurnedOn(self):
f.close()
print radio
except:
+ print "Failed to open " + path
radio = {}
radio['seedSongs'] = []
radio['seedArtists'] = []