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,
@ -39,34 +43,8 @@ class VidSrcProvider : TmdbProvider() {
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

@ -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 {