Skip to content

A Kotlin-KMP library for extracting resources from popular sites like Streamtape, Google Drive, Mediafire, Fireload, Mp4Upload, Okru, Voe, Uqload, and many more.

License

Notifications You must be signed in to change notification settings

darkryh/MoonGetter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Maven Central

MoonGetter for Kotlin

App Icon Play Store Icon

MoonGetter MoonGetter is a robust, Kotlin-first library engineered for seamless stream extraction and video hosting download logic. It offers comprehensive support for Android and is now fully Kotlin Multiplatform (KMP) ready, featuring flexible custom server integration.


βœ… Features

  • Custom Server Integration β€” Easily build and integrate your own streaming providers.
  • Coroutine-based Architecture β€” Async-first design for highly scalable extraction logic.
  • Transparent HTTP Client Injection β€” Works seamlessly with both OkHttp and Ktor.
  • Custom Error Types β€” Intuitive error handling via InvalidServerException and descriptive Error enums.
  • Flexible Cookie Management β€” Automatic for OkHttp, configurable for Ktor.

πŸ”„ Compatibility Table

Feature Android JVM Kotlin Multiplatform
Core Library βœ… βœ… βœ…
Robot Servers API βœ… ⏳(desktop) ⏳ (Planned)
Server Implementations βœ… βœ… βœ…

βœ… = Supported / ⏳ = In development / JVM refers to non-Android Kotlin projects.


🌐 Supported Servers (Core)

βœ… Actively maintained / πŸ’₯ Deprecated

  • βœ… Google Drive
  • βœ… Mediafire
  • βœ… Streamtape
  • βœ… PixelDrain
  • βœ… Okru
  • βœ… StreamWish
  • πŸ’₯ Voe (Deprecated)
  • βœ… Senvid
  • βœ… Vihide
  • βœ… Hexload
  • βœ… YourUpload
  • βœ… Facebook
  • βœ… XTwitter
  • βœ… LuluStream
  • βœ… Mp4Upload
  • βœ… Uqload
  • βœ… Mixdrop
  • βœ… Doodstream
  • βœ… Vidguard
  • βœ… Filemoon
  • βœ… VK

πŸ€– Robot Servers (Optional)

These require the moongetter-core-robot module and a platform-specific Robot API.

  • πŸ’₯ Fireload (Deprecated)
  • βœ… 1CloudFile

Coming Soon: GoodStream, Gofile, Abyss


β˜• Installation (Gradle)

// For stable releases, use Maven Central
repositories {
    mavenCentral()
}

Kotlin Multiplatform Project Dependencies (MoonGetter Modules Only)

This section outlines the dependencies block specifically for integrating MoonGetter modules within a Kotlin Multiplatform (KMP) project structure. It focuses solely on MoonGetter-related dependencies, showing their placement for common shared code, Android-specific configurations, and iOS (Darwin) targets.

