Sites that stream music or videos through Flash interfaces are extremely common, and most of the time can be circumvented easily either using:
- Online sites created solely for the purpose of extracting the real music or video URL
- Using Chrome’s developer tools to find the exact resources being loaded, and simply opening the largest file
- Browsing the source, decompiling the flash, and recreating the exact authenticated etc to access the file as if you were the real client.
This works great for most sites, but I recently came across a site that none of these worked on (grooveshark). For the educational value, I decided to try a new approach: write a simple HTTP proxy server that simply cached the file type that I wanted.
The simplest way was to use Python and Twisted, and I found a great example of intercepting specific requests and modifying them here.
I took the code there, and modified it so that it looked for the Content-Type I was looking for (audio/mpeg), and cached those files. I started up my HTTP server, told my browser to go to Grooveshark, listened to the file I wanted, and done! I had a cached copy of the file.
This method will work with any site that uses HTTP.