Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt
This commit is contained in:
LagradOst 2022-07-17 02:44:36 +02:00
commit 6d351a4737
2 changed files with 16 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.schemaStripRegex
import org.schabi.newpipe.extractor.ServiceList
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeStreamLinkHandlerFactory
@ -35,7 +36,11 @@ open class YoutubeExtractor : ExtractorApi() {
val streams = safeApiCall {
val streams = ytVideos[url] ?: let {
val link =
YoutubeStreamLinkHandlerFactory.getInstance().fromUrl(url)
YoutubeStreamLinkHandlerFactory.getInstance().fromUrl(
url.replace(
schemaStripRegex, ""
)
)
val s = object : YoutubeStreamExtractor(
ServiceList.YouTube,

View File

@ -40,7 +40,7 @@ data class ExtractorLinkPlayList(
override val headers: Map<String, String> = mapOf(),
/** Used for getExtractorVerifierJob() */
override val extractorData: String? = null,
) : ExtractorLink(
) : ExtractorLink(
source,
name,
// Blank as un-used
@ -92,6 +92,12 @@ data class ExtractorSubtitleLink(
override val headers: Map<String, String> = mapOf()
) : VideoDownloadManager.IDownloadableMinimum
/**
* Removes https:// and www.
* To match urls regardless of schema, perhaps Uri() can be used?
*/
val schemaStripRegex = Regex("""^(https:|)//(www\.|)""")
enum class Qualities(var value: Int) {
Unknown(400),
P144(144), // 144p
@ -146,7 +152,9 @@ suspend fun loadExtractor(
callback: (ExtractorLink) -> Unit
): Boolean {
for (extractor in extractorApis) {
if (url.startsWith(extractor.mainUrl)) {
if (url.replace(schemaStripRegex, "")
.startsWith(extractor.mainUrl.replace(schemaStripRegex, ""))
) {
extractor.getSafeUrl(url, referer)?.forEach(callback)
return true
}