subtitle-downloader/Program.cs

40 lines
1.5 KiB
C#
Raw Normal View History

2023-02-10 22:03:31 +01:00
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
public class Program {
static void Main(string[] args) {
Console.WriteLine("Starting");
2023-02-10 22:03:31 +01:00
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/hologra_downloaded.txt");
foreach (string line in lines) {
string videoId = line.Substring(8, 11);
string fullUrl = "https://downsub.com/?url=https%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D" + videoId;
2023-02-10 22:03:31 +01:00
driver.Navigate().GoToUrl(fullUrl);
Thread.Sleep(5000);
2023-02-10 22:03:31 +01:00
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);
2023-02-10 22:03:31 +01:00
IWebElement check = driver.FindElement(By.Id("input-885")); // Click button to disable tag stripping [WORKS]
check.SendKeys(Keys.Space);
Thread.Sleep(1000);
2023-02-10 22:03:31 +01:00
IWebElement sub = driver.FindElement(By.XPath("//button[@data-title='[SRT] English']")); // Download subtitle file [WORKS]
sub.Click();
Thread.Sleep(3000);
driver.Close();
}
Console.WriteLine("Ended");
2023-02-10 22:03:31 +01:00
}
}