added Useetv (#9)

* add Useetv

* fixes
This commit is contained in:
Hexated 2022-09-02 04:26:24 +07:00 committed by GitHub
parent 4b1b6626e6
commit 9b35c6acd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 134 additions and 0 deletions

25
UseeTv/build.gradle.kts Normal file
View file

@ -0,0 +1,25 @@
// use an integer for version numbers
version = 1
cloudstream {
language = "id"
// 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(
"Live",
)
iconUrl = "https://www.google.com/s2/favicons?domain=useetv.com&sz=%size%"
}

View file

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

View file

@ -0,0 +1,93 @@
package com.lagradost
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import org.jsoup.nodes.Element
class UseeTv : MainAPI() {
override var mainUrl = "https://www.useetv.com"
override var name = "Useetv"
override var lang = "id"
override val hasDownloadSupport = false
override val hasMainPage = true
override val supportedTypes = setOf(
TvType.Live
)
companion object {
private const val mainLink = "https://streaming.useetv.com"
}
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val document = app.get("$mainUrl/tv/live").document
val home = listOf(
Pair("col-xs-4", "Semua"),
Pair("local", "Local"),
Pair("news", "News"),
).map { (soap,name) ->
val home = document.select("div#channelContainer div.col-channel").mapNotNull { it }.filter {
it.attr("class").contains(soap, true)
}.mapNotNull {
it.toSearchResult()
}
HomePageList(name, home)
}.filter { it.list.isNotEmpty() }
return HomePageResponse(home)
}
private fun Element.toSearchResult(): LiveSearchResponse? {
return LiveSearchResponse(
this.selectFirst("a")?.attr("data-name") ?: return null,
fixUrl(this.selectFirst("a")!!.attr("href")),
this@UseeTv.name,
TvType.Live,
fixUrlNull(this.select("img").attr("data-src")),
)
}
override suspend fun search(query: String): List<SearchResponse> {
return app.get("$mainUrl/tv/live").document.select("div#channelContainer div.col-channel").mapNotNull {
it
}.filter { it.select("a").attr("data-name").contains(query, true) }.mapNotNull {
it.toSearchResult()
}
}
override suspend fun load(url: String): LoadResponse? {
val document = app.get(url).document
val content = document.selectFirst("div.d-flex.video-schedule-time p")?.text()?.split("")
val link = document.select("script").findLast { it.data().contains("\$('.live').last()") }?.data()?.let{
Regex("'$mainLink(.*)';var").find(it)?.groupValues?.getOrNull(1)
}
return LiveStreamLoadResponse(
content?.firstOrNull()?.trim() ?: return null,
url,
this.name,
"$mainLink$link",
fixUrlNull(document.selectFirst("div.row.video-schedule img")?.attr("src")),
plot = document.selectFirst("title")?.text()
)
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
M3u8Helper.generateM3u8(
this.name,
data,
mainUrl
).forEach(callback)
return true
}
}

View file

@ -0,0 +1,14 @@
package com.lagradost
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
@CloudstreamPlugin
class UseeTvPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(UseeTv())
}
}