moved vidsrc to extractor, fixed #1350

This commit is contained in:
LagradOst 2022-07-27 18:27:49 +02:00
parent bec9a87eed
commit 8340d364f9
4 changed files with 63 additions and 33 deletions

View File

@ -0,0 +1,46 @@
package com.lagradost.cloudstream3.extractors
import com.lagradost.cloudstream3.apmap
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import com.lagradost.cloudstream3.utils.loadExtractor
class VidSrcExtractor : ExtractorApi() {
override val name = "VidSrc"
override val mainUrl = "https://v2.vidsrc.me"
override val requiresReferer = false
override suspend fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
val iframedoc = app.get(url).document
val serverslist = iframedoc.select("div#sources.button_content div#content div#list div").map {
val datahash = it.attr("data-hash")
if (datahash.isNotBlank()) {
val links = try {
app.get("$mainUrl/src/$datahash", referer = "https://source.vidsrc.me/").url
} catch (e: Exception) {
""
}
links
} else ""
}
return serverslist.apmap { server ->
val linkfixed = server.replace("https://vidsrc.xyz/","https://embedsito.com/")
if (linkfixed.contains("/pro")) {
val srcresponse = app.get(server, referer = mainUrl).text
val m3u8Regex = Regex("((https:|http:)//.*\\.m3u8)")
val srcm3u8 = m3u8Regex.find(srcresponse)?.value ?: return@apmap listOf()
M3u8Helper.generateM3u8(
name,
srcm3u8,
mainUrl
)
} else {
loadExtractor(linkfixed, url)
}
}.flatten()
}
}

View File

@ -1,12 +1,12 @@
package com.lagradost.cloudstream3.movieproviders
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.extractors.VidSrcExtractor
import com.lagradost.cloudstream3.metaproviders.TmdbLink
import com.lagradost.cloudstream3.metaproviders.TmdbProvider
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8
import com.lagradost.cloudstream3.utils.loadExtractor
class VidSrcProvider : TmdbProvider() {
override val apiName = "VidSrc"
@ -19,6 +19,10 @@ class VidSrcProvider : TmdbProvider() {
TvType.TvSeries,
)
companion object {
val extractor = VidSrcExtractor()
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
@ -32,41 +36,15 @@ class VidSrcProvider : TmdbProvider() {
) else listOf(mappedData.tmdbID.toString(), "tmdb")
val isMovie = mappedData.episode == null && mappedData.season == null
val embedUrl = if (isMovie) {
if(site == "imdb") "$mainUrl/embed/$id" else
if (site == "imdb") "$mainUrl/embed/$id" else
"$mainUrl/embed/$id"
} else {
val suffix = "$id/${mappedData.season ?: 1}-${mappedData.episode ?: 1}"
if (site == "imdb") "$mainUrl/embed/$suffix" else
"$mainUrl/embed/$suffix"
}
val iframedoc = app.get(embedUrl).document
val serverslist = iframedoc.select("div#sources.button_content div#content div#list div").map {
val datahash = it.attr("data-hash")
if (datahash.isNotBlank()) {
val links = try {
app.get("$mainUrl/src/$datahash", referer = "https://source.vidsrc.me/").url
} catch (e: Exception) {
""
}
links
} else ""
}
serverslist.apmap { server ->
val linkfixed = server.replace("https://vidsrc.xyz/","https://embedsito.com/")
if (linkfixed.contains("/pro")) {
val srcresponse = app.get(server, referer = mainUrl).text
val m3u8Regex = Regex("((https:|http:)\\/\\/.*\\.m3u8)")
val srcm3u8 = m3u8Regex.find(srcresponse)?.value ?: return@apmap false
generateM3u8(
name,
srcm3u8,
mainUrl
).forEach(callback)
} else
loadExtractor(linkfixed, embedUrl, callback)
}
extractor.getSafeUrl(embedUrl)?.forEach(callback) ?: return false
return true
}

View File

@ -664,6 +664,11 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
override fun playerError(exception: Exception) {
Log.i(TAG, "playerError = $currentSelectedLink")
super.playerError(exception)
}
private fun noLinksFound() {
showToast(activity, R.string.no_links_found_toast, Toast.LENGTH_SHORT)
activity?.popCurrentPage()

View File

@ -144,7 +144,7 @@ fun getAndUnpack(string: String): String {
return JsUnpacker(packedText).unpack() ?: string
}
suspend fun unshortenLinkSafe(url : String) : String {
suspend fun unshortenLinkSafe(url: String): String {
return try {
if (ShortLink.isShortLink(url))
ShortLink.unshorten(url)
@ -312,7 +312,8 @@ val extractorApis: Array<ExtractorApi> = arrayOf(
YoutubeExtractor(),
YoutubeShortLinkExtractor(),
Streamlare()
Streamlare(),
VidSrcExtractor(),
)
fun getExtractorApiFromName(name: String): ExtractorApi {