YouTube Plugin: Running into problems writing the RSS Feed

related to programming for xlobby, code samples, examples etc.

YouTube Plugin: Running into problems writing the RSS Feed

Postby hvs69 on Fri Mar 30, 2007 6:43 am

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 ?
hvs69
 
Posts: 219
Joined: Wed Feb 11, 2004 8:06 am

Postby badubo on Fri Mar 30, 2007 6:51 am

try first to close your StreamWriter before leaving, it will may be flush the content
badubo
 
Posts: 505
Joined: Mon May 03, 2004 7:33 pm
Location: Belgium

Postby scottw on Fri Mar 30, 2007 12:35 pm

This sounds interesting please keep us posted!!!
scottw
 
Posts: 774
Joined: Mon Feb 06, 2006 4:21 pm
Location: Glen Burnie, Maryland

Postby dry_flood on Thu May 24, 2007 5:20 pm

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
dry_flood
 
Posts: 1
Joined: Sat May 13, 2006 6:53 pm