From 3a26bd3a92b4a85ce577aeb589b6f6b1b204c328 Mon Sep 17 00:00:00 2001 From: Cloudburst <18114966+C10udburst@users.noreply.github.com> Date: Fri, 11 Nov 2022 15:11:11 +0100 Subject: [PATCH] add dokumentalne.net --- DokumentalneProvider/build.gradle.kts | 24 +++++ .../src/main/AndroidManifest.xml | 2 + .../com/lagradost/DokumentalneProvider.kt | 99 +++++++++++++++++++ .../lagradost/DokumentalneProviderPlugin.kt | 13 +++ 4 files changed, 138 insertions(+) create mode 100644 DokumentalneProvider/build.gradle.kts create mode 100644 DokumentalneProvider/src/main/AndroidManifest.xml create mode 100644 DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProvider.kt create mode 100644 DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProviderPlugin.kt diff --git a/DokumentalneProvider/build.gradle.kts b/DokumentalneProvider/build.gradle.kts new file mode 100644 index 0000000..7248110 --- /dev/null +++ b/DokumentalneProvider/build.gradle.kts @@ -0,0 +1,24 @@ +// use an integer for version numbers +version = 1 + +cloudstream { + language = "pl" + // All of these properties are optional, you can safely remove them + + // description = "Lorem Ipsum" + authors = listOf("Cloudburst") + + /** + * Status int as the following: + * 0: Down + * 1: Ok + * 2: Slow + * 3: Beta only + * */ + status = 1 + tvTypes = listOf( + "Documentary" + ) + + iconUrl = "https://www.google.com/s2/favicons?domain=dokumentalne.net&sz=%size%" +} diff --git a/DokumentalneProvider/src/main/AndroidManifest.xml b/DokumentalneProvider/src/main/AndroidManifest.xml new file mode 100644 index 0000000..29aec9d --- /dev/null +++ b/DokumentalneProvider/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProvider.kt b/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProvider.kt new file mode 100644 index 0000000..1d41c85 --- /dev/null +++ b/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProvider.kt @@ -0,0 +1,99 @@ +package com.lagradost + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor +import org.jsoup.Jsoup +import org.jsoup.select.Elements +import android.util.Log + +open class DokumentalneProvider : MainAPI() { + override var mainUrl = "https://dokumentalne.net/" + override var name = "Dokumentalne.net" + override var lang = "pl" + override val hasMainPage = true + override val supportedTypes = setOf( + TvType.Documentary + ) + + override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse { + val document = app.get(mainUrl).document + val items = document.select(".body-content article.cactus-post-item").mapNotNull{ it -> + val a = it.selectFirst("h3 a") ?: return@mapNotNull null + val name = a.attr("title").trim() + val href = a.attr("href") + val img = it.selectFirst("img")?.attr("src") + newMovieSearchResponse( + name, + href, + TvType.Documentary + ) { + this.posterUrl = img + } + } + return HomePageResponse(listOf(HomePageList("Najnowsze", items, isHorizontalImages = true)), false) + } + + override suspend fun search(query: String): List { + val url = "$mainUrl/?s=$query" + val document = app.get(url).document + return document.select("article.cactus-post-item").mapNotNull{ it -> + val a = it.selectFirst("h3 a") ?: return@mapNotNull null + val name = a.attr("title").trim() + val href = a.attr("href") + val img = it.selectFirst("img")?.attr("src") + newMovieSearchResponse( + name, + href, + TvType.Documentary + ) { + this.posterUrl = img + } + } + } + + override suspend fun load(url: String): LoadResponse { + val document = app.get(url).document + + val embedUrl = document.selectFirst("iframe[allowfullscreen]")?.attr("src")?.let { it -> + return@let if (it.startsWith("//")) "https:$it" + else it + } + val title = document.select("h1.single-title").text().trim() + + val plot = document.select(".single-post-content p").text().trim() + + return newMovieLoadResponse(title, url, TvType.Documentary, embedUrl) { + this.plot = plot + this.recommendations = document.select(".post-list-in-single article.cactus-post-item").mapNotNull{ it -> + val a = it.selectFirst("h3 a") ?: return@mapNotNull null + val name = a.attr("title").trim() + val href = a.attr("href") + val img = it.selectFirst("img")?.attr("src") + newMovieSearchResponse( + name, + href, + TvType.Documentary + ) { + this.posterUrl = img + } + } + } + } + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + loadExtractor(data, subtitleCallback, callback) + return true + } +} + +data class LinkElement( + @JsonProperty("src") val src: String +) diff --git a/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProviderPlugin.kt b/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProviderPlugin.kt new file mode 100644 index 0000000..2218688 --- /dev/null +++ b/DokumentalneProvider/src/main/kotlin/com/lagradost/DokumentalneProviderPlugin.kt @@ -0,0 +1,13 @@ + +package com.lagradost + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class DokumentalneProviderPlugin: Plugin() { + override fun load(context: Context) { + registerMainAPI(DokumentalneProvider()) + } +} \ No newline at end of file