Jump to content

Recommended Posts

FOR EDUCATIONAL USE ONLY

DOES NOT WORK, I AM WORKING HARD ON A NEW VERSION, ALSO THANK GROOVESHARK FOR THIS NOT ME, THEY CHANGED THE API, (enough screaming :))

Write now you can search, download and change save location...

For the gui there is no EXE link (if you want one I can upload one just ask.)

Python Link

Instructions

1. Download

2. Double Click the file and unzip

3. Run Grooveshark Gui.py

4. Enjoy and please report any errors

Python Files

Instructions

1. Download http://download830.mediafire.com/9swx9hdam.../Grooveshark.7z

2. Extract

3. Open a terminal and navigate to the extract folder

4. Run python "Grooveshark.py"

Thank Yous

-Psychosis for helping me find errors in the application and reporting them :-)

-ZigZagJoe for his work in PandoraSaver2 (a great app!) and his help and inspiration :-)

How to run from python source

1. Download http://download830.mediafire.com/9swx9hdam.../Grooveshark.7z

2. Extract

3. Install Python (step 4 bellow)

--Installing Python--

If you already have python you can skip this step.

- To find out if you have python, open a Terminal, then type python at the prompt... If there are no errors you have python... otherwise you have to install it.

Download from python.org/download

-WINDOWS http://www.python.org/ftp/python/2.6.4/python-2.6.4.msi

-MAC http://www.python.org/ftp/python/2.6.4/pyt..._macosx10.3.dmg

-LINUX If not already installed or version not working get it through package manager (probably called python or python2.6 or some variant)

Note: Mac OS X and most linux distros already have python just type python then the file with the fronted code at the terminal

4. Install httplib2 (step 5 bellow)

--Install httplib2--

httplib2 which can be downloaded from http://httplib2.googlecode.com/files/httplib2-0.5.0.zip

--unzip

--go into directory and run python setup.py build then setup.py install

5. Install wxPython from wxpython.org/download.php

6. Open a terminal and navigate to the extract folder

7. Run python "Grooveshark Gui.py"

Current Source Code (Old Code below in Old Versions Section)

http://download838.mediafire.com/l5m1wleem...distrobution.7z

Old Versions

URL was http://download774.mediafire.com/azdy55ssd...jnywno/dist.exe

Source: http://download830.mediafire.com/9swx9hdam...eshark.7z"]http://download830.mediafire.com/9swx9hdam.../Grooveshark.7z

URL was http://download781.mediafire.com/vt151bb5t...rooveshark3.exe

---------Fixes in version 0.4----------

1. JSON/ HTTP Request Error

--Front End--

