diff --git a/WeatubeDL/MainWindow.xaml.cs b/WeatubeDL/MainWindow.xaml.cs index 7f749e2..1d28785 100644 --- a/WeatubeDL/MainWindow.xaml.cs +++ b/WeatubeDL/MainWindow.xaml.cs @@ -43,7 +43,7 @@ namespace WeatubeDL return; } var text = (sender as TextBox).Text; - if (current != null && current.id.Contains(YoutubeVideo.IdFromUrl(text))) + if (current != null && current.id == YoutubeVideo.IdFromUrl(text)) { EnableSuggestion(); return; diff --git a/WeatubeDL/Properties/YoutubeVideo.cs b/WeatubeDL/Properties/YoutubeVideo.cs index cc9b3f2..88e25d2 100644 --- a/WeatubeDL/Properties/YoutubeVideo.cs +++ b/WeatubeDL/Properties/YoutubeVideo.cs @@ -36,7 +36,7 @@ namespace WeatubeDL public static string IdFromUrl(string src) { - if (src.Contains("youtu.be/") && src.Contains("&")) + if (src.Contains("youtu.be/")) return src.Replace("/youtu.be/", "").Split('/')[1].Split('&')[0]; else if (src.Contains("youtube.com/watch?v=") && src.Contains("&")) return src.Split('=')[1].Split('&')[0]; @@ -88,6 +88,8 @@ namespace WeatubeDL } return false; } + + // TODO: После того как прога понимает, что видос существует, она должна подтягивать его форматы private void GetVideoName() { client = new WebClient(); @@ -98,7 +100,8 @@ namespace WeatubeDL void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { name = Regex.Match(e.Result, @"\]*\>\s*(?[\s\S]*?)\</title\>", - RegexOptions.IgnoreCase).Groups["Title"].Value.Replace(" - YouTube", ""); + RegexOptions.IgnoreCase).Groups["Title"].Value; + name = name.Remove(name.Length - 10); (sender as WebClient).Dispose(); }