All Projects → sealedtx → Java Youtube Downloader

sealedtx / Java Youtube Downloader

Licence: other
Simple, almost zero-dependency java parser for retrieving youtube video metadata

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Youtube Downloader

Youget
YouGet - YouTube Video/Playlist Downloader/Cutter - MP3 Converter
Stars: ✭ 169 (+5.63%)
Mutual labels:  downloader, download, youtube
Annie
👾 Fast and simple video download library and CLI tool written in Go
Stars: ✭ 16,369 (+10130.63%)
Mutual labels:  downloader, youtube, download
YoutubePlayer
Play and download YouTube videos. Extract audio from video. With minimalist beautiful gui.
Stars: ✭ 19 (-88.12%)
Mutual labels:  downloader, youtube, download
Insideheartz Whatsapp Bot
A multipurpose whatsapp bot buillt on node.js
Stars: ✭ 102 (-36.25%)
Mutual labels:  downloader, youtube
Docker Jdownloader
JDownloader 2 Docker Image (Multiarch) - Passed 40M Downloads
Stars: ✭ 85 (-46.87%)
Mutual labels:  downloader, download
Aria2.sh
Aria2 一键安装管理脚本 增强版
Stars: ✭ 1,276 (+697.5%)
Mutual labels:  downloader, download
Bash2mp4
Video Downloader for Termux .
Stars: ✭ 68 (-57.5%)
Mutual labels:  downloader, youtube
Filedownloader
Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process
Stars: ✭ 10,408 (+6405%)
Mutual labels:  downloader, download
Getsong
Download any song mp3 with no dependencies except ffmpeg
Stars: ✭ 102 (-36.25%)
Mutual labels:  downloader, youtube
Youtubedownloader
Downloads videos and playlists from YouTube
Stars: ✭ 2,202 (+1276.25%)
Mutual labels:  download, youtube
Android Youtubemp3
Download videos as mp3 directly from Youtube Android App
Stars: ✭ 124 (-22.5%)
Mutual labels:  download, youtube
Youtube explode dart
Port of YoutubeExplode to dart
Stars: ✭ 76 (-52.5%)
Mutual labels:  download, youtube
Github Files Fetcher
Download a specific folder or file from a GitHub repo through command line
Stars: ✭ 73 (-54.37%)
Mutual labels:  downloader, download
Av Converter
[av-converter.com] Audio and Video Converter, and YouTube downloader. Convert to MP3, MP4, AAC, FLAC, AC3, WAV, etc.
Stars: ✭ 97 (-39.37%)
Mutual labels:  downloader, youtube
Musicdownloader
Material design YouTube mp3/mp4 downloader
Stars: ✭ 70 (-56.25%)
Mutual labels:  downloader, youtube
Podify
Create podcasts from anything youtube-dl can handle
Stars: ✭ 111 (-30.62%)
Mutual labels:  downloader, youtube
Youtubeexplode
The ultimate dirty YouTube library
Stars: ✭ 1,775 (+1009.38%)
Mutual labels:  download, youtube
4chan Downloader
Python3 script to continuously download all images/webms of multiple 4chan thread simultaneously - without installation
Stars: ✭ 136 (-15%)
Mutual labels:  downloader, download
Fgdownloader
用于断点下载、任务队列、上传进度、下载进度
Stars: ✭ 143 (-10.62%)
Mutual labels:  downloader, download
Youtubeexplode.converter
Muxes and converts videos from YoutubeExplode
Stars: ✭ 68 (-57.5%)
Mutual labels:  downloader, youtube

java-youtube-downloader

Simple java parser for retrieving youtube video metadata.

Library is not stable, because Youtube often changes web structure of its pages. I don't use this library regularly to find the errors. Thats why errors are fixed as soon as someone finds it and opens an issue. Feel free to report an error or sumbit a PR.

WARNING: Youtube API does not support a video download. In fact, it is prohibited - Terms of Service - II. Prohibitions.
WARNING: Downloading videos may violate copyrights!

This project is only for educational purposes. I urge not to use this project to violate any laws.

Usage

// init downloader
YoutubeDownloader downloader = new YoutubeDownloader();

// you can easly implement or extend default parsing logic 
YoutubeDownloader downloader = new YoutubeDownloader(new Parser()); 
// downloader configurations
downloader.setParserRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36");
downloader.setParserRetryOnFailure(1);