#!/usr/bin/python
import time
import sys
import os
from Grooveshark import Grooveshark
#instance of Grooveshark
g = Grooveshark()
class Menu(object):
    def __init__(self, path):
        self.path = path
        print 'Getting Session Data'
        g.sessionData()
        print '''\
            WARNING THIS IS AN ALPHA VERSION
            EXPECT LOTS OF ERRORS AND PROBLEMS
            IF YOU DO CHOOSE TO USE THIS\n\n
            ---------------------------------
             Welcome to Grooveshark Explorer'''
    def MainMenu(self):
        print '''\n        MAIN  MENU\n        ---------------------------\n       Please pick what you want to do:
        1) Search for a song - Option to Download
        2) See top 100 songs on Grooveshark
        3) Change Save Location (Right now it is %s)
        4) Exit
    .........................................''' % self.path  
        choice = '0000'
        choice = raw_input(':')
        if len(choice) < 1:
            self.MainMenu()
        elif choice[0].lower() == '1':
            search_string = ''
            search_string = raw_input('Search for: ')
            search_string = search_string.replace('"', '')
            try:
                g.search(search_string)
            except:
                print 'There was an error with you search... sorry'
                print g.response
                o = open('C://loggrooveshark.txt', 'wb')
                o.write(g.result)
                o.close()
                self.MainMenu()
            #Display Search Reults
            if len(g.searchResults) > 0:
                print '====Song Names===='
                for n,i in enumerate(g.searchResults):
                    try:
                        print '%i.\t%s' % (n+1, i['Name'])
                    except UnicodeEncodeError:
                        print '%i.\t%s' % (n+1, repr(i['Name'])[2:-1])
            else:
                print 'No Songs Found'
                self.MainMenu()
            #Ask Which Song to Select
            selection = 'default'
            selection = raw_input('Which Song to select (Menu to go back to Menu) : ')
            if selection.lower() == 'menu':
                self.MainMenu()
            print 'You chose %s ' % selection
            songName = g.searchResults[int(selection)-1]['Name']
            songID = g.searchResults[int(selection)-1]['SongID']
            g.songKeyfromID(songID)
            print 'Downloading Song... This may take long but it is working'
            print 'Once the song is done downloading... You will see "Writing to file." There will not be a progress bar during download, sorry :('
            g.downloadSong()
            print 'Writing to file...'
            songFile = open(self.path+songName+'.mp3', 'wb')
            songFile.write(g.song)
            songFile.close()
            writeCheck = open(self.path+songName+'.mp3', 'rb')
            write = writeCheck.read()
            writeCheck.close()
            print 'Returns True if write was succesful... ' + str(write == g.song)
            print 'Saved Song located at %s' % self.path+songName+'.mp3'
            self.MainMenu()
        elif choice[0].lower() == '2':
            print 'Not Implemented'
            time.sleep(1)
            self.MainMenu()
        elif choice[0].lower() == '3':
            print 'Change Save Location, Need Full self.path'
            print 'I think MacOSX/Linux Work, BUT I AM NOT SURE (Please report your findings :))'
            print ''
            self.path = raw_input('New self.path: ')
            if not os.path.exists(self.path):
                print 'Error Bad self.path'
                self.path = 'C:/'
                self.MainMenu()
            else:
                self.path = self.path.replace('\\', '/')
                if not self.path[-1] == '/':
                    self.path = self.path + '/'
                print 'self.path Changed'
                print 'self.path is %s' % self.path
                self.MainMenu()
        elif choice[0].lower() == '4':
            print 'Exiting...'
            time.sleep(1)
            sys.exit()
        else:
            print 'Invalid Choice!'
            self.MainMenu()

def legal_warning():
    print 'LOADING...'
    print '>>>'
    print 'THIS APPLICATION DOES NOT COME WITH ANY WARRANT, WHATSOEVER. THIS APPLICATION DOES NOT MAKE ANY WARRANTY ABOUT THE USEFULLNESS OR WORKING ORDER OF THIS APPLICATION THIS IS NOT TO DOWNLOAD COPYRIGHT WORKS... THIS APPLICATION IS STRICKLY MEANT ONLY FOR TIMESHIFTING PURPOSES! IN SOME COUNTRIES THIS APPLICATION MAY BE ILLEGAL, IF YOU ARE UNSURE CONTACT LEGAL ADVICE. NEITHER THE AUTHOR OR ANY OTHER PARTY RELATED TO THIS APPLICATION IS RESPONSIBLE FOR YOU MISUSE AND/OR ILLEGAL USEAGE!'
    print ''
    if not raw_input('Do you agree? y/n ')[0].lower() == 'y':
        sys.exit()
if __name__ == '__main__':
    legal_warning()
    m = Menu('C:/')
    m.MainMenu()

--Back End--

import time
import sys
import uuid
import hashlib
import urllib
try:
    import json
except ImportError:
    print 'JSON import failed'
    try:
        import simplejson as json
    except ImportError:
        print 'Can not import simplejson... CLOSING'
        time.sleep(3)
        sys.exit()
#Third Pary Libaries
import BeautifulSoup
import httplib2#Need version 5 or higher for python 2.6 compatability 

