From eda55dd4e6b497042eaefe4180a4e50cdb8a142e Mon Sep 17 00:00:00 2001 From: ProfessionalUwU Date: Tue, 21 Mar 2023 20:50:59 +0100 Subject: [PATCH] Reused browser profile to avoid tag stripping --- Program.cs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Program.cs b/Program.cs index 01a9f20..22a63e1 100644 --- a/Program.cs +++ b/Program.cs @@ -6,6 +6,8 @@ public class Program { Console.WriteLine("Starting"); + IWebDriver driver = new FirefoxDriver(); + // Base url: https://downsub.com/?url=https%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D // Finished url: https://downsub.com/?url=https%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D + video id string[] lines = File.ReadAllLines(@"/nfs/andre/Archive/Vtuber/Hologra/archive/hologra_downloaded.txt"); @@ -13,30 +15,19 @@ public class Program { string videoId = line.Substring(8, 11); string fullUrl = "https://downsub.com/?url=https%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D" + videoId; - IWebDriver driver = new FirefoxDriver(); - driver.Navigate().GoToUrl(fullUrl); Thread.Sleep(5000); - IWebElement drop = driver.FindElement(By.XPath("//button[@class='v-expansion-panel-header px-4 py-2']")); // Open Dropdown [WORKS] - drop.SendKeys(Keys.Enter); - Thread.Sleep(1000); - - IWebElement check = driver.FindElement(By.Id("input-885")); // Click button to disable tag stripping [BROKEN] - see Element - check.SendKeys(Keys.Space); - Thread.Sleep(1000); - IWebElement sub = driver.FindElement(By.XPath("//button[@data-title='[SRT] English']")); // Download subtitle file [WORKS] sub.Click(); Thread.Sleep(3000); string fileName = "/nfs/andre/Archive/Vtuber/Hologra/archive/hologra_downloaded.txt"; - File.WriteAllLines(fileName, File.ReadAllLines(fileName).Where(l => l != line).ToList()); - - driver.Close(); - + File.WriteAllLines(fileName, File.ReadAllLines(fileName).Where(l => l != line).ToList()); // Remove link from already downloaded video subs [WORKS] } + driver.Close(); + Console.WriteLine("Ended"); } }