// parsing data
String videoId = "abc12345"; // for url https://www.youtube.com/watch?v=abc12345
YoutubeVideo video = downloader.getVideo(videoId);

// video details
VideoDetails details = video.details();
System.out.println(details.title());
...
System.out.println(details.viewCount());
details.thumbnails().forEach(image -> System.out.println("Thumbnail: " + image));

// get videos with audio
List<AudioVideoFormat> videoWithAudioFormats = video.videoWithAudioFormats();
videoWithAudioFormats.forEach(it -> {
    System.out.println(it.audioQuality() + " : " + it.url());
});

// filtering only video formats
List<VideoFormat> videoFormats = video.findVideoWithQuality(VideoQuality.hd720);
videoFormats.forEach(it -> {
    System.out.println(it.videoQuality() + " : " + it.url());
});

// itags can be found here - https://gist.github.com/sidneys/7095afe4da4ae58694d128b1034e01e2
Format formatByItag = video.findFormatByItag(136); 
if (formatByItag != null) {
    System.out.println(formatByItag.url());
}

File outputDir = new File("my_videos");
Format format = videoFormats.get(0);

// sync downloading
File file = video.download(format, outputDir);

// async downloading with callback
Future<File> future = video.downloadAsync(videoFormats.get(0), outputDir, new OnYoutubeDownloadListener() {
    @Override
    public void onDownloading(int progress) {
        System.out.printf("Downloaded %d%%\n", progress);
    }
            
    @Override
    public void onFinished(File file) {
        System.out.println("Finished file: " + file);
    }

    @Override
    public void onError(Throwable throwable) {
        System.out.println("Error: " + throwable.getLocalizedMessage());
    }
});

// async downloading without callback
Future<File> future = video.downloadAsync(format, outputDir);
File file = future.get(5, TimeUnit.SECONDS);

// cancel downloading
future.cancel(true); // true is required to interrupt downloading thread

// live videos and streams
if (video.details().isLive()) {
    System.out.println("Live Stream HLS URL: " + video.details().liveUrl());
}

// naming
// by default file name will be same as video title on youtube, 
// but you can specify output file name
File myAwesomeFile = video.download(format, outputDir, "myAwesomeName");
System.out.println(file.getName()); // myAwesomeName.mp4
// if file with such name already exits sufix will be added myAwesomeFile(1).mp4
// you may disable this feature by passing overwrite flag
File myAwesomeFile = video.download(format, outputDir, "myAwesomeName", true);

// subtitles
// you can get subtitles from video captions if you have already parsed video meta
List<SubtitlesInfo> subtitles = video.subtitles(); // NOTE: includes auto-generated
// if you don't need video meta, but just subtitles use this instead
List<SubtitlesInfo> subtitles = downloader.getVideoSubtitles(videoId); // NOTE: does not include auto-generated

for (SubtitlesInfo info : subtitles) {
    Subtitles subtitles = info.getSubtitles()
             .formatTo(Extension.JSON3)
             .translateTo("uk"); // // NOTE: subtitle translation supported only for "subtitles from captions"
        // sync download
    String subtitlesData = subtitles.download();
    // async download
    Future<String> subtitlesFuture = subtitles.downloadAsync(callback/*optional*/);
    // to download using external download manager
    String downloadUrl = subtitles.getDownloadUrl(); 
}

// playlists

// parsing data
String playlistId = "abc12345"; // for url https://www.youtube.com/playlist?list=abc12345
YoutubePlaylist playlist = downloader.getPlaylist(playlistId);

// playlist details
PlaylistDetails details = playlist.details();
System.out.println(details.title());
...
System.out.println(details.videoCount());

// get video details
PlaylistVideoDetails videoDetails = playlist.videos().get(0);
System.out.println(videoDetails.title());
...
System.out.println(videoDetails.index());

// get video
YoutubeVideo video = downloader.getVideo(videoDetails.videoId());

Include

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
  <groupId>com.github.sealedtx</groupId>
  <artifactId>java-youtube-downloader</artifactId>
  <version>2.5.2</version>
</dependency>

Gradle

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.sealedtx:java-youtube-downloader:2.5.2'
}

Android

android {
  ...
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
  // For Kotlin projects
  kotlinOptions {
    jvmTarget = "1.8"
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].