MySpace is a very well know place on the Internet. Even nowadays, with Facebook and other networks targeting pretty much everyone, MySpace have managed to stay around. However, that does not mean that they’ve got everything sort out… and today’s post is a workaround for its lack of downloading functionality.
Couple of days ago, a friend of mine was trying to download some music files from a MySpace account. It should be pretty straight forward, but for some reason there is no clear link to the song. Yesterday he ask me for help… and this is what I found.
Knowing your enemy
First thing first. If you’ve used MySpace before, you know that everyone has an address like myspace.com/<username>. The interesting thing is that every song has a unique ID very easy to find out looking to the URL of the song: myspace.com/<username>/music/songs/some-title-<ID>
Why do we need that ID? We need it because that’s how MySpace manage the songs. The do not know about titles and all that stuff, but ID’s.
After analysing the traffic MySpace’s player generates, I’ve found out an interesting service which reveals the location of the file: http://www.myspace.com/music/services/player?action=getSong&songId=<ID>
This service returns an XML with a tag “rtmp” which contains the real address of the song. Despite the fact that they always say the song is an MP3 file, it is actually an FLV file… so bear that in mind when trying to play it! Unfortunately, you will not be able to download it right away… because they use rtmp protocol. To complicate things a little bit more, I don’t know any easy way of dealing with rtmp…
Dealing with RTMP
I’ve used an open source program called “rtmpdump”. It is a command line program, but not really complicated, so don’t worry about that. However, if you try to use it naively, you’ll find out that MySpace will not allow you to get connected. Why? Well, they only allow their own player to connect to their servers.
Despite what you might think, this is a pretty common “security” measure very easy to circumvent. So common that rtmpdump has an option built in to deal with it 😀 We only need the address of the “real” player and rtmpdump will fake its signature. How cool is that?
To save you the analysis of the web, the address of the player is http://lads.myspacecdn.com/videos/MSMusicPlayer.swf
Putting everything together
So far we’ve all we need. We know how to find out the ID of a song, the location of the file for an ID and the address of the real player… how do we get the song? Let’s put everything together:
rtmpdump --swfVfy "http://lads.myspacecdn.com/videos/MSMusicPlayer.swf" -r <what_ever_the_xml_has_in_it> -o <the_you_want_for_the_song>
–swfVfy is relling rtmpdump to fake the signature of whatever we write after it… in this case the official player.
-r specifies the address of the song.
-o is to tell rtmpdump where do we want to save the song. (For some reason, MySpace uses FLV format… even if the XML says the song is an MP3 file!)
excellente a poguivo si edelia adinengo con buzeb. reexpel osacicos se aferiaso son fivos mi dicalag cugamo y cextr nceis oradarcav.
Great! It works!! Thank you!
Then I converted the song in mp3 using the following command:
ffmpeg -i song.flv -f mp3 sound.mp3
as explained here:
http://en.gibney.org/convert_flv_files_to_mp3
Thanks for posting! I just have a question, the file I downloaded is only 96kbps. I was just wondering if your downloads were also 96kbps? I have read the stream quality is 96kbps and the download should be higher, at least 128kbps. The site grabthatfile let’s you download at 128 kbps but only half the song which is no good.
Everything is very open with a clear description of the challenges.
It was definitely informative. Your website is useful.
Many thanks for sharing! youtube
youtube