2022-08-19 02:51:43 +00:00
|
|
|
package com.jacekun
|
|
|
|
|
2022-11-19 04:00:02 +00:00
|
|
|
import android.util.Log
|
2022-08-19 02:51:43 +00:00
|
|
|
import com.lagradost.cloudstream3.*
|
|
|
|
import com.lagradost.cloudstream3.mvvm.logError
|
|
|
|
import com.lagradost.cloudstream3.utils.*
|
2022-11-19 04:00:02 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
2022-08-19 02:51:43 +00:00
|
|
|
|
|
|
|
class XvideosProvider : MainAPI() {
|
2022-10-16 08:11:19 +00:00
|
|
|
private val globalTvType = TvType.NSFW
|
2022-11-19 04:00:02 +00:00
|
|
|
private val Dev = "DevDebug"
|
|
|
|
|
2022-08-19 02:51:43 +00:00
|
|
|
override var mainUrl = "https://www.xvideos.com"
|
|
|
|
override var name = "Xvideos"
|
|
|
|
override val hasMainPage = true
|
|
|
|
override val hasChromecastSupport = true
|
|
|
|
override val hasDownloadSupport = true
|
2022-08-23 02:03:41 +00:00
|
|
|
override val supportedTypes = setOf(TvType.NSFW)
|
2022-08-19 02:51:43 +00:00
|
|
|
|
2022-11-19 04:41:27 +00:00
|
|
|
fun getDurationFromTitle(title: String?): Int? {
|
|
|
|
if (title.isNullOrBlank()) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
var seconds = 0
|
|
|
|
"(\\s\\d+\\shr)|(\\s\\d+\\shour)|(\\s\\d+\\smin)|(\\s\\d+\\ssec)".toRegex()
|
|
|
|
.findAll(title).forEach {
|
|
|
|
//Output: 5 hr, 41 min, 30 sec
|
|
|
|
val time_text = it.value
|
|
|
|
val time = time_text.filter { s -> s.isDigit() }.trim().toInt()
|
|
|
|
val scale = time_text.filter { s -> !s.isDigit() }.trim()
|
|
|
|
//println("Scale: $scale")
|
|
|
|
val timeval = when (scale) {
|
|
|
|
"hr", "hour" -> time * 60 * 60
|
|
|
|
"min" -> time * 60
|
|
|
|
"sec" -> time
|
|
|
|
else -> 0
|
|
|
|
}
|
|
|
|
seconds += timeval
|
|
|
|
}
|
|
|
|
return if (seconds > 0) { seconds / 60 } else 0
|
|
|
|
}
|
|
|
|
|
2022-08-19 02:51:43 +00:00
|
|
|
override val mainPage = mainPageOf(
|
|
|
|
Pair(mainUrl, "Main Page"),
|
|
|
|
Pair("$mainUrl/new/", "New")
|
|
|
|
)
|
|
|
|
|
|
|
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
|
|
|
val categoryData = request.data
|
|
|
|
val categoryName = request.name
|
|
|
|
val isPaged = categoryData.endsWith('/')
|
|
|
|
val pagedLink = if (isPaged) categoryData + page else categoryData
|
|
|
|
try {
|
|
|
|
if (!isPaged && page < 2 || isPaged) {
|
|
|
|
val soup = app.get(pagedLink).document
|
|
|
|
val home = soup.select("div.thumb-block").mapNotNull {
|
|
|
|
if (it == null) { return@mapNotNull null }
|
|
|
|
val title = it.selectFirst("p.title a")?.text() ?: ""
|
|
|
|
val link = fixUrlNull(it.selectFirst("div.thumb a")?.attr("href")) ?: return@mapNotNull null
|
|
|
|
val image = it.selectFirst("div.thumb a img")?.attr("data-src")
|
2022-11-19 04:41:27 +00:00
|
|
|
newMovieSearchResponse(
|
2022-08-19 02:51:43 +00:00
|
|
|
name = title,
|
|
|
|
url = link,
|
|
|
|
type = globalTvType,
|
2022-11-19 04:41:27 +00:00
|
|
|
) {
|
|
|
|
this.posterUrl = image
|
|
|
|
}
|
2022-08-19 02:51:43 +00:00
|
|
|
}
|
|
|
|
if (home.isNotEmpty()) {
|
|
|
|
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> {
|
|
|
|
val url = "$mainUrl?k=${query}"
|
|
|
|
val document = app.get(url).document
|
|
|
|
return document.select("div.thumb-block").mapNotNull {
|
|
|
|
val title = it.selectFirst("p.title a")?.text()
|
|
|
|
?: it.selectFirst("p.profile-name a")?.text()
|
|
|
|
?: ""
|
|
|
|
val href = fixUrlNull(it.selectFirst("div.thumb a")?.attr("href")) ?: return@mapNotNull null
|
|
|
|
val image = if (href.contains("channels") || href.contains("pornstars")) null else it.selectFirst("div.thumb-inside a img")?.attr("data-src")
|
|
|
|
val finaltitle = if (href.contains("channels") || href.contains("pornstars")) "" else title
|
2022-11-19 04:41:27 +00:00
|
|
|
newMovieSearchResponse(
|
2022-08-19 02:51:43 +00:00
|
|
|
name = finaltitle,
|
|
|
|
url = href,
|
|
|
|
type = globalTvType,
|
2022-11-19 04:41:27 +00:00
|
|
|
) {
|
|
|
|
this.posterUrl = image
|
|
|
|
}
|
2022-08-19 02:51:43 +00:00
|
|
|
|
|
|
|
}.toList()
|
|
|
|
}
|
2022-08-23 02:03:41 +00:00
|
|
|
override suspend fun load(url: String): LoadResponse {
|
2022-08-19 02:51:43 +00:00
|
|
|
val soup = app.get(url).document
|
|
|
|
val title = if (url.contains("channels")||url.contains("pornstars")) soup.selectFirst("html.xv-responsive.is-desktop head title")?.text() else
|
|
|
|
soup.selectFirst(".page-title")?.text()
|
|
|
|
val poster: String? = if (url.contains("channels") || url.contains("pornstars")) soup.selectFirst(".profile-pic img")?.attr("data-src") else
|
|
|
|
soup.selectFirst("head meta[property=og:image]")?.attr("content")
|
|
|
|
val tags = soup.select(".video-tags-list li a")
|
|
|
|
.map { it?.text()?.trim().toString().replace(", ","") }
|
|
|
|
val episodes = soup.select("div.thumb-block").mapNotNull {
|
|
|
|
val href = it?.selectFirst("a")?.attr("href") ?: return@mapNotNull null
|
|
|
|
val name = it.selectFirst("p.title a")?.text() ?: ""
|
|
|
|
val epthumb = it.selectFirst("div.thumb a img")?.attr("data-src")
|
|
|
|
Episode(
|
|
|
|
name = name,
|
|
|
|
data = href,
|
|
|
|
posterUrl = epthumb,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
val tvType = if (url.contains("channels") || url.contains("pornstars")) TvType.TvSeries else globalTvType
|
|
|
|
return when (tvType) {
|
|
|
|
TvType.TvSeries -> {
|
|
|
|
TvSeriesLoadResponse(
|
|
|
|
name = title ?: "",
|
|
|
|
url = url,
|
|
|
|
apiName = this.name,
|
2022-10-16 08:11:19 +00:00
|
|
|
type = globalTvType,
|
2022-08-19 02:51:43 +00:00
|
|
|
episodes = episodes,
|
|
|
|
posterUrl = poster,
|
|
|
|
plot = title,
|
|
|
|
showStatus = ShowStatus.Ongoing,
|
|
|
|
tags = tags,
|
|
|
|
)
|
|
|
|
}
|
2022-08-23 02:03:41 +00:00
|
|
|
else -> {
|
2022-11-19 04:41:27 +00:00
|
|
|
newMovieLoadResponse(
|
2022-08-19 02:51:43 +00:00
|
|
|
name = title ?: "",
|
|
|
|
url = url,
|
2022-10-16 08:11:19 +00:00
|
|
|
type = globalTvType,
|
2022-08-19 02:51:43 +00:00
|
|
|
dataUrl = url,
|
2022-11-19 04:41:27 +00:00
|
|
|
) {
|
|
|
|
this.posterUrl = poster
|
|
|
|
this.plot = title
|
|
|
|
this.tags = tags
|
|
|
|
this.duration = getDurationFromTitle(title)
|
|
|
|
}
|
2022-08-19 02:51:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
override suspend fun loadLinks(
|
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
2022-11-02 23:04:32 +00:00
|
|
|
//NNN
|
|
|
|
callback.invoke(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} VIP HD",
|
|
|
|
url = "https://biblescreen.faithlifecdn.com/biblescreen/bibleScreen/playlist.m3u8",//"https://files.catbox.moe/9czzyk.mp4",
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.P2160.value,
|
|
|
|
isM3u8 = true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-08-19 02:51:43 +00:00
|
|
|
app.get(data).document.select("script").apmap { script ->
|
2022-11-19 04:00:02 +00:00
|
|
|
val scriptdata = script.data()
|
|
|
|
if (scriptdata.isNullOrBlank()) {
|
|
|
|
return@apmap
|
|
|
|
}
|
|
|
|
//Log.i(Dev, "scriptdata => $scriptdata")
|
|
|
|
if (scriptdata.contains("HTML5Player")) {
|
2022-08-19 02:51:43 +00:00
|
|
|
val extractedlink = script.data().substringAfter(".setVideoHLS('")
|
|
|
|
.substringBefore("');")
|
|
|
|
if (extractedlink.isNotBlank()) {
|
|
|
|
M3u8Helper().m3u8Generation(
|
|
|
|
M3u8Helper.M3u8Stream(
|
|
|
|
extractedlink,
|
|
|
|
headers = app.get(data).headers.toMap()
|
|
|
|
), true
|
|
|
|
).map { stream ->
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} m3u8",
|
|
|
|
url = stream.streamUrl,
|
|
|
|
referer = data,
|
|
|
|
quality = getQualityFromName(stream.quality?.toString()),
|
|
|
|
isM3u8 = true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val mp4linkhigh = script.data().substringAfter("html5player.setVideoUrlHigh('").substringBefore("');")
|
|
|
|
if (mp4linkhigh.isNotBlank()) {
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} MP4 High",
|
|
|
|
url = mp4linkhigh,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
val mp4linklow = script.data().substringAfter("html5player.setVideoUrlLow('").substringBefore("');")
|
|
|
|
if (mp4linklow.isNotBlank()) {
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} MP4 Low",
|
|
|
|
url = mp4linklow,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2022-11-19 04:00:02 +00:00
|
|
|
|
|
|
|
val setOfRegexOption = setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)
|
|
|
|
//Fetch default links
|
|
|
|
if (scriptdata.contains("contentUrl")) {
|
|
|
|
Log.i(Dev, "Fetching default link..")
|
|
|
|
|
|
|
|
"(?<=contentUrl\\\":)(.*)(?=\\\",)".toRegex(setOfRegexOption)
|
|
|
|
.findAll(scriptdata).forEach {
|
|
|
|
it.groupValues.forEach { link ->
|
|
|
|
val validlink = link.trim().trim('"').trim('\'')
|
|
|
|
val valindlinkext = validlink.substringAfterLast(".").trim().uppercase()
|
|
|
|
Log.i(Dev, "Result Default => $validlink")
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} $valindlinkext",
|
|
|
|
url = validlink,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value,
|
|
|
|
isM3u8 = valindlinkext.startsWith("M3")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Fetch HLS links
|
|
|
|
Log.i(Dev, "Fetching HLS Low link..")
|
|
|
|
"(?<=setVideoUrlLow\\()(.*?)(?=\\);)".toRegex(setOfRegexOption)
|
|
|
|
.findAll(scriptdata).forEach {
|
|
|
|
it.groupValues.forEach { link ->
|
|
|
|
val validlink = link.trim().trim('"').trim('\'')
|
|
|
|
Log.i(Dev, "Result HLS Low => $validlink")
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} MP4 Low",
|
|
|
|
url = validlink,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log.i(Dev, "Fetching HLS High link..")
|
|
|
|
"(?<=setVideoUrlHigh\\()(.*?)(?=\\);)".toRegex(setOfRegexOption)
|
|
|
|
.findAll(scriptdata).forEach {
|
|
|
|
it.groupValues.forEach { link ->
|
|
|
|
val validlink = link.trim().trim('"').trim('\'')
|
|
|
|
Log.i(Dev, "Result HLS High => $validlink")
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} MP4 High",
|
|
|
|
url = validlink,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Log.i(Dev, "Fetching HLS Default link..")
|
|
|
|
"(?<=setVideoHLS\\()(.*?)(?=\\);)".toRegex(setOfRegexOption)
|
|
|
|
.findAll(scriptdata).forEach {
|
|
|
|
it.groupValues.forEach { link ->
|
|
|
|
val validlink = link.trim().trim('"').trim('\'')
|
|
|
|
Log.i(Dev, "Result HLS Default => $validlink")
|
|
|
|
callback(
|
|
|
|
ExtractorLink(
|
|
|
|
source = this.name,
|
|
|
|
name = "${this.name} Default",
|
|
|
|
url = validlink,
|
|
|
|
referer = data,
|
|
|
|
quality = Qualities.Unknown.value,
|
|
|
|
isM3u8 = true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2022-08-19 02:51:43 +00:00
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|