Fixed ihavenotv, closes #1292

This commit is contained in:
Blatzar 2022-07-16 21:35:58 +02:00
parent bb7400638a
commit 30f2b4b782
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
}