The branch, dharma-pre has been updated
       via  cf4caf039f127da2b7c916ddb4243fe7cbef37bb (commit)
      from  d7ff2ad61ad0d291b739f6efedba7290a468ff9a (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=cf4caf039f127da2b7c916ddb4243fe7cbef37bb

commit cf4caf039f127da2b7c916ddb4243fe7cbef37bb
Author: Zeljko Ametovic <[email protected]>
Date:   Thu Nov 4 10:27:36 2010 +0400

    [script.audio.grooveshark] -v 0.3.0
    - Bug fix: Exit button didn't display correctly.
    - Enhancement: Search function should be much faster.
    - Enhancement: Reduced number of http requests on Dharma.
    - Fixed: Works on Dharma Beta 4.

diff --git a/script.audio.grooveshark/GrooveShark.py 
b/script.audio.grooveshark/GrooveShark.py
index 0520c32..dd9c90b 100644
--- a/script.audio.grooveshark/GrooveShark.py
+++ b/script.audio.grooveshark/GrooveShark.py
@@ -4,13 +4,7 @@ import pickle
 import os
 import traceback
 import threading
-
-sys.path.append(os.path.join(os.getcwd().replace(";",""),'resources','lib'))
-
-from GrooveAPI import *
-from GroovePlayer import GroovePlayer
-from GrooveGUI import *
-from operator import itemgetter, attrgetter
+import random
 
 __scriptname__ = sys.modules[ "__main__" ].__scriptname__
 __version__ = sys.modules[ "__main__" ].__version__
@@ -19,6 +13,32 @@ __language__ = sys.modules[ "__main__" ].__language__
 __scriptid__ = sys.modules[ "__main__" ].__scriptid__
 __debugging__ = sys.modules["__main__"].__debugging__
 __isXbox__ = sys.modules["__main__"].__isXbox__
+__cwd__ = sys.modules["__main__"].__cwd__
+
+sys.path.append(os.path.join(__cwd__.replace(";",""),'resources','lib'))
+
+from GrooveAPI import *
+from GroovePlayer import GroovePlayer
+from GrooveGUI import *
+from operator import itemgetter, attrgetter
+
+class searchThread(threading.Thread):
+       def __init__(self, item, query):
+               threading.Thread.__init__(self)
+               self.item = item
+               self.query = query
+
+       def run (self):
+               try:
+                       function = self.item['function']
+                       if self.query == None:
+                               self.item['result'] = 
function(GrooveClass.SEARCH_LIMIT)
+                       else:
+                               self.item['result'] = function(self.query, 
GrooveClass.SEARCH_LIMIT)
+               except:
+                       self.item['result'] = None
+                       print "GrooveShark: Search thread failed"
+                       traceback.print_exc()
 
 class GrooveClass(xbmcgui.WindowXML):
 
@@ -74,7 +94,7 @@ class GrooveClass(xbmcgui.WindowXML):
 
        def initPlayer(self):
                try:
-                       self.player = GroovePlayer()
+                       self.player = GroovePlayer(xbmc.PLAYER_CORE_MPLAYER)
                        self.player.setCallBackFunc(self.playerChanged)
                except:
                        xbmc.log('GrooveShark Exception (initPlayer): ' + 
str(sys.exc_info()[0]))
@@ -137,8 +157,21 @@ class GrooveClass(xbmcgui.WindowXML):
                        result = search.getResult()
                        if result != None:
                                text = result['query']
+                               lst = []
+                               lst.append({'result': [], 
'id':id(self.searchResultSongs), 'function': self.gs.searchSongs})
+                               lst.append({'result': [], 
'id':id(self.searchResultArtists), 'function': self.gs.searchArtists})
+                               lst.append({'result': [], 
'id':id(self.searchResultAlbums), 'function': self.gs.searchAlbums})
+                               lst.append({'result': [], 
'id':id(self.searchResultPlaylists), 'function': self.gs.searchPlaylists})
                                self.searchText = text
-                               self.searchAll(text)
+                               self.search(text, lst)
+                               for item in lst:
+                                       if item['result'] == None:
+                                               item['result'] = []
+                                               
self.message(__language__(3022), __language__(3011))
+                               self.searchResultSongs = lst[0]['result']
+                               self.searchResultArtists = lst[1]['result']
+                               self.searchResultAlbums = lst[2]['result']
+                               self.searchResultPlaylists = lst[3]['result']
                                
self.setStateListDown(GrooveClass.STATE_LIST_SEARCH, reset = True, query = text)
                elif control == 1001:
                        if __isXbox__ == True:
@@ -162,7 +195,10 @@ class GrooveClass(xbmcgui.WindowXML):
                elif control == 1004:
                        self.getPopular()
                elif control == 1005:
-                       __settings__.openSettings()
+                       try:
+                               __settings__.openSettings()
+                       except:
+                               traceback.print_exc()
                elif control == 1007: #Exit
                        self.saveState()
                        self.close()
@@ -327,7 +363,7 @@ class GrooveClass(xbmcgui.WindowXML):
                self.playlistId = 0
                self.playlistName = 'Unsaved'
                self.searchText = ""
-               self.rootDir = os.getcwd()
+               self.rootDir = __cwd__
                self.xbmcPlaylist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
                self.location = []
                if __isXbox__ == True:
@@ -351,7 +387,7 @@ class GrooveClass(xbmcgui.WindowXML):
                self.defaultArtMediumUrl = 
'http://beta.grooveshark.com/webincludes/img/defaultart/album/mdefault.png'
                self.itemsPrPage = 10
 
-       def saveState(self):                    
+       def saveState(self):
                try:
                        print 'GrooveShark: Saving state'
                        self.location[len(self.location)-1]['itemFocused'] = 
self.getCurrentListPosition()
@@ -608,7 +644,7 @@ class GrooveClass(xbmcgui.WindowXML):
                        pass
 
        def showOptionsNowPlaying(self, songs):
-               items = [__language__(102),__language__(113)]
+               items = [__language__(102),__language__(113), 
__language__(122), __language__(104)]
                result = gSimplePopup(title='', items=items, width=200)
 
                n = self.getCurrentListPosition()-1
@@ -619,6 +655,40 @@ class GrooveClass(xbmcgui.WindowXML):
                        self.nowPlayingList.pop(n)
                        self.listMenu()
 
+               elif result == 2: #Remove all songs
+                       self.nowPlayingList = []
+                       self.nowPlaying = -1
+                       self.listMenu()
+
+               elif result == 3: #Add to playlist
+                       if self.gs.loggedInStatus() != 1:
+                               result = self.login()
+                               if result == 1:
+                                       pass
+                               elif result == -1:
+                                       return None
+                               elif result == -2:
+                                       
self.message(__language__(3028),__language__(3029))
+                                       return None
+                               else:
+                                       return None
+                       items = []
+                       b = busy()
+                       playlists = self.gs.userGetPlaylists(limit=150)
+                       i = 0
+                       while (i < len(playlists)):
+                               items.append(playlists[i][0])
+                               i += 1
+                       b.close()
+                       del b
+                       result = gShowPlaylists(playlists=items,options=[])
+                       action = result[0]
+                       selected = result[1]
+                       if selected != -1:
+                               pId = playlists[selected][1]
+                               n = self.getCurrentListPosition()
+                               songId = songs[n-1][1]
+                               self.gs.playlistAddSong(pId, songId, 0)
        def showOptionsSearch(self, songs, withBrowse = False):
                items = 
[__language__(102),__language__(101),__language__(103),__language__(104), 
__language__(119)]
                if withBrowse == True:
@@ -736,36 +806,43 @@ class GrooveClass(xbmcgui.WindowXML):
                self.playSong(n)
 
        def queueSong(self, song, i = -1):
-               if __isXbox__ == True: #FIXME
+               if __isXbox__ == True:
                        self.nowPlayingList.append(song)
                else:
                        if i < 0:
                                n = self.xbmcPlaylist.size()
                        else:
                                n = i
+                       replace = [{'searchFor':'&','replaceWith':'and'}, 
{'searchFor':'?','replaceWith':''}]
                        songId = song[1]
-                       title = song[0]
+                       title = self.replaceCharacters(song[0], replace)
                        albumId = song[4]
-                       artist = song[6]
-                       album = song[3]
+                       artist = self.replaceCharacters(song[6], replace)
+                       album = self.replaceCharacters(song[3], replace)
                        duration = song[2]
                        imgUrl = song[9] # Medium image
-                       url = 'plugin://%s/?playSong=%s' % (__scriptid__, 
songId) # Adding plugin:// to the url makes xbmc call the script to resolve the 
real url
+                       url = 
'plugin://%s/?playSong=%s&album=%s&title=%s&artist=%s&cover=%s&duration=%s' % 
(__scriptid__, songId, album, title, artist, imgUrl.replace('http://', ''), 
duration) # Adding plugin:// to the url makes xbmc call the script to resolve 
the real url
                        listItem = xbmcgui.ListItem('music', 
thumbnailImage=imgUrl, iconImage=imgUrl)
                        listItem.setProperty( 'Music', "true" )
                        listItem.setProperty('mimetype', 'audio/mpeg')
                        listItem.setProperty('IsPlayable', 'true') # Tell XBMC 
that it is playable and not a folder
-                       listItem.setInfo( type = 'Music', infoLabels = { 
'title': title, 'artist': artist, 'album': album, 'duration': duration} )
+                       listItem.setInfo( type = 'Music', infoLabels = 
{'title': title, 'artist': artist, 'album': album, 'duration': duration})
                        self.xbmcPlaylist.add(url, listitem=listItem, index = 
n)                        
 
        def queueSongs(self, songs, queueFrom = -1):
                if queueFrom < 0:
                        n = self.xbmcPlaylist.size()
                else:
-                       n = queueFrom                   
+                       n = queueFrom
                for i in range(len(songs)):
                        self.queueSong(songs[i], i = i + n)
 
+       def replaceCharacters(self, text, items):
+               newText = text
+               for item in items:
+                       newText = newText.replace(item['searchFor'], 
item['replaceWith'])
+               return newText
+
        def getSimilar(self, songs):
                self.searchText = 'Similar'
                n = self.getCurrentListPosition()
@@ -860,50 +937,48 @@ class GrooveClass(xbmcgui.WindowXML):
                        pass
 
        def getPopular(self):
-               b = busy()
-               try:
-                       self.searchResultSongs = 
self.gs.popularGetSongs(GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(33)
-                       self.searchResultArtists = 
self.gs.popularGetArtists(GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(66)
-                       self.searchResultAlbums = 
self.gs.popularGetAlbums(GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(100)
-                       self.setStateListDown(GrooveClass.STATE_LIST_SEARCH, 
reset = True, folderName = __language__(3041))
-                       b.close()
-                       del b
-                       self.playlistHasFocus()
-               except:
-                       b.close()
-                       del b
-                       self.message(__language__(3012))
-                       traceback.print_exc()
+               lst = []
+               lst.append({'result': [], 'id':id(self.searchResultSongs), 
'function': self.gs.popularGetSongs})
+               lst.append({'result': [], 'id':id(self.searchResultArtists), 
'function': self.gs.popularGetArtists})
+               lst.append({'result': [], 'id':id(self.searchResultAlbums), 
'function': self.gs.popularGetAlbums})
+               self.search(None, lst)
+               for item in lst:
+                       if item['result'] == None:
+                               item['result'] = []
+                               self.message(__language__(3012), 
__language__(3011))
+               self.searchResultSongs = lst[0]['result']
+               self.searchResultArtists = lst[1]['result']
+               self.searchResultAlbums = lst[2]['result']
+               self.setStateListDown(GrooveClass.STATE_LIST_SEARCH, reset = 
True, folderName = __language__(3041))
+               self.playlistHasFocus()
        
-       def searchAll(self, text):
-               self.searchText = text
+       def search(self, text, lst):
                b = busy()
+               searchList = []
+               for item in lst:
+                       f = searchThread(item, text)
+                       searchList.append(f)
+                       f.start()
+               total = len(searchList)
                try:
-                       self.searchResultSongs = self.gs.searchSongs(text, 
GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(25)
-                       self.searchResultArtists = self.gs.searchArtists(text, 
GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(50)
-                       self.searchResultAlbums = self.gs.searchAlbums(text, 
GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(75)
-                       self.searchResultPlaylists = 
self.gs.searchPlaylists(text, GrooveClass.SEARCH_LIMIT)
-                       b.setProgress(100)
-                       xbmc.sleep(500)
-                       b.close()
-                       del b
-                       self.playlistHasFocus()
+                       while len(searchList) > 0:
+                               for i in range(len(searchList)):
+                                       if searchList[i].isAlive() == False:
+                                               searchList.pop(i)
+                                               progress = int(((total - 
len(searchList))*100.0)/float(total))
+                                               b.setProgress(progress)
+                                               break
                except:
-                       b.close()
-                       del b
-                       self.message(__language__(3022), __language__(3011))
                        traceback.print_exc()
-       
+
+               xbmc.sleep(500)
+               b.close()
+               del b
+
        def listSearchResults(self, songs, artists, albums, playlists):
                self.getControl(300011).setVisible(False)
                xbmcgui.lock()
-               path = 
os.path.join(os.getcwd(),'resources','skins','DefaultSkin', 'media', 
'default-cover.png')
+               path = os.path.join(__cwd__,'resources','skins','DefaultSkin', 
'media', 'default-cover.png')
                self.clearList()
                item = xbmcgui.ListItem (label=__language__(3023), 
label2=str(len(songs)) + ' ' + __language__(3026), thumbnailImage=path)         
             
                self.addItem(item)
@@ -919,7 +994,7 @@ class GrooveClass(xbmcgui.WindowXML):
 
        def listSimilar(self, songs, artists):
                xbmcgui.lock()
-               path = 
os.path.join(os.getcwd(),'resources','skins','DefaultSkin', 'media', 
'default-cover.png')
+               path = os.path.join(__cwd__,'resources','skins','DefaultSkin', 
'media', 'default-cover.png')
                self.clearList()
                item = xbmcgui.ListItem (label='..')                    
                self.addItem(item)
@@ -937,13 +1012,6 @@ class GrooveClass(xbmcgui.WindowXML):
                        i = 0
                        self.clearList()
                        self.addItem('..')
-                       items = []
-                       while(i < len(songs)):
-                               items.append([songs[i][4], songs[i][8]])
-                               i += 1
-
-                       if __isXbox__ == True:
-                               self.getThumbs(items)
                        i = 0
                        while(i < len(songs)):
                                if songs[i][2] == -1:
@@ -956,10 +1024,7 @@ class GrooveClass(xbmcgui.WindowXML):
                                        else:
                                                durStr = '(' + str(durMin) + 
':' + str(durSec) + ')'
                                songId = str(songs[i][1])
-                               if __isXbox__ == True:
-                                       path = self.getThumbPath(items[i])
-                               else:
-                                       path = songs[i][8]
+                               path = songs[i][8]
                                l1 = songs[i][0]
                                l2 = songs[i][6] + '\n' + songs[i][3]
                                item = xbmcgui.ListItem (label=l1,label2=l2, 
thumbnailImage=path, iconImage=path)                       
@@ -977,7 +1042,7 @@ class GrooveClass(xbmcgui.WindowXML):
                i = 0
                self.clearList()
                self.addItem('..')
-               path = 
os.path.join(os.getcwd(),'resources','skins','DefaultSkin', 
'media','default-cover.png')
+               path = os.path.join(__cwd__,'resources','skins','DefaultSkin', 
'media','default-cover.png')
                while(i < len(artists)):
                        item = xbmcgui.ListItem (label=artists[i][0], 
thumbnailImage=path)
                        self.addItem(item)
@@ -993,18 +1058,8 @@ class GrooveClass(xbmcgui.WindowXML):
                if len(albums) == 0:
                        return
                i = 0
-               items = []
                while(i < len(albums)):
-                       items.append([albums[i][3], albums[i][4]])
-                       i += 1
-               if __isXbox__ == True:
-                       self.getThumbs(items)
-               i = 0
-               while(i < len(albums)):
-                       if __isXbox__ == True:
-                               path = self.getThumbPath(items[i])
-                       else:
-                               path = albums[i][4]
+                       path = albums[i][4]
                        if withArtist == 0:
                                item = xbmcgui.ListItem (label=albums[i][2], 
thumbnailImage=path, iconImage=path)
                        else:
@@ -1020,7 +1075,7 @@ class GrooveClass(xbmcgui.WindowXML):
                i = 0
                self.clearList()
                self.addItem('..')
-               path = 
os.path.join(os.getcwd(),'resources','skins','DefaultSkin', 
'media','default-cover.png')
+               path = os.path.join(__cwd__,'resources','skins','DefaultSkin', 
'media','default-cover.png')
                while(i < len(playlists)):
                        item = xbmcgui.ListItem (label=playlists[i][1], 
label2=playlists[i][2], thumbnailImage=path)
                        self.addItem(item)
@@ -1148,6 +1203,8 @@ class GrooveClass(xbmcgui.WindowXML):
                        pass
 
        def getNextSongNumber(self):
+               if __settings__.getSetting("xbox_shuffle") == "true":
+                       return random.randint(0, len(self.nowPlayingList)-1)
                n = len(self.nowPlayingList)-1
                if n > 0:
                        if (self.nowPlaying + 1) > n:
@@ -1480,7 +1537,7 @@ class GrooveClass(xbmcgui.WindowXML):
                if os.path.exists(filePath):
                        return filePath
                else:
-                       return 
os.path.join(os.getcwd(),'resources','skins','DefaultSkin' ,'media', 
'default-cover.png')
+                       return 
os.path.join(__cwd__,'resources','skins','DefaultSkin' ,'media', 
'default-cover.png')
 
 
 
diff --git a/script.audio.grooveshark/addon.xml 
b/script.audio.grooveshark/addon.xml
index 2b473e2..44d6cf0 100644
--- a/script.audio.grooveshark/addon.xml
+++ b/script.audio.grooveshark/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="script.audio.grooveshark"
        name="GrooveShark"
-       version="0.2.9"
+       version="0.3.0"
        provider-name="Solver">
   <requires>
     <import addon="xbmc.python" version="1.0"/>
diff --git a/script.audio.grooveshark/changelog.txt 
b/script.audio.grooveshark/changelog.txt
index c2d2cdc..f7a38e0 100644
--- a/script.audio.grooveshark/changelog.txt
+++ b/script.audio.grooveshark/changelog.txt
@@ -1,3 +1,17 @@
+0.3.0:
+
+From this version onward only XBOX and Dharma will be supported.
+
+ - Bug fix: Exit button didn't display correctly.
+
+ - Enhancement: Search function should be much faster.
+
+ - Enhancement: Reduced number of http requests on Dharma.
+
+ - Fixed: Works on Dharma Beta 4.
+
+ - New feature: Shuffle on XBOX. Can be enabled in settings.
+
 0.2.9:
 
  - Fixed: Login works again after changes in the API.
diff --git a/script.audio.grooveshark/default.py 
b/script.audio.grooveshark/default.py
index 439dfc4..4d526bd 100644
--- a/script.audio.grooveshark/default.py
+++ b/script.audio.grooveshark/default.py
@@ -5,9 +5,7 @@ import xbmc
 import xbmcgui
 import traceback
 import threading
-
-sys.path.append(os.path.join(os.getcwd().replace(";",""),'resources','lib'))
-
+from datetime import datetime
 
 class tools(object):
        def __init__(self):
@@ -28,32 +26,40 @@ class tools(object):
                else:
                        return None
 
-BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( os.getcwd(), 
'resources', 'lib' ) )
-sys.path.append (BASE_RESOURCE_PATH)
-
 __scriptid__ = "script.audio.grooveshark"
 __scriptname__ = "GrooveShark"
 __author__ = "Solver"
 __url__ = "http://code.google.com/p/grooveshark-for-xbmc/";
 __svn_url__ = ""
 __credits__ = ""
-__version__ = "0.2.9"
 __XBMC_Revision__ = "31000"
 
-try: #It's post-dharma
+try: #It's an XBOX/pre-dharma
+       __cwd__ = os.getcwd()
+       __settings__ = xbmc.Settings(path=__cwd__)
+       __language__ = xbmc.Language(__cwd__.replace( ";", "" 
)).getLocalizedString
+       __debugging__ = __settings__.getSetting("debug")
+       __isXbox__ = True
+       __version__ = "0.3.0"
+       BASE_RESOURCE_PATH = xbmc.translatePath(os.path.join(__cwd__, 
'resources', 'lib' ))
+       print 'GrooveShark: Initialized as a XBOX plugin'
+
+except: #It's post-dharma
        import xbmcaddon
        __settings__ = xbmcaddon.Addon(id=__scriptid__)
        __language__ = __settings__.getLocalizedString
        __debugging__ = __settings__.getSetting("debug")
        __isXbox__ = False
+       __version__ = __settings__.getAddonInfo('version')
+       BASE_RESOURCE_PATH = 
xbmc.translatePath(os.path.join(__settings__.getAddonInfo('path'), 'resources', 
'lib' ))
+       __cwd__ = __settings__.getAddonInfo('path')
        print 'GrooveShark: Initialized as a post-dharma plugin'
+       traceback.print_exc()
 
-except: #It's an XBOX/pre-dharma
-       __settings__ = xbmc.Settings(path=os.getcwd())
-       __language__ = xbmc.Language(os.getcwd().replace( ";", "" 
)).getLocalizedString
-       __debugging__ = __settings__.getSetting("debug")
-       __isXbox__ = True
-       print 'GrooveShark: Initialized as a XBOX plugin'
+if __isXbox__ == True:
+       __settings__.setSetting("xbox", "true")
+else:
+       __settings__.setSetting("xbox", "false")
 
 if __debugging__ == 'true':
        __debugging__ = True
@@ -62,9 +68,11 @@ else:
        __debugging__ = False
        print 'GrooveShark: Debugging disabled'
 
+sys.path.append(BASE_RESOURCE_PATH)
+
 def startGUI():
        print "GrooveShark version " + str(__version__)
-       w = GrooveClass("grooveshark.xml", os.getcwd(), "DefaultSkin", isXbox = 
__isXbox__)
+       w = GrooveClass("grooveshark.xml", __cwd__, "DefaultSkin", isXbox = 
__isXbox__)
        w.doModal()
        del w
        print 'GrooveShark: Closed'
@@ -87,7 +95,16 @@ else:
                        get = tools.getCmd
                        songId = get('playSong')
                        playlist = get('playlist')
-       
+                       title = get('title')
+                       album = get('album')
+                       artist = get('artist')
+                       cover = 'http://' + get('cover')
+                       duration = get('duration')
+                       try:
+                               duration = int(duration)
+                       except:
+                               duration = 0
+
                        if (playlist != None): # To be implemented...
                                #listitem=xbmcgui.ListItem('Playlists')#, 
iconImage=icon, thumbnailImage=thumbnail )
                                #listitem.addContextMenuItems( cm, 
replaceItems=True )
@@ -100,15 +117,15 @@ else:
                                print 'GrooveShark: Song ID: ' + str(songId)
                                url = gs.getStreamURL(str(songId))
                                if url != "":
-                                       info = gs.songAbout(str(songId))
-                                       
listitem=xbmcgui.ListItem(label=info['songName'], 
iconImage=info['image']['medium'], thumbnailImage=info['image']['medium'], 
path=url);
-                                       listitem.setInfo(type='Music', 
infoLabels = { 'title': info['songName'], 'artist': info['artistName'] , 
'url':url})
+                                       listitem=xbmcgui.ListItem(label=title, 
iconImage=cover, thumbnailImage=cover, path=url);
+                                       listitem.setInfo(type='Music', 
infoLabels = { 'title': title, 'artist': artist , 'url': url, 'duration': 
duration})
+                                       listitem.setProperty('mimetype', 
'audio/mpeg')
                                        
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, 
listitem=listitem)
                                else:
                                        
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, 
listitem=None)
                        else:
                                
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, 
listitem=None)
-                               print 'Unknown command'
+                               print 'GrooveShark: Unknown command'
                except:
                        xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), 
