public static List <YouTubeVideoQuality> GetYouTubeVideoUrls(string html) { List <YouTubeVideoQuality> youTubeVideoQualities = new List <YouTubeVideoQuality>(); string title = YouTubeDownloader.GetTitle(html); foreach (string str in YouTubeDownloader.ExtractUrls(html)) { YouTubeVideoQuality youTubeVideoQuality = new YouTubeVideoQuality() { VideoTitle = title, DownloadUrl = string.Concat(str, "&title=", title) }; if (!YouTubeDownloader.getQuality(youTubeVideoQuality, YouTubeDownloader.IsWideScreen(html))) { continue; } youTubeVideoQualities.Add(youTubeVideoQuality); } return(youTubeVideoQualities); }
private static bool getQuality(YouTubeVideoQuality q, bool _Wide) { int num; string str = Regex.Match(q.DownloadUrl, "itag=([1-9]?[0-9]?[0-9])", RegexOptions.Singleline).Groups[1].ToString(); if (str == "") { return(false); } if (!int.TryParse(str, out num)) { num = 0; } if (num <= 18) { if (num <= 6) { if (num == 5) { q.SetQuality("flv", new Size(320, (_Wide ? 180 : 240))); } else { if (num != 6) { q.SetQuality(string.Concat("itag-", str), new Size(0, 0)); return(true); } q.SetQuality("flv", new Size(480, (_Wide ? 270 : 360))); } } else if (num == 17) { q.SetQuality("3gp", new Size(176, (_Wide ? 99 : 144))); } else { if (num != 18) { q.SetQuality(string.Concat("itag-", str), new Size(0, 0)); return(true); } q.SetQuality("mp4", new Size(640, (_Wide ? 360 : 480))); } } else if (num > 46) { switch (num) { case 82: { q.SetQuality("3D.mp4", new Size(480, (_Wide ? 270 : 360))); break; } case 83: { q.SetQuality("3D.mp4", new Size(640, (_Wide ? 360 : 480))); break; } case 84: { q.SetQuality("3D.mp4", new Size(1280, (_Wide ? 720 : 960))); break; } case 85: { q.SetQuality("3D.mp4", new Size(1920, (_Wide ? 1080 : 1440))); break; } default: { switch (num) { case 100: { q.SetQuality("3D.webm", new Size(640, (_Wide ? 360 : 480))); break; } case 101: { q.SetQuality("3D.webm", new Size(640, (_Wide ? 360 : 480))); break; } case 102: { q.SetQuality("3D.webm", new Size(1280, (_Wide ? 720 : 960))); break; } default: { if (num != 120) { q.SetQuality(string.Concat("itag-", str), new Size(0, 0)); return(true); } q.SetQuality("live.flv", new Size(1280, (_Wide ? 720 : 960))); break; } } break; } } } else if (num == 22) { q.SetQuality("mp4", new Size(1280, (_Wide ? 720 : 960))); } else { switch (num) { case 34: { q.SetQuality("flv", new Size(640, (_Wide ? 360 : 480))); break; } case 35: { q.SetQuality("flv", new Size(854, (_Wide ? 480 : 640))); break; } case 36: { q.SetQuality("3gp", new Size(320, (_Wide ? 180 : 240))); break; } case 37: { q.SetQuality("mp4", new Size(1920, (_Wide ? 1080 : 1440))); break; } case 38: { q.SetQuality("mp4", new Size(2048, (_Wide ? 1152 : 1536))); break; } case 39: case 40: case 41: case 42: { q.SetQuality(string.Concat("itag-", str), new Size(0, 0)); return(true); } case 43: { q.SetQuality("webm", new Size(640, (_Wide ? 360 : 480))); break; } case 44: { q.SetQuality("webm", new Size(854, (_Wide ? 480 : 640))); break; } case 45: { q.SetQuality("webm", new Size(1280, (_Wide ? 720 : 960))); break; } case 46: { q.SetQuality("webm", new Size(1920, (_Wide ? 1080 : 1440))); break; } default: { q.SetQuality(string.Concat("itag-", str), new Size(0, 0)); return(true); } } } return(true); }