This library is a kotlin wrapper for YtDlp command line project.
To integrate a library into your build.gradle:
- Add the JitPack repository to your build file
allprojects {
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency
dependencies {
implementation 'com.github.dinaraparanid:YtDlp-kt:v1.0.0.0'
}
For other configuration go here
import com.dinaraparanid.ytdlp_kt.YtDlp
import com.dinaraparanid.ytdlp_kt.YtDlpRequest
suspend fun main() {
YtDlp.updateAsync().join() // or YtDlp.update()
val videoUrl = "https://www.youtube.com/watch?v=K0HSD_i2DvA"
val request = YtDlpRequest(videoUrl).apply {
setOption("--audio-format", "mp3")
setOption("--socket-timeout", "1")
setOption("--retries", "infinite")
setOption("--extract-audio")
setOption("--format", "best")
}
assert(YtDlp.execute(request) == YtDlp.executeAsync(request).await())
assert(YtDlp.getVideoData(videoUrl) == YtDlp.getVideoDataAsync(videoUrl).await())
}