From: stephendenham Date: Fri, 3 Dec 2010 15:40:19 +0000 (+0000) Subject: Disabled radio. X-Git-Url: https://git.hcoop.net/clinton/xbmc-groove.git/commitdiff_plain/e6ccfeca53fe3df107378e3c7747a351049c7806 Disabled radio. git-svn-id: svn://svn.code.sf.net/p/xbmc-groove/code@9 2dec19e3-eb1d-4749-8193-008c8bba0994 --- diff --git a/default.py b/default.py index 2053c2a..cf909a9 100644 --- a/default.py +++ b/default.py @@ -23,7 +23,7 @@ resDir = xbmc.translatePath(os.path.join(baseDir, 'resources')) 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 * @@ -169,8 +169,8 @@ class Groveshark: 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() @@ -182,8 +182,8 @@ class Groveshark: 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() @@ -220,8 +220,13 @@ class Groveshark: 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') @@ -235,7 +240,7 @@ class Groveshark: 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): @@ -290,9 +295,9 @@ class Groveshark: # 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: @@ -327,15 +332,15 @@ class Groveshark: +"&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 diff --git a/resources/lib/GrooveAPI.py b/resources/lib/GrooveAPI.py index e97d04d..b1e5c7e 100644 --- a/resources/lib/GrooveAPI.py +++ b/resources/lib/GrooveAPI.py @@ -334,6 +334,7 @@ class GrooveAPI: 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 @@ -345,6 +346,7 @@ class GrooveAPI: 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 @@ -382,8 +384,10 @@ class GrooveAPI: 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): @@ -393,8 +397,10 @@ class GrooveAPI: 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): @@ -408,6 +414,7 @@ class GrooveAPI: f.close() print radio except: + print "Failed to open " + path radio = {} radio['seedSongs'] = [] radio['seedArtists'] = []