dependencies {
    // --- Common Main (Shared KMP Logic) ---
    commonMain.dependencies {
        implementation("io.github.darkryh.moongetter:moongetter-core:2.0.0-alpha01")
        implementation("io.github.darkryh.moongetter:moongetter-client-ktor:2.0.0-alpha01")
        implementation("io.github.darkryh.moongetter:moongetter-server-bundle:2.0.0-alpha01")
        implementation("io.github.darkryh.moongetter:moongetter-core-robot:2.0.0-alpha01")
        implementation("io.github.darkryh.moongetter:moongetter-server-robot-bundle:2.0.0-alpha01")
        // Optional: Individual server modules (instead of bundles)
        // implementation("io.github.darkryh.moongetter:moongetter-mp4upload:2.0.0-alpha01")
    }

    // --- Android Specific ---
    androidMain.dependencies {
        // Choose ONE HTTP client:
        implementation("io.github.darkryh.moongetter:moongetter-client-okhttp:2.0.0-alpha01") // Option 1: MoonGetter OkHttp Client
        // OR
        // implementation("io.ktor:ktor-client-okhttp:2.3.12") // Option 2: Ktor with OkHttp engine

        implementation("io.github.darkryh.moongetter:moongetter-client-cookie-java-net:2.0.0-alpha01") // Required: Cookie management if using ktor
        implementation("io.github.darkryh.moongetter:moongetter-client-trustmanager-java-net:2.0.0-alpha01") // Required: Trust management if using ktor
        implementation("io.github.darkryh.moongetter:moongetter-android-robot:2.0.0-alpha01") // Android Robot APIs
    }

    // --- iOS Specific ---
    iosMain.dependencies {
        // REQUIRED: Ktor's Darwin engine for network requests on iOS.
        implementation("io.ktor:ktor-client-darwin:2.3.12")
    }

    // --- Desktop (JVM) Specific ---
    desktopMain.dependencies {
        // Choose ONE HTTP client:
        implementation("io.ktor:ktor-client-cio:2.3.12") // Option 1: Ktor with CIO engine
        // OR
        // implementation("io.github.darkryh.moongetter:moongetter-client-okhttp:2.0.0-alpha01") // Option 2: MoonGetter OkHttp Client

        implementation("io.github.darkryh.moongetter:moongetter-client-cookie-java-net:2.0.0-alpha01") // Required: Cookie management if using ktor
        implementation("io.github.darkryh.moongetter:moongetter-client-trustmanager-java-net:2.0.0-alpha01") // Required: Trust management if using ktor
    }
}

Java/Kotlin JVM Project Dependencies (MoonGetter Integration Example)

This section outlines the dependencies block for integrating MoonGetter modules into a standard Java or Kotlin JVM project. This includes typical Android applications or standalone desktop JVM applications that do not use Kotlin Multiplatform.

dependencies {
    // --- Core & Server Support ---
    implementation("io.github.darkryh.moongetter:moongetter-core:2.0.0-alpha01")
    implementation("io.github.darkryh.moongetter:moongetter-server-bundle:2.0.0-alpha01")
    implementation("io.github.darkryh.moongetter:moongetter-core-robot:2.0.0-alpha01")
    implementation("io.github.darkryh.moongetter:moongetter-server-robot-bundle:2.0.0-alpha01")
    // Optional: Individual server modules
    // implementation("io.github.darkryh.moongetter:moongetter-mp4upload:2.0.0-alpha01")

    // --- HTTP Client & Utilities ---
    // Choose your client:
    implementation("io.github.darkryh.moongetter:moongetter-client-okhttp:2.0.0-alpha01") // Option 1: OkHttp (recommended)
    // OR
    // implementation("io.github.darkryh.moongetter:moongetter-client-ktor:2.0.0-alpha01") // Option 2: Ktor
    // + Ktor engine (e.g., "io.ktor:ktor-client-okhttp:2.3.12" or "io.ktor:ktor-client-cio:2.3.12")

    implementation("io.github.darkryh.moongetter:moongetter-client-cookie-java-net:2.0.0-alpha01") // Required: Cookie management if using ktor
    implementation("io.github.darkryh.moongetter:moongetter-client-trustmanager-java-net:2.0.0-alpha01") // Required: Trust management if using ktor

    // Android-specific Robot (only for Android projects)
    implementation("io.github.darkryh.moongetter:moongetter-android-robot:2.0.0-alpha01")
}

🧐 Client & Cookie Management Integration

Client Library Module Cookie Management KMP Support
OkHttp moongetter-client-okhttp βœ… Built-in ⏳ Not Supported
Ktor moongetter-client-ktor ⚠️ Manual setup required βœ… Experimental
JavaNetCookieManager moongetter-client-cookie-java-net βœ… (Only for Ktor, optional) ⏳ Not Supported

βœ… = Supported / ⚠️ = Manual setup / ⏳ = Coming soon

Note:

  • OkHttp has built-in cookie support, no setup needed.
  • Ktor requires you to explicitly inject cookie management (e.g., JavaNetCookieManagement).

Example with Ktor:

