subtitle-downloader/Program.cs

34 lines
1.3 KiB
C#

using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
public class Program {
static void Main(string[] args) {
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");
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;
driver.Navigate().GoToUrl(fullUrl);
Thread.Sleep(5000);
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()); // Remove link from already downloaded video subs [WORKS]
}
driver.Close();
Console.WriteLine("Ended");
}
}