cloudstream-extensions-mult.../WiflixProvider/src/main/kotlin/com/lagradost/StreamSBPlusExtractor.kt

81 lines
3.3 KiB
Kotlin
Raw Normal View History

add VostfreeProvider (#16) * add VostfreeProvider * autoformat the code and add the changes requested * remove com.lagradost.cloudstream3.animeproviders line * optimized the getMainPage * Add Sarlay's provider * fix the research function and reshape the load * Add NekosamaProvider * add fuzzy for computing string distance * correct the name of class * fix and improve the search function * rename nekosama class * Remove no french provider * NekosamaProvider working version * Revert "Remove no french provider" This reverts commit b177de518dd429010b8b8ddc569940d9d11cc6d7. * use of apmap when necessary * Nekosama add more results items from search * Load function of vostfree optimized * "" * resolve conflict * Add WiflixProvider * Change title and use apmap * No vostfree reference * Add tags and complete season * precise dub ou sub * Update FrenchStream * not anime movie * Fix load movie for vostfree * Add vido extractor for frenchStream * fix reference vido * doodstream work for Wiflix * Udate vidoExtractor to take in account Wiflix ! Optimized FrenchStream to take directly the redirected link * In Frenchstream dood is in reality streamlare * Get MesFilmsProvider directly at Sarlay repository * Requested changes are done * Add showStatus to NekoSamaProvider * show news episodes for neko-sama * Requested changes done * Add year for episodes * French Stream change his mainUrl * Improve research for wiflix * add year of episodes and show the latest episode for vostfree * Add more provider for Wiflix * open the good extractor * Fix Extractor * change authors Co-authored-by: Eddy <kingkama976@gmail.com>
2022-09-26 15:20:08 +00:00
package com.lagradost
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
// This is a modified version of https://github.com/jmir1/aniyomi-extensions/blob/master/src/en/genoanime/src/eu/kanade/tachiyomi/animeextension/en/genoanime/extractors/StreamSBExtractor.kt
// The following code is under the Apache License 2.0 https://github.com/jmir1/aniyomi-extensions/blob/master/LICENSE
open class StreamSBPlusExtractor : ExtractorApi() {
override var name = "StreamSB"
override var mainUrl = "https://sbspeed.com"
override val requiresReferer = false
private val hexArray = "0123456789ABCDEF".toCharArray()
private fun bytesToHex(bytes: ByteArray): String {
val hexChars = CharArray(bytes.size * 2)
for (j in bytes.indices) {
val v = bytes[j].toInt() and 0xFF
hexChars[j * 2] = hexArray[v ushr 4]
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
}
return String(hexChars)
}
data class Subs (
@JsonProperty("file") val file: String,
@JsonProperty("label") val label: String,
)
data class StreamData (
@JsonProperty("file") val file: String,
@JsonProperty("cdn_img") val cdnImg: String,
@JsonProperty("hash") val hash: String,
@JsonProperty("subs") val subs: List<Subs>?,
@JsonProperty("length") val length: String,
@JsonProperty("id") val id: String,
@JsonProperty("title") val title: String,
@JsonProperty("backup") val backup: String,
)
data class Main (
@JsonProperty("stream_data") val streamData: StreamData,
@JsonProperty("status_code") val statusCode: Int,
)
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val regexID =
Regex("(embed-[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+|/e/[a-zA-Z0-9]{0,8}[a-zA-Z0-9_-]+)")
val id = regexID.findAll(url).map {
it.value.replace(Regex("(embed-|/e/)"), "")
}.first()
// val master = "$mainUrl/sources48/6d6144797752744a454267617c7c${bytesToHex.lowercase()}7c7c4e61755a56456f34385243727c7c73747265616d7362/6b4a33767968506e4e71374f7c7c343837323439333133333462353935333633373836643638376337633462333634663539343137373761333635313533333835333763376333393636363133393635366136323733343435323332376137633763373337343732363536313664373336327c7c504d754478413835306633797c7c73747265616d7362"
val master = "$mainUrl/sources48/" + bytesToHex("||$id||||streamsb".toByteArray()) + "/"
val headers = mapOf(
"watchsb" to "sbstream",
)
val mapped = app.get(
master.lowercase(),
headers = headers,
referer = url,
).parsedSafe<Main>()
// val urlmain = mapped.streamData.file.substringBefore("/hls/")
M3u8Helper.generateM3u8(
name,
mapped?.streamData?.file ?: return,
url,
headers = headers
).forEach(callback)
}
}