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

View file

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