title: Downloading mp3 from mp3clan.audio with C#
body: <p>I'm having headaches to make this work, is a mp3 downloader which downloads songs from mp3clan and other websites. here's my download code:</p>
  
  <pre><code> public void StartDownload()
      {
          downloadMusicGuid = dwMp3Skull.GenerateUniqueGuid();
  
          streamToWriteTo = new IsolatedStorageFileStream("music/" + downloadMusicGuid + ".mp3", FileMode.Create, file);
  
              request = (HttpWebRequest)WebRequest.Create(URL);
              request.AllowReadStreamBuffering = false;
              request.BeginGetResponse(new AsyncCallback(GetData), request);
  
      }
  
  
  
      void GetData(IAsyncResult result)
      { 
  
        try
        {
          HttpWebRequest request = (HttpWebRequest)result.AsyncState;
  
          HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);             
  
          Deployment.Current.Dispatcher.BeginInvoke(new Action(() =&gt; fSize = BytesToString(response.ContentLength)));
  
          Stream rStream = response.GetResponseStream();
  
          IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
  
          byte[] data = new byte[16 * 1024];
          int read;
  
          long totalValue = response.ContentLength;
          long sum = 0;
  
  
          while ((read = rStream.Read(data, 0, data.Length)) &gt; 0 )
          {
              sum += read;
  
              Deployment.Current.Dispatcher.BeginInvoke(new Action(() =&gt; Progress = (int)((sum * 100) / totalValue)));
  
  
              try
              {
                  streamToWriteTo.Write(data, 0, read);
              }
              catch (ObjectDisposedException ex)
              {
                  return;
              }
          }
          streamToWriteTo.Close();
          streamToWriteTo.Dispose();
  
          if (ModelLocator.HomeStatic.Downloads.Count != 0)
          {
              foreach (Download d in ModelLocator.HomeStatic.Downloads)
              {
                  if (d.State == DownloadState.Pending)
                  {
                      d.State = DownloadState.InProgress;
                      d.StartDownload();
                      break;
                  }
              }
          }
  
          Deployment.Current.Dispatcher.BeginInvoke(new Action(() =&gt; ConvertDownloadToTrack(this)));
  
          Deployment.Current.Dispatcher.BeginInvoke(new Action(() =&gt; ModelLocator.HomeStatic.Downloads.Remove(this)));
  
          }
          catch (Exception ex)
          {
              Deployment.Current.Dispatcher.BeginInvoke(new Action(() =&gt; MessageBox.Show(ex.Message)));
              return;
          }
      }
  </code></pre>
  
  <p>This code works perfect with direct links, but it doesn't with the mp3clan.audio, here is an example of link, I Have tested this link and it seems to redirect to two websites before returning the file (i'm not sure):</p>
  
  <p><a href="http://mp3clan.audio/dl.php?type=get&amp;s=4094c84c1a0a7fd0b53e556bb28ceb00&amp;tid=4470600_45874963&amp;name=Mp3NameGoesHere" rel="nofollow">http://mp3clan.audio/dl.php?type=get&amp;s=4094c84c1a0a7fd0b53e556bb28ceb00&amp;tid=4470600_45874963&amp;name=Mp3NameGoesHere</a></p>
  
  <p>Can someone point me to the right direction? Thanks for reading.</p>