add Tvpolan

This commit is contained in:
Cloudburst 2022-08-22 14:38:07 +02:00
parent a8c1c9ca44
commit 4baacbb689
4 changed files with 122 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// use an integer for version numbers
version = 1
dependencies {
implementation("me.xdrop:fuzzywuzzy:1.4.0")
}
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(
"Live"
)
iconUrl = "https://www.google.com/s2/favicons?domain=tvpolan.ml&sz=%size%"
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.lagradost"/>

View file

@ -0,0 +1,79 @@
package com.lagradost
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import me.xdrop.fuzzywuzzy.FuzzySearch
open class TvpolanProvider : MainAPI() {
override var mainUrl = "http://tvpolan.ml/"
override var name = "TV Polan"
override var lang = "pl"
override val hasMainPage = true
override val supportedTypes = setOf(
TvType.Live
)
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
val document = app.get(mainUrl).document
val lists = document.select(".channels ul li a[href]").map { it ->
return@map LiveSearchResponse(
name = it.attr("title"),
url = it.attr("href"),
apiName = this.name,
type = TvType.Live,
posterUrl = it.selectFirst("img[src]")?.attr("src")
)
}
return newHomePageResponse(this.name, lists, false)
}
override suspend fun search(query: String): List<SearchResponse> {
val document = app.get(mainUrl).document
val lists = document.select(".channels ul li a[href]").map { it ->
return@map LiveSearchResponse(
name = it.attr("title"),
url = it.attr("href"),
apiName = this.name,
type = TvType.Live,
posterUrl = it.selectFirst("img[src]")?.attr("src")
)
}
return lists.sortedBy { -FuzzySearch.ratio(it.name, query) }
}
override suspend fun load(url: String): LoadResponse? {
val document = app.get(url).document
val name = Regex("http://tvpolen\\.ml/(.+)\\.php").find(url)?.groupValues?.get(1) ?: this.name
val src = document.selectFirst("video source[src]")?.attr("src") ?: return null
return LiveStreamLoadResponse(
name,
url,
this.name,
src,
"http://tvpolen.ml/tv/${name}.png"
)
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
callback.invoke(
ExtractorLink(
"tvpolen.ml",
this.name,
data,
"",
Qualities.Unknown.value,
isM3u8 = true
)
)
return true
}
}

View file

@ -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 TvpolanProviderPlugin: Plugin() {
override fun load(context: Context) {
registerMainAPI(TvpolanProvider())
}
}