succeeded=False, listitem=None)
                        traceback.print_exc()
diff --git a/script.audio.grooveshark/resources/language/Danish/strings.xml 
b/script.audio.grooveshark/resources/language/Danish/strings.xml
index af85908..5db07f2 100644
--- a/script.audio.grooveshark/resources/language/Danish/strings.xml
+++ b/script.audio.grooveshark/resources/language/Danish/strings.xml
@@ -24,6 +24,7 @@
     <string id="119">Find lignende</string>
     <string id="120">Se denne sangs album</string>
     <string id="121">Afslut</string>
+    <string id="122">Fjern alle sange</string>
 
     <!-- Dialogs -->
     <string id="1000">Indtast en søgning</string>
@@ -36,6 +37,8 @@
     <string id="2000">Brugernavn</string>
     <string id="2001">Password</string>
     <string id="2002">Debugging (Genstart script for at anvende)</string>
+    <string id="2003">XBOX</string>
+    <string id="2004">Shuffle</string>
 
     <!-- Labels -->
     <string id="3000">Start søgning efter sange eller åbn 
spilleliste</string>
diff --git a/script.audio.grooveshark/resources/language/English/strings.xml 
b/script.audio.grooveshark/resources/language/English/strings.xml
index 7be1e7f..7f11872 100644
--- a/script.audio.grooveshark/resources/language/English/strings.xml
+++ b/script.audio.grooveshark/resources/language/English/strings.xml
@@ -24,6 +24,7 @@
     <string id="119">Find similar</string>
     <string id="120">Browse this songs album</string>
     <string id="121">Exit</string>
