Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

30 Commits

Repository files navigation

youtubedl-java Build Status

A simple java wrapper for youtube-dl executable

There's a lot of thing left to do. Parsing output is one of them. Too bad, youtube-dl doesn't output formatted data.

Prerequisite

⚠️ Youtube-dl should be installed and available in your `$PATH.

How to properly install YoutubeDL executable

Otherwise you will get this error :

Cannot run program "youtube-dl" (in directory "/Users/my/beautiful/path"): error=2, No such file or directory

Usage

Installation

You can use jitpack.io to add the library to your project.

youtube-dl

Gradle

Step 1 : Add jitpack repository to your build file

allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}

Step 2: Add the dependency

dependencies {
compile 'com.github.sapher:youtubedl-java:1.+'
}

Make request

// Video url to downloadStringvideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
// Destination directoryStringdirectory = System.getProperty("user.home");
// Build requestYoutubeDLRequestrequest = newYoutubeDLRequest(videoUrl, directory);
request.setOption("ignore-errors"); // --ignore-errorsrequest.setOption("output", "%(id)s");	// --output "%(id)s"request.setOption("retries", 10); // --retries 10// Make request and return responseYoutubeDLResponseresponse = YoutubeDL.execute(request);
// ResponseStringstdOut = response.getOut(); // Executable output

You may also specify a callback to get notified about the progress of the download:

...
YoutubeDLResponse response = YoutubeDL.execute(request, new DownloadProgressCallback() {
@Override
public void onProgressUpdate(float progress, long etaInSeconds) {
System.out.println(String.valueOf(progress) + "%");
}
});

Links

About

Java wrapper for youtubedl executable

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages