Upload any Kind of File to Your Music Cloud Service

CloudMusic in the cloud, a new kind of cloud service, has become very popular over the last couple of years.

It makes sense. It helps free valuable portable space on smartphones, it facilitates the sharing of music with family and friends and most importantly, It’s much cheaper than regular cloud storage. In some cases, as with Google Music, it’s free.

Theoretically, when you pay for this kind of service, you’re buying extremely cheap cloud storage space. In the case of Google, you’re even getting it for free. Let’s see:

Songs Maximum File Size Storage Space Price
Apple 25'000 200 MB 4.7 TB $25
Google 20'000 300 MB 5.7 TB Free
Amazon 250'000 100 MB 19 TB $25

Of course, this makes sense for service providers because in most cases, people use these services to store music in the form of MP3 files. If a file is already contained in the service provider’s catalog, there’s no need to even upload it from the client’s computer. And one single copy of this MP3 can serve millions of happy customers. In the end, only a small fraction of all that theoretical space is actually occupied.

What I would like to show your here is how we can teach a new trick to our music-in-the-cloud-services in order to make them accept, not only MP3 files, but any kind of file.

I know what you’re probably thinking: “Let’s take any file and change the extension to MP3”

Genius, right?… wrong… In fact, these services are a little smarter than that. They all expect you to upload music. So we need to do some work on our files before we can upload them to the cloud. Here’s how it really works:

An MP3 file has a very specific structure. It is composed of several frames, each of them preceded by a header. The header contains information about the MP3 version, the bit-rate, the frequency and some other meaningful information. Metadata is optionally added to the file by means of ID tags.

I wrote a Python script that wraps any file into an MP3 disguise. It does this by cutting the data in chunks of very specific size, adding the necessary headers, putting the frames together and finally, adding an ID tag to store information about the original binary file. If the file is to large, the script cuts it into pieces and then wraps each piece as an MP3 file. Each chunk is marked using the track information contained in the ID tag.

By default, the script marks the files with the Artist name “Fake MP3 Encoder” and the Album name “My Data in the Music Cloud”. Both values can be changed directly from the command line. Album artwork is also added to the file to help identify more easily the Album containing your wrapped files in iTunes, Google Music or Amazon Cloud Player.

So this is my wrapper:

Of course, a second Python script removes the disguise and yields the original data. Here’s what it looks like:

If you want to try this, you will also need to download this image and save it to the same directory where you put both scripts. Do not change the file name.

So let’s give it a try. First, we need to install the Python package responsible for the ID tagging services of the script: mutagen.

Ok, now we’re ready to go. For this test, I will upload 790 MB Ubuntu installer ISO file. The encoder script gives me all these options:

But I will not use any options and rather go with the default values:

I now find 5 new MP3 files in my working directory:Screen Shot 2013-01-08 at 8.15.37 PM

You will notice that the total size of all the MP3 files together is a bit bigger than the size of the original file. This is to be expected, since the encapsulation (wrapping) process adds some overhead. There’s also some file padding involved.

I’m now going to upload the MP3 files to the Apple iTunes Match service, Google Music Player and Amazon Cloud Player.

Let’s start with Amazon. Amazon uses a little piece of software called the Amazon Music Importer. After pointing the importer to the specific directory containing my 5 fake MP3 files, the upload process begins:

Screen Shot 2013-01-08 at 8.44.36 PM

After a long wait, my files are uploaded and displayed online as music in the Amazon Cloud Player. I delete the originals from my hard drive. This is how the online album looks like:

Screen Shot 2013-01-08 at 9.05.24 PM

and here’s the list of “songs”:

Screen Shot 2013-01-08 at 9.05.47 PM

Downloading is much faster… after a little while, I have all the files once again. I will now proceed to remove the wrappers and stitch them all together again, all with one single command:

and my ISO file is back:

I now import the files to iTunes and manually select an iCloud update:

Screen Shot 2013-01-08 at 9.32.21 PM

The only way to interact with Apple’s service is through iTunes. This is the upload/download hub for your music. I wait a little while (less than what I had to wait with amazon) and finally find my files uploaded to the cloud. I can now delete the local versions. This is how iTunes looks like when you have deleted your local files. The cloud buttons on the right of each song allow you to download local copies again. That’s what I’m going to do now.

Screen Shot 2013-01-08 at 10.00.20 PM

iTunes likes to rename files by putting the track numbers in front of the name. This is no problem for the decoding script:

Once again, I recover my ISO file:

I’m going to run a last test with the only one of the three services that is completely free up to 20’000 songs, Google Music (amazon will let you upload 245 songs for free).

Google Music uses a small application called Music Manager, responsible for the uploading (and downloading) of music. I let Music Manager upload my fake album:

Screen Shot 2013-01-08 at 10.27.47 PM

My songs are now uploaded to Google Music and this is how they look:

Screen Shot 2013-01-08 at 10.43.32 PM

Downloading from Google is a breeze. The files download much faster than with the other two services. But downloading music from Google is a little tricky though. You may download your files as many times as you want, but you have to use the Music Manager Application. The downside is, you have to download the whole library every time. Downloading a specific file may be done directly from the Google Music website, but you can download each and every song only twice.

Google also likes to rename files. They use a naming scheme very similar to the one used by iTunes. I will now use my decoder tool:

and here’s my ISO file again:

So this is it. It’s still a work in progress. There are some “known issues” with the code and who knows how many “unknown issues”. It’s not very robust. It doesn’t check a lot of stuff and it doesn’t do a lot of error trapping. As a matter of fact, because the code started as a proof of concept, it’s not very elegant. But at least it does what it does.

Non ASCII file names are not supported at this time by the way… sorry…

Of course, your may have already guessed that this is a scientific curiosity for me more than any other thing. Keep in mind that these services are not optimized for this kind of use. They’re often slower than the real thing.

The interface, of course, is not exactly a pleasure to use. I mean, if you need to constantly upload and download many files, using this thing will be a pain. You can’t match the simplicity of dedicated cloud storage services such as the Amazon Cloud Drive, Google Drive, Dropbox or even the somehow limited iCloud storage for applications.

As a matter of fact, I don’t even use it myself 😉

11 thoughts on “Upload any Kind of File to Your Music Cloud Service

  1. hello,
    I find your idea great,
    I copied your code as shown
    but i receive the following error message you have an idea?
    bash:. / encoder.py: Permission denied

    thanks for help

  2. Hi!

    Nice post, I actually had a pretty similar idea, posted the same day as you ,-) Instead of MP3, I embed data in PNG files.

    Since Google Picasa provides unlimited storage for images below 2048×2048 in size, you could potentially store any amount of data you want (even tough 5.7TB on Google Music is pretty close to unlimited already ,-)).

    You could use googlecl (http://code.google.com/p/googlecl/) to automatically upload/download images (I don’t show how to do it in my post, I don’t want to make it too easy for people to use). Is there such an interface for Google Play music? (can’t test it, it’s not available in Singapore (yet))

    My blog post here: http://drinkcat.blogspot.sg/2013/01/picasa-as-random-data-storage.html


    • Hi!

      Nice! Google Picasa was my next project 🙂

      They do have an interface for Google Play that uploads and downloads music. But it forces you to download the whole library at once.

      Google doesn’t check your IP for the Google Music service. If you have a Google account associated to a geographical address in a country where Google Music is available, it will work worldwide. At least it does in my case!

      Greetings from Switzerland!

  3. Pingback: Il stocke gratuitement 5800 gigas de données grâce à Google Music | Entete.ch | Alexandre Haederli

Leave a Reply

Your email address will not be published. Required fields are marked *