+    <string id="122">Remove all songs</string>
 
     <!-- Dialogs -->
     <string id="1000">Enter a search phrase</string>
@@ -36,6 +37,8 @@
     <string id="2000">Username</string>
     <string id="2001">Password</string>
     <string id="2002">Debugging (restart script to apply)</string>
+    <string id="2003">XBOX</string>
+    <string id="2004">Shuffle</string>
 
     <!-- Labels -->
     <string id="3000">Start searching for songs or load a playlist</string>
diff --git a/script.audio.grooveshark/resources/lib/GrooveAPI.py 
b/script.audio.grooveshark/resources/lib/GrooveAPI.py
index 06fa04d..db214cd 100644
--- a/script.audio.grooveshark/resources/lib/GrooveAPI.py
+++ b/script.audio.grooveshark/resources/lib/GrooveAPI.py
@@ -2,6 +2,7 @@ import urllib2, md5, unicodedata, re, os, traceback, sys, 
pickle, socket, string
 from operator import itemgetter, attrgetter
 
 __scriptid__ = sys.modules[ "__main__" ].__scriptid__
+__cwd__ = sys.modules[ "__main__" ].__cwd__
 
 class LoginTokensExceededError(Exception):
        def __init__(self):
@@ -43,7 +44,7 @@ class GrooveAPI:
                self.frowns = []
                self.songIDsAlreadySeen = []
                self.recentArtists = []
