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 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.TmdbLink
import com.lagradost.cloudstream3.metaproviders.TmdbProvider import com.lagradost.cloudstream3.metaproviders.TmdbProvider
import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper.Companion.generateM3u8
import com.lagradost.cloudstream3.utils.loadExtractor
class VidSrcProvider : TmdbProvider() { class VidSrcProvider : TmdbProvider() {
override val apiName = "VidSrc" override val apiName = "VidSrc"
@ -19,6 +19,10 @@ class VidSrcProvider : TmdbProvider() {
TvType.TvSeries, TvType.TvSeries,
) )
companion object {
val extractor = VidSrcExtractor()
}
override suspend fun loadLinks( override suspend fun loadLinks(
data: String, data: String,
isCasting: Boolean, isCasting: Boolean,
@ -32,41 +36,15 @@ class VidSrcProvider : TmdbProvider() {
) else listOf(mappedData.tmdbID.toString(), "tmdb") ) else listOf(mappedData.tmdbID.toString(), "tmdb")
val isMovie = mappedData.episode == null && mappedData.season == null val isMovie = mappedData.episode == null && mappedData.season == null
val embedUrl = if (isMovie) { val embedUrl = if (isMovie) {
if(site == "imdb") "$mainUrl/embed/$id" else if (site == "imdb") "$mainUrl/embed/$id" else
"$mainUrl/embed/$id" "$mainUrl/embed/$id"
} else { } else {
val suffix = "$id/${mappedData.season ?: 1}-${mappedData.episode ?: 1}" val suffix = "$id/${mappedData.season ?: 1}-${mappedData.episode ?: 1}"
if (site == "imdb") "$mainUrl/embed/$suffix" else if (site == "imdb") "$mainUrl/embed/$suffix" else
"$mainUrl/embed/$suffix" "$mainUrl/embed/$suffix"
} }
val iframedoc = app.get(embedUrl).document
val serverslist = iframedoc.select("div#sources.button_content div#content div#list div").map { extractor.getSafeUrl(embedUrl)?.forEach(callback) ?: return false
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)
}
return true 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() { private fun noLinksFound() {
showToast(activity, R.string.no_links_found_toast, Toast.LENGTH_SHORT) showToast(activity, R.string.no_links_found_toast, Toast.LENGTH_SHORT)
activity?.popCurrentPage() activity?.popCurrentPage()

View file

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