Fixes to pornhub
This commit is contained in:
parent
8d30295490
commit
56e5460ced
|
@ -1,12 +1,12 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 5
|
version = 6
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
// All of these properties are optional, you can safely remove them
|
// All of these properties are optional, you can safely remove them
|
||||||
|
|
||||||
description = "Cornhub"
|
description = "Cornhub"
|
||||||
authors = listOf("Stormunblessed", "Jace")
|
authors = listOf("Stormunblessed", "Jace", "KillerDogeEmpire")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status int as the following:
|
* Status int as the following:
|
||||||
|
|
|
@ -1,142 +1,117 @@
|
||||||
package com.jacekun
|
package com.jacekun
|
||||||
|
|
||||||
import com.lagradost.cloudstream3.MainAPI
|
import android.util.Log
|
||||||
import com.lagradost.cloudstream3.TvType
|
|
||||||
import com.lagradost.cloudstream3.*
|
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
|
||||||
import com.lagradost.cloudstream3.network.WebViewResolver
|
|
||||||
import com.lagradost.cloudstream3.utils.*
|
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.*
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
|
|
||||||
class Pornhub : MainAPI() {
|
class PornHub : MainAPI() {
|
||||||
private val globalTvType = TvType.NSFW
|
override var mainUrl = "https://www.pornhub.com"
|
||||||
|
override var name = "PornHub"
|
||||||
override var mainUrl = "https://www.pornhub.com"
|
override val hasMainPage = true
|
||||||
override var name = "Pornhub"
|
override var lang = "en"
|
||||||
override val hasMainPage = true
|
override val hasQuickSearch = false
|
||||||
|
override val hasDownloadSupport = true
|
||||||
override val hasChromecastSupport = true
|
override val hasChromecastSupport = true
|
||||||
override val hasDownloadSupport = true
|
override val supportedTypes = setOf(TvType.NSFW)
|
||||||
override val vpnStatus = VPNStatus.MightBeNeeded //Cause it's a big site
|
override val vpnStatus = VPNStatus.MightBeNeeded
|
||||||
override val supportedTypes = setOf(TvType.NSFW)
|
|
||||||
|
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage = mainPageOf(
|
||||||
"$mainUrl/video?page=" to "Main Page",
|
"${mainUrl}/video?o=mr&hd=1&page=" to "Recently Featured",
|
||||||
|
"${mainUrl}/video?o=tr&t=w&hd=1&page=" to "Top Rated",
|
||||||
|
"${mainUrl}/video?o=mv&t=w&hd=1&page=" to "Most Viewed",
|
||||||
|
"${mainUrl}/video?o=ht&t=w&hd=1&page=" to "Hottest",
|
||||||
|
"${mainUrl}/video?p=professional&hd=1&page=" to "Professional",
|
||||||
|
"${mainUrl}/video?o=lg&hd=1&page=" to "Longest",
|
||||||
|
"${mainUrl}/video?p=homemade&hd=1&page=" to "Homemade",
|
||||||
|
"${mainUrl}/video?o=cm&t=w&hd=1&page=" to "Newest",
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
try {
|
val document = app.get(request.data + page).document
|
||||||
val categoryData = request.data
|
val home = document.select("li.pcVideoListItem").mapNotNull { it.toSearchResult() }
|
||||||
val categoryName = request.name
|
|
||||||
val pagedLink = if (page > 0) categoryData + page else categoryData
|
return newHomePageResponse(
|
||||||
val soup = app.get(pagedLink).document
|
list = HomePageList(
|
||||||
val home = soup.select("div.sectionWrapper div.wrap").mapNotNull {
|
name = request.name,
|
||||||
if (it == null) { return@mapNotNull null }
|
list = home,
|
||||||
val title = it.selectFirst("span.title a")?.text() ?: ""
|
isHorizontalImages = true
|
||||||
val link = fixUrlNull(it.selectFirst("a")?.attr("href")) ?: return@mapNotNull null
|
),
|
||||||
val img = fetchImgUrl(it.selectFirst("img"))
|
hasNext = true
|
||||||
MovieSearchResponse(
|
)
|
||||||
name = title,
|
}
|
||||||
url = link,
|
|
||||||
apiName = this.name,
|
private fun Element.toSearchResult(): SearchResponse? {
|
||||||
type = globalTvType,
|
val title = this.selectFirst("a")?.attr("title") ?: return null
|
||||||
posterUrl = img
|
val link = this.selectFirst("a")?.attr("href") ?: return null
|
||||||
)
|
val posterUrl = fixUrlNull(this.selectFirst("img.thumb")?.attr("src"))
|
||||||
}
|
|
||||||
if (home.isNotEmpty()) {
|
return newMovieSearchResponse(title, link, TvType.Movie) { this.posterUrl = posterUrl }
|
||||||
return newHomePageResponse(
|
|
||||||
list = HomePageList(
|
|
||||||
name = categoryName,
|
|
||||||
list = home,
|
|
||||||
isHorizontalImages = true
|
|
||||||
),
|
|
||||||
hasNext = true
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
throw ErrorLoadingException("No homepage data found!")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
//e.printStackTrace()
|
|
||||||
logError(e)
|
|
||||||
}
|
|
||||||
throw ErrorLoadingException()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val url = "$mainUrl/video/search?search=${query}"
|
val document = app.get("${mainUrl}/video/search?search=${query}").document
|
||||||
val document = app.get(url).document
|
|
||||||
return document.select("div.sectionWrapper div.wrap").mapNotNull {
|
return document.select("li.pcVideoListItem").mapNotNull { it.toSearchResult() }
|
||||||
if (it == null) { return@mapNotNull null }
|
|
||||||
val title = it.selectFirst("span.title a")?.text() ?: return@mapNotNull null
|
|
||||||
val link = fixUrlNull(it.selectFirst("a")?.attr("href")) ?: return@mapNotNull null
|
|
||||||
val image = fetchImgUrl(it.selectFirst("img"))
|
|
||||||
MovieSearchResponse(
|
|
||||||
name = title,
|
|
||||||
url = link,
|
|
||||||
apiName = this.name,
|
|
||||||
type = globalTvType,
|
|
||||||
posterUrl = image
|
|
||||||
)
|
|
||||||
}.distinctBy { it.url }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun quickSearch(query: String): List<SearchResponse> = search(query)
|
||||||
val soup = app.get(url).document
|
|
||||||
val title = soup.selectFirst(".title span")?.text() ?: ""
|
override suspend fun load(url: String): LoadResponse? {
|
||||||
val poster: String? = soup.selectFirst("div.video-wrapper .mainPlayerDiv img")?.attr("src") ?:
|
val document = app.get(url).document
|
||||||
soup.selectFirst("head meta[property=og:image]")?.attr("content")
|
|
||||||
val tags = soup.select("div.categoriesWrapper a")
|
val title = document.selectFirst("h1.title span[class='inlineFree']")?.text()?.trim() ?: return null
|
||||||
.map { it?.text()?.trim().toString().replace(", ","") }
|
val description = title
|
||||||
return MovieLoadResponse(
|
val poster = fixUrlNull(document.selectFirst("div.mainPlayerDiv img")?.attr("src"))
|
||||||
name = title,
|
val year = Regex("""uploadDate\": \"(\d+)""").find(document.html())?.groupValues?.get(1)?.toIntOrNull()
|
||||||
url = url,
|
val tags = document.select("div.categoriesWrapper a[data-label='Category']").map { it?.text()?.trim().toString().replace(", ","") }
|
||||||
apiName = this.name,
|
val rating = document.selectFirst("span.percent")?.text()?.first()?.toString()?.toRatingInt()
|
||||||
type = globalTvType,
|
val duration = Regex("duration' : '(.*)',").find(document.html())?.groupValues?.get(1)?.toIntOrNull()
|
||||||
dataUrl = url,
|
val actors = document.select("div.pornstarsWrapper a[data-label='Pornstar']").mapNotNull {
|
||||||
posterUrl = poster,
|
Actor(it.text().trim(), it.select("img").attr("src"))
|
||||||
tags = tags,
|
}
|
||||||
plot = title
|
|
||||||
)
|
val recommendations = document.selectXpath("//a[contains(@class, 'img')]").mapNotNull {
|
||||||
}
|
val recName = it?.attr("title")?.trim() ?: return@mapNotNull null
|
||||||
override suspend fun loadLinks(
|
val recHref = fixUrlNull(it.attr("href")) ?: return@mapNotNull null
|
||||||
data: String,
|
val recPosterUrl = fixUrlNull(it.selectFirst("img")?.attr("src"))
|
||||||
isCasting: Boolean,
|
newMovieSearchResponse(recName, recHref, TvType.NSFW) {
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
this.posterUrl = recPosterUrl
|
||||||
callback: (ExtractorLink) -> Unit
|
|
||||||
): Boolean {
|
|
||||||
app.get(
|
|
||||||
url = data,
|
|
||||||
interceptor = WebViewResolver(
|
|
||||||
Regex("(master\\.m3u8\\?.*)")
|
|
||||||
)
|
|
||||||
).let { response ->
|
|
||||||
M3u8Helper().m3u8Generation(
|
|
||||||
M3u8Helper.M3u8Stream(
|
|
||||||
response.url,
|
|
||||||
headers = response.headers.toMap()
|
|
||||||
), true
|
|
||||||
).apmap { stream ->
|
|
||||||
callback(
|
|
||||||
ExtractorLink(
|
|
||||||
source = name,
|
|
||||||
name = "${this.name} m3u8",
|
|
||||||
url = stream.streamUrl,
|
|
||||||
referer = mainUrl,
|
|
||||||
quality = getQualityFromName(stream.quality?.toString()),
|
|
||||||
isM3u8 = true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true
|
|
||||||
|
return newMovieLoadResponse(title, url, TvType.NSFW, url) {
|
||||||
|
this.posterUrl = poster
|
||||||
|
this.year = year
|
||||||
|
this.plot = description
|
||||||
|
this.tags = tags
|
||||||
|
this.rating = rating
|
||||||
|
this.duration = duration
|
||||||
|
this.recommendations = recommendations
|
||||||
|
addActors(actors)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchImgUrl(imgsrc: Element?): String? {
|
override suspend fun loadLinks(data: String, isCasting: Boolean, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit): Boolean {
|
||||||
return try { imgsrc?.attr("data-src")
|
Log.d("PHub", "url » ${data}")
|
||||||
?: imgsrc?.attr("data-mediabook")
|
val source = app.get(data).text
|
||||||
?: imgsrc?.attr("alt")
|
val extracted_value = Regex("""([^\"]*master.m3u8?.[^\"]*)""").find(source)?.groups?.last()?.value ?: return false
|
||||||
?: imgsrc?.attr("data-mediumthumb")
|
val m3u_link = extracted_value.replace("\\", "")
|
||||||
?: imgsrc?.attr("data-thumb_url")
|
Log.d("PHub", "extracted_value » ${extracted_value}")
|
||||||
?: imgsrc?.attr("src")
|
Log.d("PHub", "m3u_link » ${m3u_link}")
|
||||||
} catch (e:Exception) { null }
|
|
||||||
|
callback.invoke(
|
||||||
|
ExtractorLink(
|
||||||
|
source = this.name,
|
||||||
|
name = this.name,
|
||||||
|
url = m3u_link,
|
||||||
|
referer = "${mainUrl}/",
|
||||||
|
quality = Qualities.Unknown.value,
|
||||||
|
isM3u8 = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue