From 74ab75cf5f194705bd2ecb4a29c33597aabab2f2 Mon Sep 17 00:00:00 2001 From: ilusha Date: Tue, 13 Jul 2021 12:23:39 +0300 Subject: [PATCH] =?UTF-8?q?"=D0=A1=D0=B8=D0=B4=D0=B8=D1=82=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=B8=D1=81=D1=82,=20?= =?UTF-8?q?=D0=BF=D0=B8=D1=88=D0=B5=D1=82=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=BC=D1=83,=20=D0=B2=D0=B4=D1=80=D1=83=D0=B3,=20?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=BA=20=D0=B2=20=D0=B4=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=8C.=20=D0=9E=D1=82=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=E2=80=94=20=D0=B0=20=D1=82=D0=B0=D0=BC=20=D1=81=D0=BC?= =?UTF-8?q?=D0=B5=D1=80=D1=82=D1=8C=20=D1=81=20=D0=BA=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B9!=20=D0=9F=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC?= =?UTF-8?q?=D0=B8=D1=81=D1=82:=20=E2=80=94=20=D0=9D=D0=B5=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B1=D0=B8=D1=80=D0=B0=D0=B9=20=D0=BC=D0=B5=D0=BD=D1=8F=20?= =?UTF-8?q?=D1=81=D0=B5=D0=B9=D1=87=D0=B0=D1=81,=20=D0=B4=D0=B0=D0=B9=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=83=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D1=82=D1=8C!=20=D0=A1=D0=BC?= =?UTF-8?q?=D0=B5=D1=80=D1=82=D1=8C:=20=E2=80=94=20=D0=90=20=D1=8F=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=B7=D0=B0=20=D1=82=D0=BE=D0=B1=D0=BE=D0=B9,?= =?UTF-8?q?=20=D1=8F=20=D0=B7=D0=B0=20=D1=82=D0=B2=D0=BE=D0=B8=D0=BC=20?= =?UTF-8?q?=D0=B2=D0=B8=D0=BD=D1=87=D0=B5=D1=81=D1=82=D0=B5=D1=80=D0=BE?= =?UTF-8?q?=D0=BC."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Смешно, да?) --- WeatubeDL/MainWindow.xaml.cs | 2 +- WeatubeDL/Properties/YoutubeVideo.cs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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(); }