Skip to content

A Kotlin Multiplatform library for extracting streaming URLs and metadata from YouTube videos, designed for seamless integration across platforms. 🎥📦

Notifications You must be signed in to change notification settings

AjayDhattarwal/YouTubeExtractor

Repository files navigation

YouTubeExtractor Library

Maven Kotlin

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.

Features

  • 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.

Requirements

  • Kotlin 2.1+ (or compatible version)
  • Gradle 7.x (with Kotlin DSL or Groovy)

Setup

Step 1: Add Maven Repository

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 Dependency

Maven

Add the library dependency to your respective modules.

For Android:

dependencies {
    implementation("io.github.ajaydhattarwal:youtube-extractor-android:1.0.2")
}

For Desktop:

dependencies {
    implementation("io.github.ajaydhattarwal:youtube-extractor-desktop:1.0.2")
}

For KMP (shared module):

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("io.github.ajaydhattarwal:youtube-extractor:1.0.2")
            }
        }
    }
}

Usage Example

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 
    }
    

}

Planned Features

  • Additional configuration options.
  • Improved error handling and logging.

Contributing

We welcome contributions! Feel free to submit issues or pull requests to improve the library.

License

Unlicense

🔗 Links

linkedin

twitter

Feedback

If you have any feedback, please reach out to us at [email protected]

About

A Kotlin Multiplatform library for extracting streaming URLs and metadata from YouTube videos, designed for seamless integration across platforms. 🎥📦

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages