From 97339447c76765b248aa4ff273faaf92d8f1f9a1 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 7 Jan 2024 21:33:12 +0700 Subject: [PATCH] close #502, close #333 --- Kinoger/build.gradle.kts | 26 +++ Kinoger/src/main/AndroidManifest.xml | 2 + .../src/main/kotlin/com/hexated/Kinoger.kt | 155 ++++++++++++++++++ .../main/kotlin/com/hexated/KinogerPlugin.kt | 15 ++ 4 files changed, 198 insertions(+) create mode 100644 Kinoger/build.gradle.kts create mode 100644 Kinoger/src/main/AndroidManifest.xml create mode 100644 Kinoger/src/main/kotlin/com/hexated/Kinoger.kt create mode 100644 Kinoger/src/main/kotlin/com/hexated/KinogerPlugin.kt diff --git a/Kinoger/build.gradle.kts b/Kinoger/build.gradle.kts new file mode 100644 index 00000000..7dfa6898 --- /dev/null +++ b/Kinoger/build.gradle.kts @@ -0,0 +1,26 @@ +// use an integer for version numbers +version = 1 + + +cloudstream { + language = "de" + // All of these properties are optional, you can safely remove them + + // description = "Lorem Ipsum" + authors = listOf("Hexated") + + /** + * Status int as the following: + * 0: Down + * 1: Ok + * 2: Slow + * 3: Beta only + * */ + status = 1 // will be 3 if unspecified + tvTypes = listOf( + "TvSeries", + "Movie", + ) + + iconUrl = "https://www.google.com/s2/favicons?domain=kinoger.com&sz=%size%" +} \ No newline at end of file diff --git a/Kinoger/src/main/AndroidManifest.xml b/Kinoger/src/main/AndroidManifest.xml new file mode 100644 index 00000000..c98063f8 --- /dev/null +++ b/Kinoger/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Kinoger/src/main/kotlin/com/hexated/Kinoger.kt b/Kinoger/src/main/kotlin/com/hexated/Kinoger.kt new file mode 100644 index 00000000..c7b78584 --- /dev/null +++ b/Kinoger/src/main/kotlin/com/hexated/Kinoger.kt @@ -0,0 +1,155 @@ +package com.hexated + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.extractors.Chillx +import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.ExtractorLinkType +import com.lagradost.cloudstream3.utils.Qualities +import com.lagradost.cloudstream3.utils.loadExtractor +import org.jsoup.nodes.Element + +class Kinoger : MainAPI() { + override var name = "Kinoger" + override var mainUrl = "https://kinoger.com" + override var lang = "de" + override val hasMainPage = true + override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie) + + override val mainPage = mainPageOf( + "" to "Alle Filme", + "stream/action" to "Action", + "stream/fantasy" to "Fantasy", + "stream/drama" to "Drama", + "stream/mystery" to "Mystery", + "stream/romance" to "Romance", + "stream/animation" to "Animation", + "stream/horror" to "Horror", + "stream/familie" to "Familie", + "stream/komdie" to "Komdie", + ) + + override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { + val document = app.get("$mainUrl/${request.data}/page/$page").document + val home = document.select("div#dle-content div.short").mapNotNull { + it.toSearchResult() + } + return newHomePageResponse(request.name, home) + } + + private fun getProperLink(uri: String): String { + return if (uri.contains("-episode-")) { + "$mainUrl/series/" + Regex("$mainUrl/(.+)-ep.+").find(uri)?.groupValues?.get(1) + } else { + uri + } + } + + private fun Element.toSearchResult(): SearchResponse? { + val href = getProperLink(this.selectFirst("a")?.attr("href") ?: return null) + val title = this.selectFirst("a")?.text() ?: this.selectFirst("img")?.attr("alt") + ?: this.selectFirst("a")?.attr("title") ?: return null + val posterUrl = fixUrlNull( + (this.nextElementSibling()?.selectFirst("div.content_text img") ?: this.selectFirst("div.content_text img") ?: this.selectFirst("img"))?.getImageAttr() + ) + + return newTvSeriesSearchResponse(title, href, TvType.AsianDrama) { + this.posterUrl = posterUrl + } + } + + override suspend fun search(query: String): List { + return app.get("$mainUrl/?do=search&subaction=search&titleonly=3&story=$query&x=0&y=0&submit=submit").document.select( + "div#dle-content div.titlecontrol" + ).mapNotNull { it.toSearchResult() } + } + + override suspend fun load(url: String): LoadResponse { + val document = app.get(url).document + val title = document.selectFirst("h1#news-title")?.text() ?: "" + val poster = fixUrlNull(document.selectFirst("div.images-border img")?.getImageAttr()) + val description = document.select("div.images-border").text() + val year = """\((\d{4})\)""".toRegex().find(title)?.groupValues?.get(1)?.toIntOrNull() + val type = if (document.selectFirst("label[title=Stream HD+]") + ?.hasText() == true + ) TvType.Movie else TvType.TvSeries + + val recommendations = document.select("ul.ul_related li").mapNotNull { + it.toSearchResult() + } + + val script = document.selectFirst("script:containsData(pw.show)")?.data() + ?.substringAfter("[")?.substringBeforeLast("]")?.replace("\'", "\"") + val json = AppUtils.tryParseJson>>("[$script]") + + val episodes = json?.flatMapIndexed { season: Int, iframes: List -> + iframes.mapIndexed { episode, iframe -> + Episode( + iframe.trim(), + season = season + 1, + episode = episode + 1 + ) + } + } ?: emptyList() + + return newTvSeriesLoadResponse(title, url, type, episodes) { + this.posterUrl = poster + this.year = year + this.plot = description + this.recommendations = recommendations + } + } + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + loadCustomExtractor(data, "$mainUrl/", subtitleCallback, callback) + return true + } + + private suspend fun loadCustomExtractor( + url: String, + referer: String? = null, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit, + quality: Int? = null, + ) { + loadExtractor(url, referer, subtitleCallback) { link -> + if(link.quality == Qualities.Unknown.value) { + callback.invoke( + ExtractorLink( + link.source, + link.name, + link.url, + link.referer, + when (link.type) { + ExtractorLinkType.M3U8 -> link.quality + else -> quality ?: link.quality + }, + link.type, + link.headers, + link.extractorData + ) + ) + } + } + } + + private fun Element.getImageAttr(): String? { + return when { + this.hasAttr("data-src") -> this.attr("data-src") + this.hasAttr("data-lazy-src") -> this.attr("data-lazy-src") + this.hasAttr("srcset") -> this.attr("srcset").substringBefore(" ") + else -> this.attr("src") + } + } + +} + +class Kinogeru : Chillx() { + override val name = "Kinoger" + override val mainUrl = "https://kinoger.ru" +} \ No newline at end of file diff --git a/Kinoger/src/main/kotlin/com/hexated/KinogerPlugin.kt b/Kinoger/src/main/kotlin/com/hexated/KinogerPlugin.kt new file mode 100644 index 00000000..2b9fc736 --- /dev/null +++ b/Kinoger/src/main/kotlin/com/hexated/KinogerPlugin.kt @@ -0,0 +1,15 @@ + +package com.hexated + +import com.lagradost.cloudstream3.plugins.CloudstreamPlugin +import com.lagradost.cloudstream3.plugins.Plugin +import android.content.Context + +@CloudstreamPlugin +class KinogerPlugin: Plugin() { + override fun load(context: Context) { + // All providers should be added in this manner. Please don't edit the providers list directly. + registerMainAPI(Kinoger()) + registerExtractorAPI(Kinogeru()) + } +} \ No newline at end of file