#This is a default header that can be used if you just need a user agent change (this way not every function/method has to define this)
header = {}
header['user-agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)'

class Grooveshark(object):
    def __init__(self):
        self.search_url = 'http://cowbell.grooveshark.com/more.php?getSearchResults'
    def search(self, search_string):
        http = httplib2.Http()
        data = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09","token":"%s"},'''
        '''"parameters":{"type":"Songs","query":"%s"},"method":"getSearchResults"}''' % (self.session, self.uuid, self.token, search_string.lower()))
        self.response, self.result = http.request(self.search_url, 'POST', headers = header, body = data)
        self.result = self.result
        self.searchResults = json.loads(self.result)['result']['Return']
        return self.searchResults
    def sessionData(self):
        self.session = self.getSessionID()
        self.uuid = self.getUID()
        self.token = self.getToken()

    def songKeyfromID(self, id):
        http = httplib2.Http()
        self.songID = id
        songKeyURL = '  http://cowbell.grooveshark.com/more.php?ge...FromSongID'
        songKeyPOSTdata = ('''{"header":{"token":"%s","session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
        '''"parameters":{"songID":%s,"prefetch":false},"method":"getStreamKeyFromSongID"}''' % (self.token, self.session, self.uuid, self.songID))
        request, reply = http.request(songKeyURL, 'POST', headers = header, body = songKeyPOSTdata)
        self.reply = json.loads(reply)['result']
        self.songKey = self.reply['result']['streamKey']
        return self.songKey
    def downloadSong(self):
        http = httplib2.Http()
        self.mp3URL = 'http://'+self.reply['result']['streamServer']+'/stream.php'#use self. so that any outer program can access it (not local)
        data = {}
        data['streamKey'] = self.songKeyfromID(self.songID)
        songHeader = header
        songHeader['content-length'] = str(len(urllib.urlencode(data)))
        songHeader['content-type'] = 'application/x-www-form-urlencoded'
        self.response, self.song = http.request(self.mp3URL, 'POST', headers = header, body = urllib.urlencode(data))
        return self.song
    def getToken(self):
        http = httplib2.Http()
        url = 'https://cowbell.grooveshark.com/service.php'
        self.secretKey = hashlib.md5(self.session).hexdigest()
        tokenPOSTdata = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
        '''"parameters":{"secretKey":"%s"},"method":"getCommunicationToken"}''' % (self.session, self.uuid, self.secretKey))
        request, reply = http.request(url, 'POST', headers = header, body = tokenPOSTdata)
        return json.loads(reply)['result']

    def getUID(self):
        return uuid.uuid4()

    def getSessionID(self):
        http = httplib2.Http()
        url = 'http://listen.grooveshark.com'
        response, src = http.request(url, 'GET', headers = header)
        src = src.lower().replace(' ', '')
        start = src.find('session')
        end = src[start:].find("',")
        startSession =  src[start:end+start].find("'") +1
        return src[startSession+start:end+start]

URL was http://download734.mediafire.com/rmhbuo2hl...rk2+Updated.exe

Version 0.2 and 0.3 (See Minor Code Changes)

Minor Code Changes

Note on the line bellow search_string = raw_input('Search For:') I added search_string = search_string.replace('"', '') to fix a minor problem.... I felt this fix did not deserve a addition to old code and a full change (though the EXE has been updated)

1. Do note that before this error was fixed the url was EXE URL

Front End

#!/usr/bin/python
import time
import sys
import os
from Grooveshark import Grooveshark
#instance of Grooveshark
g = Grooveshark()
class Menu(object):
	def __init__(self, path):
		self.path = path
		print 'Getting Session Data'
		g.sessionData()
		print '''\
			WARNING THIS IS AN ALPHA VERSION
			EXPECT LOTS OF ERRORS AND PROBLEMS
			IF YOU DO CHOOSE TO USE THIS\n\n
			---------------------------------
			 Welcome to Grooveshark Explorer'''
	def MainMenu(self):
		print '''\n		MAIN  MENU\n		---------------------------\n	   Please pick what you want to do:
		1) Search for a song - Option to Download
		2) See top 100 songs on Grooveshark
		3) Change Save Location (Right now it is %s)
		4) Exit
	.........................................''' % self.path  
		choice = '0000'
		choice = raw_input(':')
		if len(choice) < 1:
			self.MainMenu()
		elif choice[0].lower() == '1':
			search_string = ''
			search_string = raw_input('Search for: ')
			g.search(search_string)
			#Display Search Reults
			if len(g.searchResults) > 0:
				print '====Song Names===='
				for n,i in enumerate(g.searchResults):
					try:
						print '%i.\t%s' % (n+1, i['Name'])
					except UnicodeEncodeError:
						print '%i.\t%s' % (n+1, repr(i['Name'])[2:-1])
			else:
				print 'No Songs Found'
				self.MainMenu()
			#Ask Which Song to Select
			selection = 'default'
			selection = raw_input('Which Song to select (Menu to go back to Menu) : ')
			if selection.lower() == 'menu':
				self.MainMenu()
			print 'You chose %s ' % selection
			songName = g.searchResults[int(selection[0])-1]['Name']
			songID = g.searchResults[int(selection[0])-1]['SongID']
			g.songKeyfromID(songID)
			print 'Downloading Song... This may take long but it is working'
			print 'Once the song is done downloading... You will see "Writing to file." There will not be a progress bar during download, sorry :('
			g.downloadSong()
			print 'Writing to file...'
			songFile = open(self.path+songName+'.mp3', 'wb')
			songFile.write(g.song)
			songFile.close()
			writeCheck = open(self.path+songName+'.mp3', 'rb')
			write = writeCheck.read()
			print 'Returns True if write was succesful... ' + str(write == g.song)
			print 'Saved Song located at %s' % self.path+songName+'.mp3'
			self.MainMenu()
		elif choice[0].lower() == '2':
			print 'Not Implemented'
			time.sleep(1)
			self.MainMenu()
		elif choice[0].lower() == '3':
			print 'Change Save Location, Need Full self.path'
			print 'I think MacOSX/Linux Work, BUT I AM NOT SURE (Please report your findings :))'
			print ''
			self.path = raw_input('New self.path: ')
			if not os.path.exists(self.path):
				print 'Error Bad self.path'
				self.path = 'C:/'
				self.MainMenu()
			else:
				self.path = self.path.replace('\\', '/')
				if not self.path[-1] == '/':
					self.path = self.path + '/'
				print 'self.path Changed'
				print 'self.path is %s' % self.path
				self.MainMenu()
		elif choice[0].lower() == '4':
			print 'Exiting...'
			time.sleep(1)
			sys.exit()
		else:
			print 'Invalid Choice!'
			self.MainMenu()

def legal_warning():
	print 'LOADING...'
	print '>>>'
	print 'THIS APPLICATION DOES NOT COME WITH ANY WARRANT, WHATSOEVER. THIS APPLICATION DOES NOT MAKE ANY WARRANTY ABOUT THE USEFULLNESS OR WORKING ORDER OF THIS APPLICATION THIS IS NOT TO DOWNLOAD COPYRIGHT WORKS... THIS APPLICATION IS STRICKLY MEANT ONLY FOR TIMESHIFTING PURPOSES! IN SOME COUNTRIES THIS APPLICATION MAY BE ILLEGAL, IF YOU ARE UNSURE CONTACT LEGAL ADVICE. NEITHER THE AUTHOR OR ANY OTHER PARTY RELATED TO THIS APPLICATION IS RESPONSIBLE FOR YOU MISUSE AND/OR ILLEGAL USEAGE!'
	print ''
	if not raw_input('Do you agree? y/n ')[0].lower() == 'y':
		sys.exit()
if __name__ == '__main__':
	legal_warning()
	m = Menu('C:/')
	m.MainMenu()

Back End

import time
import sys
import uuid
import hashlib
import urllib
try:
	import json
except ImportError:
	print 'JSON import failed'
	try:
		import simplejson as json
	except ImportError:
		print 'Can not import simplejson... CLOSING'
		time.sleep(3)
		sys.exit()
#Third Pary Libaries
import BeautifulSoup
import httplib2#Need version 5 or higher for python 2.6 compatability 

#This is a default header that can be used if you just need a user agent change (this way not every function/method has to define this)
header = {}
header['user-agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)'

class Grooveshark(object):
	def __init__(self):
		self.search_url = 'http://cowbell.grooveshark.com/more.php?getSearchResults'
	def search(self, search_string):
		http = httplib2.Http()
		data = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09","token":"%s"},'''
		'''"parameters":{"type":"Songs","query":"%s"},"method":"getSearchResults"}''' % (self.session, self.uuid, self.token, search_string.lower()))
		response, result = http.request(self.search_url, 'POST', headers = header, body = data)
		self.searchResults = json.loads(result)['result']['Return']
		return self.searchResults
	def sessionData(self):
		self.session = self.getSessionID()
		self.uuid = self.getUID()
		self.token = self.getToken()

	def songKeyfromID(self, id):
		http = httplib2.Http()
		self.songID = id
		songKeyURL = '  http://cowbell.grooveshark.com/more.php?ge...FromSongID'
		songKeyPOSTdata = ('''{"header":{"token":"%s","session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
		'''"parameters":{"songID":%s,"prefetch":false},"method":"getStreamKeyFromSongID"}''' % (self.token, self.session, self.uuid, self.songID))
		request, reply = http.request(songKeyURL, 'POST', headers = header, body = songKeyPOSTdata)
		self.reply = json.loads(reply)['result']
		self.songKey = self.reply['result']['streamKey']
		return self.songKey
	def downloadSong(self):
		http = httplib2.Http()
		self.mp3URL = 'http://'+self.reply['result']['streamServer']+'/stream.php'#use self. so that any outer program can access it (not local)
		data = {}
		data['streamKey'] = self.songKeyfromID(self.songID)
		songHeader = header
		songHeader['content-length'] = str(len(urllib.urlencode(data)))
		songHeader['content-type'] = 'application/x-www-form-urlencoded'
		self.response, self.song = http.request(self.mp3URL, 'POST', headers = header, body = urllib.urlencode(data))
		return self.song
	def getToken(self):
		http = httplib2.Http()
		url = 'https://cowbell.grooveshark.com/service.php'
		self.secretKey = hashlib.md5(self.session).hexdigest()
		tokenPOSTdata = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
		'''"parameters":{"secretKey":"%s"},"method":"getCommunicationToken"}''' % (self.session, self.uuid, self.secretKey))
		request, reply = http.request(url, 'POST', headers = header, body = tokenPOSTdata)
		return json.loads(reply)['result']

	def getUID(self):
		return uuid.uuid4()

	def getSessionID(self):
		http = httplib2.Http()
		url = 'http://listen.grooveshark.com'
		response, src = http.request(url, 'GET', headers = header)
		src = src.lower().replace(' ', '')
		start = src.find('session')
		end = src[start:].find("',")
		startSession =  src[start:end+start].find("'") +1
		return src[startSession+start:end+start]

===============================================================

===============================================================

===============================================================

URL: http://download684.mediafire.com/bdmtqd1tn...Grooveshark.exe

Version 0.1

---Front End---

#!/usr/bin/python
import time
import sys
import os
from Grooveshark import Grooveshark
#instance of Grooveshark
g = Grooveshark()
def MainMenu():
	print 'Getting Session Data'
	g.sessionData()
	print '''\
		WARNING THIS IS AN ALPHA VERSION
		EXPECT LOTS OF ERRORS AND PROBLEMS
		IF YOU DO CHOOSE TO USE THIS
		 Welcome to Grooveshark Explorer
	Please pick what you want to do:
	1) Search for a song - Option to Download
	2) See top 100 songs on Grooveshark
	3) Change Save Location (Default is C:\)
	4) Exit
.........................................
'''
	path = 'C:/'
	choice = '0000'
	choice = raw_input(':')
	if choice[0].lower() == '1':
		search_string = raw_input('Search for: ')
		g.search(search_string)
		#Display Search Reults
		if len(g.searchResults) > 0:
			print '====Song Names===='
			for n,i in enumerate(g.searchResults):
				try:
					print '%i.\t%s' % (n+1, i['Name'])
				except UnicodeEncodeError:
					print '%i.\t%s' % (n+1, repr(i['Name'])[2:-1])
		else:
			print 'No Songs Found'
			MainMenu()
		#Ask Which Song to Select
		selection = raw_input('Which Song to select (Menu to go back to Menu): ')
		if selection.lower() == 'menu':
			MainMenu()
		songName = g.searchResults[int(selection[0])-1]['Name']
		songID = g.searchResults[int(selection[0])-1]['SongID']
		g.songKeyfromID(songID)
		print 'Downloading Song... This may take long but it is working'
		print 'Once the song is done downloading... You will see "Writing to file." There will not be a progress bar during download, sorry :('
		g.downloadSong()
		print 'Writing to file...'
		songFile = open(path+songName+'.mp3', 'wb')
		songFile.write(g.song)
		songFile.close()
		writeCheck = open(path+songName+'.mp3', 'rb')
		write = writeCheck.read()
		print 'Returns True if write was succesful... ' + str(write == g.song)
		print 'Saved Song located at %s' % path+songName+'.mp3'
	elif choice[0].lower() == '2':
		print 'Not Implemented'
		time.sleep(1)
		MainMenu()
	elif choice[0].lower() == '3':
		print 'Change Save Location, Need Full path'
		print 'I think MacOSX/Linux Work, BUT I AM NOT SURE (Please report your findings :))'
		print ''
		path = raw_input('New Path: ')
		if not os.path.exists(path):
			print 'Error Bad Path'
			path = 'C:/'
		else:
			path = path.replace('\\', '/')
			if not path[-1] == '/':
				path = path + '/'
			print 'Path Changed'
			print 'path is %s' % path
			MainMenu()
	elif choice[0].lower() == '4':
		print 'Exiting...'
		time.sleep(1)
		sys.exit()
	else:
		print 'Invalid Choice!'
		MainMenu()
def legal_warning():
	print 'LOADING...'
	print '>>>'
	print 'THIS APPLICATION DOES NOT COME WITH ANY WARRANT, WHATSOEVER.'
	print 'THIS APPLICATION DOES NOT MAKE ANY WARRANTY ABOUT THE USEFULLNESS OR WORKING ORDER OF THIS APPLICATION'
	print 'THIS IS NOT TO DOWNLOAD COPYRIGHT WORKS... THIS APPLICATION IS STRICKLY MEANT ONLY FOR TIMESHIFTING PURPOSES!'
	print 'IN SOME COUNTRIES THIS APPLICATION MAY BE ILLEGAL, IF YOU ARE UNSURE CONTACT LEGAL ADVICE.'
	print 'NEITHER THE AUTHOR OR ANY OTHER PARTY RELATED TO THIS APPLICATION IS RESPONSIBLE FOR YOU MISUSE AND/OR ILLEGAL USEAGE!'
	print ''
	if not raw_input('Do you agree? y/n ')[0].lower() == 'y':
		sys.exit()
if __name__ == '__main__':
	legal_warning()
	MainMenu()

---Back end---

import time
import sys
import uuid
import hashlib
import urllib
try:
	import json
except ImportError:
	print 'JSON import failed'
	try:
		import simplejson as json
	except ImportError:
		print 'Can not import simplejson... CLOSING'
		time.sleep(3)
		sys.exit()
#Third Pary Libaries
import BeautifulSoup
import httplib2#Need version 5 or higher for python 2.6 compatability 

#Intialize variables 
http = httplib2.Http()
http.timeout = None
#This is a default header that can be used if you just need a user agent change (this way not every function/method has to define this)
header = {}
header['user-agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)'

class Grooveshark(object):
	def __init__(self):
		self.search_url = 'http://cowbell.grooveshark.com/more.php?getSearchResults'
	def search(self, search_string):
		data = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09","token":"%s"},'''
		'''"parameters":{"type":"Songs","query":"%s"},"method":"getSearchResults"}''' % (self.session, self.uuid, self.token, search_string.lower()))
		self.searchResponse, searchResult_ = http.request(self.search_url, 'POST', headers = header, body = data)
		self.searchResults = json.loads(searchResult_)['result']['Return']

	def sessionData(self):
		self.session = self.getSessionID()
		self.uuid = self.getUID()
		self.token = self.getToken()

	def songKeyfromID(self, id):
		self.songID = id
		songKeyURL = '  http://cowbell.grooveshark.com/more.php?ge...FromSongID'
		songKeyPOSTdata = ('''{"header":{"token":"%s","session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
		'''"parameters":{"songID":%s,"prefetch":false},"method":"getStreamKeyFromSongID"}''' % (self.token, self.session, self.uuid, self.songID))
		request, reply = http.request(songKeyURL, 'POST', headers = header, body = songKeyPOSTdata)
		self.reply = json.loads(reply)['result']
		self.songKey = self.reply['result']['streamKey']
	def downloadSong(self):
		mp3URL = 'http://'+self.reply['result']['streamServer']+'/stream.php'
		print 'Downloading Song....'
		print mp3URL
		data = {}
		data['streamKey'] = self.songKey
		songHeader = header
		songHeader['content-length'] = str(len(urllib.urlencode(data)))
		songHeader['content-type'] = 'application/x-www-form-urlencoded'
		self.response, self.song = http.request(mp3URL, 'POST', headers = header, body = urllib.urlencode(data))
	def getToken(self):
		url = 'https://cowbell.grooveshark.com/service.php'
		self.secretKey = hashlib.md5(self.session).hexdigest()
		tokenPOSTdata = ('''{"header":{"session":"%s","uuid":"%s","client":"gslite","clientRevision":"20091027.09"},'''
		'''"parameters":{"secretKey":"%s"},"method":"getCommunicationToken"}''' % (self.session, self.uuid, self.secretKey))
		request, reply = http.request(url, 'POST', headers = header, body = tokenPOSTdata)
		return json.loads(reply)['result']

	def getUID(self):
		return uuid.uuid4()

	def getSessionID(self):
		url = 'http://listen.grooveshark.com'
		response, src = http.request(url, 'GET', headers = header)
		src_ = src.lower().replace(' ', '')
		start = src_.find('session')
		end = src_[start:].find("',")
		startSession =  src_[start:end+start].find("'") +1
		return src_[startSession+start:end+start]

Edited by Zimmer
Link to post
Share on other sites
  • Replies 199
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

MERGED WITH TOP POST ---- Old Post Bellow for referance

How to run from python source

ok there is a little problem with getting the exe so for know you need

save the front end code with any name then save the backend code with the name Grooveshark.py to the same directory

python from python.org/download

-WINDOWS http://www.python.org/ftp/python/2.6.4/python-2.6.4.msi

-MAC http://www.python.org/ftp/python/2.6.4/pyt..._macosx10.3.dmg

-LINUX If not already installed or version not working get it through package manager (probably called python or python2.6 or some variant)

Note: Mac OS X and most linux distros already have python just type python then the file with the fronted code at the terminal

and httplib2 which can be downloaded from http://httplib2.googlecode.com/files/httplib2-0.5.0.zip

--unzip

-- go into directory and run python setup.py build then setup.py install

Then to run python (path and file of front end code) in the terminal

Link to post
Share on other sites

I'm using the EXE.

I ran it, selected option 3, and changed the output to C:\Users\Psychosis\Desktop

I then tried to donwload a song, and...

Downloading Song... This may take long but it is working

Once the song is done downloading... You will see "Writing to file." There will

not be a progress bar during download, sorry :(

Downloading Song....

http://stream2.grooveshark.com/stream.php

Writing to file...

Traceback (most recent call last):

File "Command Line App Grooveshark.py", line 97, in <module>

File "Command Line App Grooveshark.py", line 76, in MainMenu

File "Command Line App Grooveshark.py", line 51, in MainMenu

IOError: [Errno 13] Permission denied: u'C:/<songname>.mp3'

Looks like it isn't saving the output directory.

Link to post
Share on other sites

Another bug: If you search for something containing quotes:

Search for: "Hupp Cossack!"

Traceback (most recent call last):

File "Command Line App Grooveshark.py", line 97, in <module>

File "Command Line App Grooveshark.py", line 28, in MainMenu

File "Grooveshark.pyo", line 34, in search

File "json\__init__.pyo", line 307, in loads

File "json\decoder.pyo", line 319, in decode

File "json\decoder.pyo", line 338, in raw_decode

ValueError: No JSON object could be decoded

Link to post
Share on other sites

The app doesn't close the saved file until the application closes, so I can't move the saved file whilst the downloader is still opened.

Also, if I select a song >= 10 on the list, it only takes the first digit of my choice.

Link to post
Share on other sites

Hi,

I am very interested in using this application under Linux. I have python installed, but when I cut and paste your code from your post all the indentation goes away. I suppose I could try and figure out where all the indents go... but it would be cool if you could post your .py files on the ftp server as well. Thanks!

Link to post
Share on other sites
Hi,

I am very interested in using this application under Linux. I have python installed, but when I cut and paste your code from your post all the indentation goes away. I suppose I could try and figure out where all the indents go... but it would be cool if you could post your .py files on the ftp server as well. Thanks!

Ditto! I'm a bit tired of all these .NET thingies going out without much thought for other platforms. Kudos for your attempt in Python instead!

Link to post
Share on other sites

Ok I will post them...

Also are you referencing ZigZagJoe's apps, because he put a lot of work into them and he also helped me a lot so don't discredit his work :(

Also have you tried mono?

FYI You need httplib2 (see the second post for instructions...)

Front End http://download476.mediafire.com/9la1acsh9...+Grooveshark.py

Back End http://download862.mediafire.com/b5az0cvus.../Grooveshark.py

Link to post
Share on other sites

His application is great. To the point I was running a virtual OS on top of linux solely for the purpose of listening to pandora. I did actually get it to work under wine with the modifications he recently posted, but like he said, you have to keep retrying to load the app and sometimes it works, sometimes it doesn't. Thanks for posting the source!

Link to post
Share on other sites

Works great in unbuntu karmic!

I got rid of all instances of 'C:/' in any self.path statements and replaced them with ''

underneath: choice = '0000' in the frontend I added: self.path = 'saved/' and made a folder called saved in the folder I placed the python files in, so all music goes there.

Is there any way to get artist information from the download?

I don't know too much about python programming, I use it as a matlab replacement for data analysis, so I apologize if it is obvious how to do it.

Thanks again!

Link to post
Share on other sites
His application is great. To the point I was running a virtual OS on top of linux solely for the purpose of listening to pandora. I did actually get it to work under wine with the modifications he recently posted, but like he said, you have to keep retrying to load the app and sometimes it works, sometimes it doesn't. Thanks for posting the source!

Heh, thanks :)

Not to hijack the thread, but there is a open-source pandora client for linux called pianobar. Written in C; it might be worth checking into as far as ripping/listening goes. Mono wouldn't work (unless dllimports can work with wine to get the job done?) because the player relys on named pipes to feed mplayer data (requires the use of win32 functions). Might try anyways, for shits and giggles. SProxy/Saver2 on the other hand, I'm not sure. Last guy that tried it hit \ on windows vs / on *nix killing it.

I'm also contemplating attempting to write a saving-only pandora dealie in php. Not the best language for this, I know, but the only cross platform language I'm rather comfortable with. Perl scares us, want nothing to do with python, and i'm not even going to mention java.

Btw, a suggestion (on topic): You might look into a ID3 library or command line tagging program, as the ID3 tags on grooveshark are VERY inconsistent. Some have none, others have odd capitalization, missing tags, outright wrong tags, and so on. The first plugin i wrote for ripping from grooveshark worked, but only just (caught the stream download, read tags, wrote file). Invalid chars/bad encodings (char) were rampant.

http://id3lib.sourceforge.net/ could work, though it isn't a native solution (I.E in python)

Link to post
Share on other sites

also just wanted to say thanks. :) Works nice here with simpleJson (ubuntu) .

One Request (dunno if it's possible though): download a grooveshark playlist in one go

And one very minor bug: when selecting nothing in the mainmenu and pressing enter the script stops, maybe make it go back to mainmenu

Cheers!

Link to post
Share on other sites

Ok I have ID3 tags working and am now working on fetching extended ID3 tags from the iTunes Music Store (you won't need iTunes installed for this to work...), Would anyone want me to have it fetch tags from Amazon too (I would then have to find out how).

Any other features (I am working on having an option to play songs from search results)

Link to post
Share on other sites
Ok I have ID3 tags working and am now working on fetching extended ID3 tags from the iTunes Music Store (you won't need iTunes installed for this to work...), Would anyone want me to have it fetch tags from Amazon too (I would then have to find out how).

Any other features (I am working on having an option to play songs from search results)

Why not just use grooveshark's data? if it provides genre, artist, album, and track name, i'd say its good enough.

As for the play from search results, you could spawn a thread which starts the download and then just spits the output at mplayer. I'm not familiar with python, but there must be some way to do partial reads from downloads. (streams, basically). Or you could use wget with the "--post-data=(data)" switch and have that piped to mplayer. Probably simpler, but controlling it would be more difficult because you'd have to use a fifo for slave control (or maybe pipe the data to the fifo? not used them much tbh)

BTW, if you do pipe data to mplayer, make sure to add "-cache 320 -demuxer audio". This is not necessary if playing from a file. Otherwise mplayer behaves very oddly, the most obvious things is it skips the first 30 seconds or so and plays back with some degree of time distortion (fast or slow). This one was a thorn in my side for a while.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...