JavaYoutubeDownloader
JavaYoutubeDownloader copied to clipboard
Video not downloading
I wanted to test the package out, so I made a quick gradle project and added this pakage to my dependencies This is my main class (I just copy pasted the example)
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package javaytdl;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Comparator;
import io.github.gaeqs.javayoutubedownloader.JavaYoutubeDownloader;
import io.github.gaeqs.javayoutubedownloader.decoder.MultipleDecoderMethod;
import io.github.gaeqs.javayoutubedownloader.stream.StreamOption;
import io.github.gaeqs.javayoutubedownloader.stream.YoutubeVideo;
import io.github.gaeqs.javayoutubedownloader.stream.download.StreamDownloader;
public class App {
public String getGreeting() {
return "Hello World!";
}
public static boolean download(String url, File folder) throws MalformedURLException {
YoutubeVideo video = JavaYoutubeDownloader.decode(url, MultipleDecoderMethod.AND, "html");
//Gets the option with the greatest quality that has video and audio.
StreamOption option = video.getStreamOptions().stream()
.filter(target -> target.getType().hasVideo() && target.getType().hasAudio())
.min(Comparator.comparingInt(o -> o.getType().getVideoQuality().ordinal())).orElse(null);
//If there is no option, returns false.
if (option == null) return false;
//Prints the option type.
System.out.println(option.getType());
//Creates the file. folder/title.extension
File file = new File(folder, video.getTitle() + "." + option.getType().getContainer().toString().toLowerCase());
//Creates the downloader.
StreamDownloader downloader = new StreamDownloader(option, file, null);
//Runs the downloader.
new Thread(downloader).start();
return true;
}
public static void main(String[] args) {
System.out.println(new App().getGreeting());
try {
download("https://www.youtube.com/watch?v=p8mXAQ6cPxg", new File("C:\\Users\\<my user>\\Coding\\JavaYTDL\\x.mp4"));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}
I ran the app, but there is no file downloaded in that directory All I get are these messages in the console
Couldn't find the StreamType for the iTag 401
Couldn't find the StreamType for the iTag 400
[Video: true, Audio: true, Container: MP4, VEncoding: H264, VQuality: p720, AEncoding: AAC, AQuality: k192, Format Note: NONE, FPS: f30]
Where have I gone wrong?