Question

I have YouTube link "https://www.youtube.com/watch?v=ySuYTKkgIvg"

How can I store this video from YouTube to my SD card?

I can play video using YouTube player by android YouTube DATA API but don't know how to download it is any API / code who can help me to do this?

Was it helpful?

Solution

Youtube API allows you to search & list videos and obtain the mediaplayer URL, so that you can play videos within your web page.

Look here for downloading video from Youtube

Youtube Video Data API

Youtube Java Data API - Getting Started

It does not allow you to download the byte content of videos - because Google is protecting their own rights and the rights of the content creators.

Youtube Google API Terms of Service

OTHER TIPS

You can try using my library, youtube-dl-android, which lets you to easily extract video link from 1000+ sites including YouTube, Facebook, etc.

Step 1: Add jitpack repository to your project build file

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

Step 2: Add the dependency

dependencies {
    implementation 'com.github.bawaviki.youtube-dl-android:library:0.7.+'
}

Step 3: Use Youtube-dl instance

YoutubeDLRequest request = new YoutubeDLRequest("http://youtube.com/watch?v=xxxx");
request.setOption("-o", youtubeDLDir.getAbsolutePath() + "/%(title)s.%(ext)s");
YoutubeDL.getInstance().execute(request, (progress, etaInSeconds) -> {
    System.out.println(String.valueOf(progress) + "% (ETA " + String.valueOf(etaInSeconds) + " seconds)");
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top