Page 1 of 1

YouTube Plugin: Running into problems writing the RSS Feed

PostPosted: Fri Mar 30, 2007 6:43 am
by hvs69
I am currently trying to write a plugin that will bring YouTube content into Xlobby. The idea is very simple:

    Download the RSS feeds from Youtube using their API
    Convert the RSS feeds into Xlobby readable XML database by applying XSL transform


I have most of the pieces working but having strange problems with writing the full content of RSS feeds into a file. Here is the simplified relevant code

Code: Select all
      try
                {
HttpWebRequest myreq = (HttpWebRequest)WebRequest.Create("http://youtube.com/rss/global/top_viewed_today.rss");
                HttpWebResponse myrep = (HttpWebResponse)myreq.GetResponse();
                StreamReader mystream = new StreamReader(myrep.GetResponseStream(), Encoding.UTF8);
           
         
                   
                    string outputstring;
                    outputstring = mystream.ReadToEnd();
                    FileStream fs = new FileStream("temp.txt", FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.Write(outputstring);
                    //Console.WriteLine(outputstring);
}



The problem is that when I try to write the RSS webstream to file "temp.txt", it does not write the full feed to the file. Several lines are missing at the end.

On the other hand, if I dump the outputstring to the console (as seen in the commented line in the above code), I can see the whole stream.

I cannot understand this. Can someone please help ?

PostPosted: Fri Mar 30, 2007 6:51 am
by badubo
try first to close your StreamWriter before leaving, it will may be flush the content

PostPosted: Fri Mar 30, 2007 12:35 pm
by scottw
This sounds interesting please keep us posted!!!

PostPosted: Thu May 24, 2007 5:20 pm
by dry_flood
I dont know if your still working on this but have you ever heard of XBMC (xbox media center) it is an opensource media center for a modified xbox, but they have a youtube plugin that works, maybe you can have a look at that since it is open source and check their code against yours.

I think it is written in python, dont know if that will be any good for you though.

Gaz