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:
- 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.
- 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).

- 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.

- 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.

- 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.

- Entering 0 or nothing for an entry will cause it to quit.
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.