0

it's a week that I'm trying to write a program that download correctly from youtube a video

the problem is this:

I've done via httpwebrequest a simple downloader and all work well. I've tried download a mp4 video from a local server (uniform server) and all goes well, video is the same, work and is valid mp4. When I download the same video from youtube something strange happens:

It fill some characters in downloaded file with sequence EF BF BD

for example when encounter character E2 (I've compared the two files one from youtube and the original). Googling around I discover that a server return this kinda sequence when encounterd a invalid char for your encoding, now I'm on wp7 and I can't set

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

here's others useful data: I've try with these:

_webRequest.Method = "GET"; //also POST
_webRequest.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16";
_webRequest.Accept = @"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
_webRequest.BeginGetResponse(_onDownload, userState);

format url from youtube

Any Idea? thanks

LXG
  • 1,957
  • 3
  • 22
  • 45

1 Answers1

1

Can you set the header using the _webRequest.Headers method? See these related questions:

Cannot set some HTTP headers when using System.Net.WebRequest

Constructing a POST in C#

Community
  • 1
  • 1
Greg Bray
  • 14,929
  • 12
  • 80
  • 104