You can use the below code to download YouTube videos:
package com.mycompany.ytd;
import java.io.File;
import java.net.URL;
import com.github.axet.vget.VGet;
/**
*
* @author Manindar
*/
public class YTD {
public static void main(String[] args) {
try {
String url = "watch?v=s10ARdfQU";
String path = "D:\\Manindar\\YTD\\";
VGet v = new VGet(new URL(url), new File(path));
v.download();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Also, you need to add the dependency in POM.XML file:
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.33</version>
</dependency>
I hope this will help.
Want to become a Java Expert? Join Java Course now!!