Forum Archive

Grooveshark downloader - enjoy :)

pudquick51

Disclaimer: This works in combination with a (free) third-party App Store app.

The app that this script works in combination with is called 'iDownloads PLUS - Download Manager!', free, from Amad Marwat, in the iOS app store. I am not affiliated with him, it's just free and very useful (can download in the background with notifications when complete, can download multiple files, can play .mp3 files directly, has HTTP sharing and iTunes documents capabilities for transfer to a computer, and also has 'Open in ...' capabilities to move them to another app). Unfortunately for this script, Mobile Safari cannot directly be used as it lacks an 'Open in ...' capability to move .mp3 files to other apps.

This script is a Grooveshark search + download tool. It allows you to enter what you're looking for, gives you the top 8 results, then helps you download the .mp3.

https://gist.github.com/pudquick/5606582

Unlike other attempts at third-party Grooveshark libraries, I've attempted to do several things to help keep this client from being banned:

  • Download files likely to be downloaded by a real browser.
  • Mask the User-Agent of the browser.
  • Retain cookies handed out by the site.
  • Use the HTML5 version of the site so I can avoid needing to parse the Flash player.
  • Dynamically pull special values instead of hardcoding them.
  • Enforce the 30 second timer that fires when you've listened to an entire song.

All of these things should help to make sure that you don't get banned. Note: If you do get banned (downloading too many songs too quickly), the ban should lift in 10 minutes or so - try again later. I have no clue if this script will work outside of the US. They're very geographically picky about who can use their site.

How it works when you run it:

  1. The script will attempt to import requests module version 1.2. If it's not found, it will automatically download it and install it as requests_1_2.
  2. Once loaded, it will present a menu. Right now there is just a single choice '1) Search and download' (I'll add some more later). Enter 1, then enter your search term (like the name of a song).
  3. It will lookup your entry and provide the top hits (up to 8) for a match. Enter the number of the match you want to download.
  4. The download will then start, with progress indicators. As noted, the download will take a minimum of 30 seconds to help ensure you're not banned.
  5. When complete, iDownloads+ will automatically launch (make sure you have it installed). You can just hit the 'Download' button as I've configured the script to attempt to offer a decent name for the .mp3. When the transfer is complete (it will be quick), you can go back to the script. It will automatically clean up and offer to run again.
  6. Entering 0 or nothing for an entry will cause it to quit.

(album with images here)

As noted before in my Soundcloud downloader, the limitations of iOS make it so that .mp3 files you download can't be added to your device's music library programmatically. You'll have to save the .mp3 file from your device to iTunes and then sync it back to your device (or have a separate music player app, of which there are many, that you can 'Open in ...' the .mp3 file). In the meantime, iDownloads+ also offers a built-in media player so you can get to the listening :)

As always, hope you guys enjoy! ☺

I've already got the mechanics figured out for downloading playlists, just wanted to get the initial version published and out there for others to try.

pudquick51

Side note: .mp3 files are stored temporarily in the gs_dl folder that it creates.

If something goes wrong with the script, you can delete the folder in the Pythonista interface and it'll clear out everything that's in there (whether it's shown or not).

eliskan175

Awesome, I was wondering if this was possible. It's too cool that you decided to do it without anyone having to ask :D

omz

Gotta say, transferring the downloaded file to another app with a local http server is pretty clever! Unfortunately, I can't try this because Grooveshark isn't available in Germany.

pudquick51

@omz - I've used the http server + app method for a couple of my scripts in here (Mega client, for one). This script contains a variant of SimpleHTTPServer I've been developing that has sane timeouts, limited number of responses, etc. (instead of .serve_forever). Side request: please include a newer requests module in the next release - it's gone through some major changes that are useful.

@eliskan - Well, I've done Youtube, Soundcloud, Mega, and Grooveshark. They've all been fun. Got another suggestion?

eliskan175

Pandora is a consideration, but personally I have always used Grooveshark ever since I wanted specific choice so Pandora isn't a big deal for me.

However I would like to report one issue I had with this script, a very small one (probably related to my wifi sucking).. Many of the downloads simply stopped, and never proceeded. There's no easy way to stop the script while downloading (like a 'cancel' button) when the download freezes. For example it gets to 42% then ceases entirely. At that point I would check Safari and internet works.

Even if I hit the 'stop' button in Pythonista, the script will continue to play until I close Pythonista entirely and reboot it.

It would be nice to have a 'cancel' prompt during downloads that can stop the script from running, or something along those lines, without taking up too many resources. When the script is cancelled, if the file is corrupt it might be a good idea to automatically delete.

I do love this script and like the YouTube one before, it works in GoodReader if you replace ''iDownloads://' with 'ghttp://' on line 313

Loveless212

I also have that same problem,
Would anyone know the reason why?

tacomaster26

I have an idea... It looks like the error is from Line 204:

base_snip = re.search(r'window\.GS\.config.+?(\{.+?\});', self.base_html).groups()[0]

Looking into it...

tacomaster26

So just in case anyone runs across this page, here is the fix. This illustrates ones of the major problems with screen scraping: authors change the structure of their content and it ruins your day.

Replace Line 204:

base_snip = re.search(r'window\.GS\.config.+?(\{.+?\});', self.base_html).groups()[0]

With:

base_snip = re.search(r'GS\.config.+?(\{.+?\});', self.base_html).groups()[0]

Notice: the only thing changed was removing "window.". The reason this is happening is that GrooveShark changed the structure of that particular piece of JavaScript so the regex doesn't match anything anymore. The regex searching does not have a "graceful" failure, so it just crashes the whole application without really telling you why: it can't find the string it's looking for!

Have a stupendous day!
PS: emailing the author of this post now in hopes he can update on github

Loveless212

thank!

Loveless212

Did not work

tacomaster02

Did you get the same error mentioned above?

The error I am getting now is that no search results were found. The problem seems to be with _getResultsFromSearch

Hoping the developer can help us out :) I'll update when I know more

tacomaster02

Yea it looks like the session information isn't being handled properly. Maybe due to a change on the GrooveShark side? The client isn't able to present a valid token or some such nonsense. Unfortunately I am not very familiar with handling json object or session info... But I love this tool and will try to fix it.

tacomaster02

The app is trying to post this in the _doAPICall. Can anyone help out?

{"header":{"session":"9c9afeaf0f6d46cc9855465d095ed197"},"fault":{"code":256,"message":"invalid token"}}

rufily

At present, there are many tools for you to download Grooveshark music. But maybe you don't know which one is the best for you. Thus, here I would like to share the best Grooveshark Downloader for you. It is a smart and powerful audio recorder that can help record and download music from Grooveshark and other music streaming services with high audio quality. Maybe you could take a try of it.

Blackshady

Thanks for sharing~
However, I have been using a tool with some extra function that derserves some more attention. TunesKit Audio Capture software cannot serch the songs for you, but it can capture them into different fromats, such as MP3, M4A, FLAC. The most important feature is that the sound quality will be the same as that of the original audios.
Hope it helps.

sam rod

i try http://html5.grooveshark.com in the safari but is out of server

Blackshady

I have an option with more options when you download from Grooveshark.
Joyoshare Audio Recorder will download music to 16 formats in high quality. Besides, you can trim the tracks after downloading them. Batch downloading is also available.