How to download Youtube video in android SD card programmatically

前端 未结 3 1940
眼角桃花
眼角桃花 2020-12-16 06:10

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 pla

3条回答
  •  旧巷少年郎
    2020-12-16 06:36

    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)");
    });
    

提交回复
热议问题