private void BindGrid() { try { YTDownloader DownloadVideo = new YTDownloader(); DataTable VideoLists = new DataTable(); VideoLists.Columns.Add("Video Format", typeof(string)); VideoLists.Columns.Add("Download Link"); VideoLists.Columns.Add("Video URL", typeof(string)); string UrlToDownlaod = Txt_Url.Text; UrlToDownlaod = (!UrlToDownlaod.StartsWith("http://") && !UrlToDownlaod.StartsWith("https://")) ? ("http://" + UrlToDownlaod) : UrlToDownlaod; if (Txt_Url.Text.Contains("youtube.com/")) { this.GetDownloadLink(UrlToDownlaod, out title); if (AvailableDownlinks.Count > 0) { for (int i = 0; i < AvailableDownlinks.Count; i++) { DataRow row = VideoLists.NewRow(); FormatCode = AvailableDownlinks[i].Tag; string VdoType = string.Empty; switch (FormatCode) { case "37": case "18": case "22": Extension = ".mp4"; VdoType = "MP4"; break; case "46": case "45": case "44": case "43": Extension = ".webm"; VdoType = "WEBM"; break; case "?": case "6": case "5": case "34": case "35": Extension = ".flv"; VdoType = "FLV"; break; case "36": case "13": case "17": Extension = ".3gp"; VdoType = "3GP"; break; } string NewUrl = AvailableDownlinks[i].DownloadLink; row["Video Format"] = VdoType; row["Download Link"] = "Download"; if (FormatCode == "22" || FormatCode == "37" || FormatCode == "45" || FormatCode == "46") { row["Download Link"] += " - HD"; } row["Video URL"] = NewUrl; VideoLists.Rows.Add(row); DataGrd_VdoLst.DataSource = VideoLists; DataGrd_VdoLst.Columns[0].Width = 150; DataGrd_VdoLst.Columns[1].Width = 200; DataGrd_VdoLst.Columns[2].Visible = false; DataGrd_VdoLst.Columns[2].Width = 0; } } else { MessageBox.Show("Wrong Url!", "Information"); } } else { MessageBox.Show("Entered Url Is Not of Youtube!", "Information"); } } catch (Exception ex) { if (ex.Message.Contains("The remote server returned an error: (404) Not Found.")) { MessageBox.Show(ex.Message); } else { Common.LogError(ex); } } }
private void BindGrid() { try { YTDownloader DownloadVideo = new YTDownloader(); DataTable VideoLists = new DataTable(); VideoLists.Columns.Add("Video Format", typeof(string)); VideoLists.Columns.Add("Download Link"); VideoLists.Columns.Add("Video URL", typeof(string)); string UrlToDownlaod = Txt_Url.Text; UrlToDownlaod = (!UrlToDownlaod.StartsWith("http://") && !UrlToDownlaod.StartsWith("https://")) ? ("http://" + UrlToDownlaod) : UrlToDownlaod; if (Txt_Url.Text.Contains("youtube.com/")) { this.GetDownloadLink(UrlToDownlaod, out title); if (AvailableDownlinks.Count > 0) { for (int i = 0; i < AvailableDownlinks.Count; i++) { DataRow row = VideoLists.NewRow(); FormatCode = AvailableDownlinks[i].Tag; string VdoType = string.Empty; switch (FormatCode) { case "37": case "18": case "22": Extension = ".mp4"; VdoType = "MP4"; break; case "46": case "45": case "44": case "43": Extension = ".webm"; VdoType = "WEBM"; break; case "?": case "6": case "5": case "34": case "35": Extension = ".flv"; VdoType = "FLV"; break; case "36": case "13": case "17": Extension = ".3gp"; VdoType = "3GP"; break; } string NewUrl = AvailableDownlinks[i].DownloadLink; row["Video Format"] = VdoType; row["Download Link"] = "Download"; if (FormatCode == "22" || FormatCode == "37" || FormatCode == "45" || FormatCode == "46") row["Download Link"] += " - HD"; row["Video URL"] = NewUrl; VideoLists.Rows.Add(row); DataGrd_VdoLst.DataSource = VideoLists; DataGrd_VdoLst.Columns[0].Width = 150; DataGrd_VdoLst.Columns[1].Width = 200; DataGrd_VdoLst.Columns[2].Visible = false; DataGrd_VdoLst.Columns[2].Width = 0; } } else { MessageBox.Show("Wrong Url!", "Information"); } } else { MessageBox.Show("Entered Url Is Not of Youtube!", "Information"); } } catch (Exception ex) { if (ex.Message.Contains("The remote server returned an error: (404) Not Found.")) MessageBox.Show(ex.Message); else Common.LogError(ex); } }