A Kotlin Multiplatform (KMP) library for extracting YouTube video information. Supports Android, Desktop, and other KMP-compatible platforms. iOS support is planned but not yet implemented.
- Kotlin Multiplatform (KMP) support.
- Fetch YouTube video metadata (title, description, Streaming Url , etc.).
- Ready for Android, IOS and Desktop platforms.
- Built-in retry mechanism for resilient data fetching.
- Kotlin 2.1+ (or compatible version)
- Gradle 7.x (with Kotlin DSL or Groovy)
Add the Maven repository to your repositories section in your project's build script.
In your build.gradle.kts file:
repositories {
mavenCentral()
google() //android only
}Add the library dependency to your respective modules.
dependencies {
implementation("io.github.ajaydhattarwal:youtube-extractor-android:1.0.2")
}dependencies {
implementation("io.github.ajaydhattarwal:youtube-extractor-desktop:1.0.2")
}kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.ajaydhattarwal:youtube-extractor:1.0.2")
}
}
}
}To use the YouTubeExtractor library, call the extractVideoData function:
fun main() {
val youtubeExtractor = YouTubeExtractor()
val url = "https://www.youtube.com/watch?v=GT0rV3pV2fA"
youtubeExtractor.extractVideoData(url).onSuccess{
println("video Title = > ${it.videoDetails?.title}")
println("video description = > ${it.videoDetails?.shortDescription}")
println("static Format url = > ${it.streamingData?.formats?.first()}")
println("hls url :: ${it.streamingData.hlsManifestUrl}")
}.onError{ //error ->
//error message
}
}
- Additional configuration options.
- Improved error handling and logging.
We welcome contributions! Feel free to submit issues or pull requests to improve the library.
If you have any feedback, please reach out to us at [email protected]