private static bool getQuality(YouTubeVideoQuality q, Boolean _Wide)
        {
            int    iTagValue;
            string itag = Regex.Match(q.DownloadUrl, @"itag=([1-9]?[0-9]?[0-9])", RegexOptions.Singleline).Groups[1].ToString();

            if (itag != "")
            {
                if (int.TryParse(itag, out iTagValue) == false)
                {
                    iTagValue = 0;
                }

                switch (iTagValue)
                {
                case 5: q.SetQuality("flv", 320); break;

                case 6: q.SetQuality("flv", 480); break;

                case 17: q.SetQuality("3gp", 176); break;

                case 18: q.SetQuality("mp4", 640); break;

                case 22: q.SetQuality("mp4", 1280); break;

                case 34: q.SetQuality("flv", 640); break;

                case 35: q.SetQuality("flv", 854); break;

                case 37: q.SetQuality("mp4", 1920); break;

                case 38: q.SetQuality("mp4", 2048); break;

                case 43: q.SetQuality("webm", 640); break;

                case 44: q.SetQuality("webm", 854); break;

                case 45: q.SetQuality("webm", 1280); break;

                case 46: q.SetQuality("webm", 1920); break;

                case 83: q.SetQuality("3D.mp4", 640); break;          // 3D

                case 84: q.SetQuality("3D.mp4", 1280); break;         // 3D

                case 85: q.SetQuality("3D.mp4", 1920); break;         // 3D

                case 100: q.SetQuality("3D.webm", 640); break;        // 3D

                case 101: q.SetQuality("3D.webm", 640); break;        // 3D

                case 102: q.SetQuality("3D.webm", 1280); break;       // 3D

                case 120: q.SetQuality("live.flv", 1280); break;      // Live-streaming - should be ignored?
                }
                return(true);
            }
            return(false);
        }
 public static List<YouTubeVideoQuality> GetYouTubeVideoUrls(params string[] VideoUrls)
 {
     List<YouTubeVideoQuality> urls = new List<YouTubeVideoQuality>();
     foreach (var VideoUrl in VideoUrls)
     {
         string html = Helper.DownloadWebPage(VideoUrl);
         string title = GetTitle(html);
         foreach (var videoLink in ExtractUrls(html))
         {
             YouTubeVideoQuality q = new YouTubeVideoQuality();
             q.VideoUrl = VideoUrl;
             q.VideoTitle = title;
             q.DownloadUrl = videoLink + "&title=" + title;
             q.Length = long.Parse(Regex.Match(html, "\"length_seconds\":(.+?),", RegexOptions.Singleline).Groups[1].ToString().Replace("\"", ""));
             bool IsWide = IsWideScreen(html);
             if (getQuality(q, IsWide))
                 urls.Add(q);
         }
     }
     return urls;
 }
        public static List <YouTubeVideoQuality> GetYouTubeVideoUrls(params string[] VideoUrls)
        {
            List <YouTubeVideoQuality> urls = new List <YouTubeVideoQuality>();

            foreach (var VideoUrl in VideoUrls)
            {
                string html  = Helper.DownloadWebPage(VideoUrl);
                string title = GetTitle(html);
                foreach (var videoLink in ExtractUrls(html))
                {
                    YouTubeVideoQuality q = new YouTubeVideoQuality();
                    q.VideoUrl    = VideoUrl;
                    q.VideoTitle  = title;
                    q.DownloadUrl = videoLink + "&title=" + title;
                    q.Length      = long.Parse(Regex.Match(html, "\"length_seconds\":(.+?),", RegexOptions.Singleline).Groups[1].ToString().Replace("\"", ""));
                    bool IsWide = IsWideScreen(html);
                    if (getQuality(q, IsWide))
                    {
                        urls.Add(q);
                    }
                }
            }
            return(urls);
        }
        private static bool getQuality(YouTubeVideoQuality q, Boolean _Wide)
        {
            int iTagValue;
            string itag = Regex.Match(q.DownloadUrl, @"itag=([1-9]?[0-9]?[0-9])", RegexOptions.Singleline).Groups[1].ToString();
            if (itag != "")
            {
                if (int.TryParse(itag, out iTagValue) == false)
                    iTagValue = 0;

                switch (iTagValue)
                {
                    case 5: q.SetQuality("flv", 320); break;
                    case 6: q.SetQuality("flv", 480); break;
                    case 17: q.SetQuality("3gp", 176); break;
                    case 18: q.SetQuality("mp4", 640); break;
                    case 22: q.SetQuality("mp4", 1280); break;
                    case 34: q.SetQuality("flv", 640); break;
                    case 35: q.SetQuality("flv", 854); break;
                    case 37: q.SetQuality("mp4", 1920); break;
                    case 38: q.SetQuality("mp4", 2048); break;
                    case 43: q.SetQuality("webm", 640); break;
                    case 44: q.SetQuality("webm", 854); break;
                    case 45: q.SetQuality("webm", 1280); break;
                    case 46: q.SetQuality("webm", 1920); break;
                    case 83: q.SetQuality("3D.mp4", 640); break;        // 3D
                    case 84: q.SetQuality("3D.mp4", 1280); break;       // 3D
                    case 85: q.SetQuality("3D.mp4", 1920); break;     // 3D
                    case 100: q.SetQuality("3D.webm", 640); break;      // 3D
                    case 101: q.SetQuality("3D.webm", 640); break;      // 3D
                    case 102: q.SetQuality("3D.webm", 1280); break;     // 3D
                    case 120: q.SetQuality("live.flv", 1280); break;    // Live-streaming - should be ignored?
                }
                return true;
            } return false;
        }