From a9ffacc245c433373fb6cd6936b9b538788b5ddb Mon Sep 17 00:00:00 2001 From: Naachiket Pant Date: Sat, 22 Oct 2022 19:10:18 +0530 Subject: [PATCH] Fix youtube download progress bar --- src/FileDownloader.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/FileDownloader.java b/src/FileDownloader.java index 90ee9b9db..d49b3dbcd 100644 --- a/src/FileDownloader.java +++ b/src/FileDownloader.java @@ -41,8 +41,6 @@ public static String getDir(){ */ @Override public void run() { - - link = link.replace('\\', '/'); if (!(link.startsWith("http://") || link.startsWith("https://"))){ link = "http://" + link; @@ -60,20 +58,19 @@ public void run() { Drifty_CLI.logger.log("INFO", "Downloading ..."); try { - ProcessBuilder processBuilder = new ProcessBuilder("yt-dlp", "-q", "--progress", "-P", dir, link); + ProcessBuilder processBuilder = new ProcessBuilder("yt-dlp", "--quiet", "--progress", "-P", dir, link); + processBuilder.inheritIO(); Process yt_dlp = processBuilder.start(); - BufferedReader br = new BufferedReader(new InputStreamReader(yt_dlp.getInputStream())); - String line = ""; - while ((line = br.readLine()) != null) { - System.out.println(line); - } + yt_dlp.waitFor(); + + System.out.println("\nDONE"); + Drifty_CLI.logger.log("INFO", "Successfully downloaded the file"); + } catch (Exception e) { e.printStackTrace(); Drifty_CLI.logger.log("ERROR", e.getMessage()); } - System.out.println("Successfully downloaded the file."); - Drifty_CLI.logger.log("INFO", "Successfully downloaded the file"); } else { url = new URL(link);