Skip to content

Commit

Permalink
Fix youtube download progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
poshi1865 committed Oct 22, 2022
1 parent 4b1140b commit a9ffacc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/FileDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit a9ffacc

Please sign in to comment.