-               self.rootDir = os.getcwd()
+               self.rootDir = __cwd__
                if self.isXbox == True:
                        self.dataDir = 'script_data'
                else:
@@ -51,8 +52,8 @@ class GrooveAPI:
                self.confDir = os.path.join('special://profile/', self.dataDir, 
__scriptid__)
                self.sessionID = self.getSavedSession()
                self.debug('Saved sessionID: ' + self.sessionID)
-               self.sessionID = self.getSessionFromAPI()
-               self.debug('API sessionID: ' + self.sessionID)
+               #self.sessionID = self.getSessionFromAPI()
+               #self.debug('API sessionID: ' + self.sessionID)
                if self.sessionID == '':
                        self.sessionID = self.startSession()
                        self.debug('Start() sessionID: ' + self.sessionID)
@@ -78,7 +79,6 @@ class GrooveAPI:
        def getSavedSession(self):
                sessionID = ''
                path = os.path.join(self.confDir, 'session', 'session.txt')
-
                try:
                        f = open(path, 'rb')
                        sessionID = pickle.load(f)
@@ -89,7 +89,7 @@ class GrooveAPI:
                
                return sessionID
 
-       def saveSession(self):                  
+       def saveSession(self):
                try:
                        dir = os.path.join(self.confDir, 'session')
                        # Create the 'data' directory if it doesn't exist.