MoonGetter.Builder()
    .setClient(
        KtorMoonClient(
            engineFactory = CIO, //on iOS Darwin
            cookieManagement = JavaNetCookieManagement(), //on iOS MoonCookie.Management.newEmptyFactory()
            trustManager = JavaMoonTrustManager // on iOS MoonTrust.Manager.newEmptyFactory()
        )
    )

Example with OkHttp:

MoonGetter.Builder()
    .setClient(
        OkHttpClient
    )

πŸš€ Example Usage

ViewModel with coroutine logic:

class MyViewModel : ViewModel() {

    private val engine = Engine.Builder()
        .onCore(
            engines = arrayOf(
                Mp4UploadFactory,
                FilemoonFactory,
                StreamtapeFactory,
                StreamwishFactory,
                // CustomServerFactory (recommended to use `object`)
            )
        )
        .build()

    fun getMediaStreams(url: String) = viewModelScope.launch(Dispatchers.IO) {
        try {
            val server = MoonGetter
                .Builder()
                .setClient(
                    KtorMoonClient(
                        engineFactory = CIO, //on iOS Darwin
                        cookieManagement = JavaNetCookieManagement(), //on iOS MoonCookie.Management.newEmptyFactory()
                        trustManager = JavaMoonTrustManager // on iOS MoonTrust.Manager.newEmptyFactory()
                    )
                )
                .setTimeout(8000)
                .setEngine(engine)
                .setHeaders(mapOf("User-Agent" to "Mozilla/5.0"))
                .get(url)

            val streams = server?.videos
        } catch (e: InvalidServerException) {
            Log.e("MoonGetter", "Invalid: ${e.message}", e)
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}

πŸ›  Add Your Own Custom Server

Custom Server Class

class CustomServer(
    url: String,
    client: MoonClient,
    headers: HashMap<String, String>,
    configData: Configuration.Data
) : Server(url, client, headers, configData) {

    private val urlRegex =  """https://custom\.domain\.com/aqua/sv\?url=([^&]+)""".toRegex()

    override var url: String = urlRegex.find(url)?.groupValues?.get(1)
        ?: throw InvalidServerException(
            Resources.invalidProcessInExpectedUrlEntry(name),
            Error.INVALID_PROCESS_IN_EXPECTED_URL_ENTRY
        )

    override suspend fun onExtract(): List<Video> {
        val response = client.GET()

        if (!response.isSuccess) throw InvalidServerException(
            Resources.unsuccessfulResponse(name),
            Error.UNSUCCESSFUL_RESPONSE,
            response.statusCode
        )

        return listOf(
            Video(
                quality = DEFAULT,
                url = PatternManager.singleMatch(
                    string = response.body.asString(),
                    regex = "<source src=\"(.*?)\""
                ) ?: throw InvalidServerException(
                    Resources.expectedResponseNotFound(name),
                    Error.EXPECTED_RESPONSE_NOT_FOUND
                )
            )
        )
    }
}

Custom Server Factory

object CustomServerFactory : Server.Factory {
    override val serverName: String = "MyCustomServer" // Must match the serverName in CustomServer
    override val pattern: String = """https://custom\.domain\.com/aqua/sv\?url=([^&]+)""" // Your regex pattern for URLs this server handles
    
    //instance function since kmp doesnt support reflection
    override fun create(
        url: String,
        headers: HashMap<String, String>,
        configData: Configuration.Data,
        client: MoonClient
    ): Server = CustomServer(
        url = url,
        client = client,
        headers = headers,
        configData = configData
    )
}

πŸ§ͺ Requests

  • get(url: String): Retrieves a Server? for the given URL.
  • get(urls: List<String>): Retrieves a List<Server> for multiple URLs.
  • getUntilFindResource(urls: List<String>): Stops at the first valid Server found.

🀝 Want to Collaborate?

If you'd like to contribute or propose a new feature, feel free to reach out via X / Twitter @Darkryh or open a PR/request.


MoonGetter is in active development to expand KMP support. Swift/iOS support is coming soon.

About

A Kotlin-KMP library for extracting resources from popular sites like Streamtape, Google Drive, Mediafire, Fireload, Mp4Upload, Okru, Voe, Uqload, and many more.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published