C-sharp source: Download contents of m3u file

Posted on Friday 14 October 2005

I've been to a few music sites that allow you to download MP3s but make you go through an m3u list first. The m3u file contains only one line with the link to the actual MP3. It bothered me because I had to open the m3u file every time and copy the link in Firefox to download the actual MP3 when I don't want to stream the mp3. So I wrote my very first useful c sharp app to read the m3u file and open the first mp3 in the list in Firefox. Nothing complicated, just a little time saver I thought I'd share.


/*
 * Created by SharpDevelop.
 * User: Patrick Mineault
 * Date: 2005-10-14
 * Time: 23:48
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Diagnostics;
using System.IO;

namespace M3Uredirecter
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string location = "";
           
            try
            {
                location = args[0];
               
                //Open the file
                TextReader tr = new StreamReader(location);
               
                string remoteLoc = tr.ReadLine();
               
                //Open up the link in firefox
                Process proc = new Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName="firefox";
                proc.StartInfo.Arguments=remoteLoc;
                proc.Start();               
            }
            catch(Exception e)
            {
                Console.WriteLine("Location is undefined:: " + e.ToString());
            }
           
        }
    }
}
 

To use, just select 'Open with...' M3URedirecter instead of Winamp when the dialog opens in Firefox. Enjoy.


WordPress database error: [Can't open file: 'wp_comments.MYD'. (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '158' AND comment_approved = '1' ORDER BY comment_date

No comments have been added to this post yet.

Leave a comment




Your e-mail address is never displayed. If you run into issues with SpamKarma blocking you, email me at $patrick->5etdemi(com)


RSS feed for comments on this post | TrackBack URI