Skip to content

Commit

Permalink
Auto accept yt-dlp download after 10 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenmoulder committed Oct 17, 2022
1 parent a9392c4 commit 537fece
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Services/DownloaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,40 @@ public async Task CheckExecutableExists()
{
if (!File.Exists(await _hostService.GetDownloaderExecutablePath()))
{
ConsoleKey response;
do
var response = true;
var countdown = 10;

while (countdown > 0)
{
await LogHelper.Log("Seems like yt-dlp has not been found. Would you like me to download it for you? [y/n]");
response = Console.ReadKey(false).Key;
Console.SetCursorPosition(0, 0);
Console.Write($"Seems like yt-dlp has not been found. Would you like me to download it for you? [y/n] ({countdown}s until auto accept) ");

if (response != ConsoleKey.Enter)
if (Console.KeyAvailable)
{
await LogHelper.Log("");
ConsoleKey key = Console.ReadKey(false).Key;

if (key == ConsoleKey.Y)
{
break;
}

if (key == ConsoleKey.N)
{
response = false;
break;
}
}
} while (response != ConsoleKey.Y && response != ConsoleKey.N);

if (response == ConsoleKey.N)
await Task.Delay(1000);
countdown--;
}

if (response == false)
{
await ErrorHelper.LogAndExit("You decided not to download yt-dlp, therefore the application must exit. yt-dlp is a requirement.");
}
else if (response == ConsoleKey.Y)

if (response == true)
{
await LogHelper.Log("Download starting");

Expand Down

0 comments on commit 537fece

Please sign in to comment.