@@ -145,6 +145,15 @@ class GrooveAPI:
                        result = self.simplejson.loads(result)
                        if 'fault' in result:
                                self.debug(result)
+                               if result['fault']['code'] == 8: #Session ID 
has expired. Get a new and try again if possible.
+                                       self.debug(result['fault']['message'])
+                                       self.sessionID = self.startSession()
+                                       if self.sessionID != '':
+                                               self.saveSession()
+                                               return self.callRemote(method, 
params)
+                                       else:
+                                               self.debug('SessionID expired, 
but unable to get new')
+                                               return []
                        return result
                except:
                        return []
@@ -326,7 +335,6 @@ class GrooveAPI:
                        
        def playlistReplace(self, playlistId, songIds):
                if self.loggedIn == 1:
-                       print "######## Logged in"
                        result = self.callRemote("playlist.replace", 
{"playlistID": playlistId, "songIDs": songIds})
                        if 'fault' in result:
                                return 0
diff --git a/script.audio.grooveshark/resources/settings.xml 
b/script.audio.grooveshark/resources/settings.xml
index 474acc7..e9cc464 100644
--- a/script.audio.grooveshark/resources/settings.xml
+++ b/script.audio.grooveshark/resources/settings.xml
@@ -3,5 +3,8 @@
        <setting id="username" type="text" label="2000" default="" />

        <setting id="password" type="text" option="hidden" label="2001" 
enable="!eq(-1,)" default="" />

        <setting type="sep" />

+       <setting id="xbox" type="bool" label="2003" default="false" 
visible="false"/>

+       <setting id="xbox_shuffle" type="bool" label="2004" default="false" 
visible="eq(-1,true)"/>

+       <setting type="sep" />

        <setting id="debug" type="bool" label="2002" default="false" />

 </settings>

diff --git 
a/script.audio.grooveshark/resources/skins/DefaultSkin/720p/grooveshark.xml 
b/script.audio.grooveshark/resources/skins/DefaultSkin/720p/grooveshark.xml
index 0e08afc..24232e6 100644
--- a/script.audio.grooveshark/resources/skins/DefaultSkin/720p/grooveshark.xml
+++ b/script.audio.grooveshark/resources/skins/DefaultSkin/720p/grooveshark.xml
@@ -628,7 +628,7 @@
                                <align>center</align>

                                <aligny>center</aligny>                         
        

                                <onup>1006</onup>

-                               <ondown>1001</ondown>   

+                               <ondown>1007</ondown>   

                                <onleft>205</onleft>

                                <onright>205</onright>

                                <font>font12</font>

diff --git 
a/script.audio.grooveshark/resources/skins/DefaultSkin/PAL/grooveshark.xml 
b/script.audio.grooveshark/resources/skins/DefaultSkin/PAL/grooveshark.xml
index d3920e6..042f1fa 100644
--- a/script.audio.grooveshark/resources/skins/DefaultSkin/PAL/grooveshark.xml
+++ b/script.audio.grooveshark/resources/skins/DefaultSkin/PAL/grooveshark.xml
@@ -488,7 +488,7 @@
                                <description>Background for menu</description>

                                <posx>0</posx>

                                <posy>0</posy>

-                               <height>240</height>

+                               <height>275</height>

                                <width>220</width>

                                <texture>gs-bg-leftmenu.png</texture>   

                                <visible>true </visible>                        

@@ -500,7 +500,7 @@
                                <description>Vertical label</description>

                                <width>100</width>                      

                                <posx>60</posx>

-                               <posy>95</posy>

+                               <posy>110</posy>

                                <align>center</align>

                                <aligny>center</aligny>

                                <label>MENU</label>

@@ -524,7 +524,7 @@
                                <textoffsetx>0</textoffsetx>

                                <align>center</align>

                                <aligny>center</aligny>                         
        

-                               <onup>1005</onup>

+                               <onup>1007</onup>

                                <ondown>1002</ondown>   

                                <onleft>205</onleft>

                                <onright>205</onright>

@@ -625,6 +625,26 @@
                                <align>center</align>

                                <aligny>center</aligny>                         
        

                                <onup>1006</onup>

+                               <ondown>1007</ondown>   

+                               <onleft>205</onleft>

+                               <onright>205</onright>

+                               <font>font12</font>

+                       </control>

+                       <control type="button" id="1007">

+                               <description>Exit button</description>          
                

+                               <posx>0</posx>  

+                               <posy>210</posy>

+                               <width>110</width>

+                               <height>30</height>

+                               <label>$LOCALIZE[SCRIPT121]</label>             

+                               <texturefocus>button_focus.png</texturefocus>

+                               <texturenofocus></texturenofocus>

+                               <textcolor>ffffffff</textcolor>

+                               <disabledcolor>60ffffff</disabledcolor>

+                               <textoffsetx>0</textoffsetx>

+                               <align>center</align>

+                               <aligny>center</aligny>                         
        

+                               <onup>1005</onup>

                                <ondown>1001</ondown>   

                                <onleft>205</onleft>

                                <onright>205</onright>


-----------------------------------------------------------------------

Summary of changes:
 script.audio.grooveshark/GrooveShark.py            |  221 ++++++++++++-------
 script.audio.grooveshark/addon.xml                 |    2 +-
 script.audio.grooveshark/changelog.txt             |   14 ++
 script.audio.grooveshark/default.py                |   57 ++++--
 .../resources/language/Danish/strings.xml          |    3 +
 .../resources/language/English/strings.xml         |    3 +
 .../resources/lib/GrooveAPI.py                     |   20 ++-
 script.audio.grooveshark/resources/settings.xml    |    3 +
 .../skins/DefaultSkin/720p/grooveshark.xml         |    2 +-
 .../skins/DefaultSkin/PAL/grooveshark.xml          |   26 ++-
 10 files changed, 238 insertions(+), 113 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to