cloudstream-extensions-hexated/GoodPorn/src/main/kotlin/com/hexated/GoodPorn.kt

126 lines
5.5 KiB
Kotlin
Raw Normal View History

2022-09-11 13:00:33 +00:00
package com.hexated
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.utils.*
import org.jsoup.nodes.Element
2022-09-11 21:08:35 +00:00
import java.util.*
2022-09-11 13:00:33 +00:00
class GoodPorn : MainAPI() {
override var mainUrl = "https://goodporn.to"
override var name = "GoodPorn"
override val hasMainPage = true
override val hasDownloadSupport = true
2022-09-11 21:27:22 +00:00
override val vpnStatus = VPNStatus.MightBeNeeded
2022-09-11 13:00:33 +00:00
override val supportedTypes = setOf(TvType.NSFW)
override val mainPage = mainPageOf(
"$mainUrl/?mode=async&function=get_block&block_id=list_videos_most_recent_videos&sort_by=post_date&from=" to "New Videos",
"$mainUrl/?mode=async&function=get_block&block_id=list_videos_most_recent_videos&sort_by=video_viewed&from=" to "Most Viewed Videos",
"$mainUrl/?mode=async&function=get_block&block_id=list_videos_most_recent_videos&sort_by=rating&from=" to "Top Rated Videos ",
2022-09-12 16:44:05 +00:00
"$mainUrl/?mode=async&function=get_block&block_id=list_videos_most_recent_videos&sort_by=most_commented&from=" to "Most Commented Videos",
2022-09-11 13:00:33 +00:00
"$mainUrl/?mode=async&function=get_block&block_id=list_videos_most_recent_videos&sort_by=duration&from=" to "Longest Videos",
2022-09-12 16:44:05 +00:00
"$mainUrl/channels/brazzers/?mode=async&function=get_block&block_id=list_videos_common_videos_list&sort_by=post_date&from=" to "Brazzers",
"$mainUrl/channels/digitalplayground/?mode=async&function=get_block&block_id=list_videos_common_videos_list&sort_by=post_date&from=" to "Digital Playground",
"$mainUrl/channels/realitykings/?mode=async&function=get_block&block_id=list_videos_common_videos_list&sort_by=post_date&from=" to "Realitykings",
"$mainUrl/channels/babes-network/?mode=async&function=get_block&block_id=list_videos_common_videos_list&sort_by=post_date&from=" to "Babes Network",
2022-09-11 13:00:33 +00:00
)
override suspend fun getMainPage(
page: Int,
request: MainPageRequest
): HomePageResponse {
val document = app.get(request.data + page).document
2022-10-16 04:04:59 +00:00
val home =
document.select("div#list_videos_most_recent_videos_items div.item, div#list_videos_common_videos_list_items div.item")
.mapNotNull {
it.toSearchResult()
}
2022-09-11 13:00:33 +00:00
return newHomePageResponse(
list = HomePageList(
name = request.name,
list = home,
isHorizontalImages = true
),
hasNext = true
)
}
private fun Element.toSearchResult(): SearchResponse? {
val title = this.selectFirst("strong.title")?.text() ?: return null
val href = fixUrl(this.selectFirst("a")!!.attr("href"))
val posterUrl = fixUrlNull(this.select("div.img > img").attr("data-original"))
return newMovieSearchResponse(title, href, TvType.Movie) {
this.posterUrl = posterUrl
}
}
override suspend fun search(query: String): List<SearchResponse> {
2022-10-15 23:11:19 +00:00
val searchResponse = mutableListOf<SearchResponse>()
2022-10-16 04:04:59 +00:00
for (i in 1..15) {
2022-10-15 23:11:19 +00:00
val document =
app.get(
"$mainUrl/search/nikki-benz/?mode=async&function=get_block&block_id=list_videos_videos_list_search_result&q=$query&category_ids=&sort_by=&from_videos=$i&from_albums=$i",
headers = mapOf("X-Requested-With" to "XMLHttpRequest")
).document
2022-10-16 04:04:59 +00:00
val results =
document.select("div#list_videos_videos_list_search_result_items div.item")
.mapNotNull {
it.toSearchResult()
}
searchResponse.addAll(results)
if (results.isEmpty()) break
2022-10-15 23:11:19 +00:00
}
return searchResponse
2022-09-11 13:00:33 +00:00
}
override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document
val title = document.selectFirst("div.headline > h1")?.text()?.trim().toString()
val poster =
fixUrlNull(document.selectFirst("meta[property=og:image]")?.attr("content").toString())
val tags = document.select("div.info div:nth-child(5) > a").map { it.text() }
val description = document.select("div.info div:nth-child(2)").text().trim()
val actors = document.select("div.info div:nth-child(6) > a").map { it.text() }
val recommendations =
2022-09-11 13:33:05 +00:00
document.select("div#list_videos_related_videos_items div.item").mapNotNull {
2022-09-11 13:00:33 +00:00
it.toSearchResult()
}
return newMovieLoadResponse(title, url, TvType.Movie, url) {
this.posterUrl = poster
this.plot = description
this.tags = tags
addActors(actors)
this.recommendations = recommendations
}
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
val document = app.get(data).document
document.select("div.info div:last-child a").map { res ->
callback.invoke(
ExtractorLink(
this.name,
this.name,
2022-10-16 04:04:59 +00:00
res.attr("href")
.replace(Regex("\\?download\\S+.mp4&"), "?") + "&rnd=${Date().time}",
2022-09-11 13:00:33 +00:00
referer = data,
quality = Regex("([0-9]+p),").find(res.text())?.groupValues?.get(1)
.let { getQualityFromName(it) },
headers = mapOf("Range" to "bytes=0-"),
)
)
}
return true
}
}