gogo: fix vidstreaming & add streamsb
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
||||
extName = 'Gogoanime'
|
||||
pkgNameSuffix = 'en.gogoanime'
|
||||
extClass = '.GogoAnime'
|
||||
extVersionCode = 40
|
||||
extVersionCode = 41
|
||||
libVersion = '12'
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.en.gogoanime.extractors.DoodExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.en.gogoanime.extractors.GogoCdnExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.en.gogoanime.extractors.StreamSBExtractor
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
@ -90,7 +91,7 @@ class GogoAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val document = response.asJsoup()
|
||||
val extractor = GogoCdnExtractor(client, json)
|
||||
val extractor = GogoCdnExtractor(network.client, json)
|
||||
val videoList = mutableListOf<Video>()
|
||||
// GogoCdn:
|
||||
document.select("div.anime_muti_link > ul > li.vidcdn > a")
|
||||
@ -104,6 +105,10 @@ class GogoAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
document.select("div.anime_muti_link > ul > li.doodstream > a")
|
||||
.firstOrNull()?.attr("data-video")
|
||||
?.let { videoList.addAll(DoodExtractor(client).videosFromUrl(it)) }
|
||||
// StreamSB mirror:
|
||||
document.select("div.anime_muti_link > ul > li.streamsb > a")
|
||||
.firstOrNull()?.attr("data-video")
|
||||
?.let { videoList.addAll(StreamSBExtractor(client).videosFromUrl(it, headers)) }
|
||||
return videoList
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class DoodExtractor(private val client: OkHttpClient) {
|
||||
)
|
||||
).execute().body!!.string()
|
||||
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
||||
return listOf(Video(serverUrl, "Doodstream mirror", videoUrl, null, doodHeaders(doodTld)))
|
||||
return listOf(Video(serverUrl, "Doodstream", videoUrl, null, doodHeaders(doodTld)))
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.animeextension.en.gogoanime.extractors
|
||||
|
||||
import android.util.Base64
|
||||
import android.util.Log
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
@ -24,6 +25,7 @@ import javax.crypto.spec.SecretKeySpec
|
||||
class GogoCdnExtractor(private val client: OkHttpClient, private val json: Json) {
|
||||
fun videosFromUrl(serverUrl: String): List<Video> {
|
||||
try {
|
||||
Log.i("bruh", serverUrl)
|
||||
val document = client.newCall(GET(serverUrl)).execute().asJsoup()
|
||||
val iv = document.select("div.wrapper")
|
||||
.attr("class").substringAfter("container-")
|
||||
@ -34,23 +36,26 @@ class GogoCdnExtractor(private val client: OkHttpClient, private val json: Json)
|
||||
val decryptionKey = document.select("div.videocontent")
|
||||
.attr("class").substringAfter("videocontent-")
|
||||
.filter { it.isDigit() }.toByteArray()
|
||||
val encryptAjaxParams = cryptoHandler(
|
||||
document.select("script[data-value]")
|
||||
.attr("data-value"),
|
||||
iv, secretKey, false
|
||||
).substringAfter("&")
|
||||
Log.i("bruh", encryptAjaxParams)
|
||||
|
||||
val httpUrl = serverUrl.toHttpUrl()
|
||||
val host = "https://" + httpUrl.host + "/"
|
||||
val id = httpUrl.queryParameter("id") ?: throw Exception("error getting id")
|
||||
val encryptedId = cryptoHandler(id, iv, secretKey)
|
||||
Log.i("bruh", "${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id")
|
||||
val token = httpUrl.queryParameter("token")
|
||||
val qualityPrefix = if (token != null) "Gogostream: " else "Vidstreaming: "
|
||||
val tokenString = if (token != null) { "&token=$token&op=2" } else ""
|
||||
|
||||
val encryptedId = cryptoHandler(id, iv, secretKey)
|
||||
|
||||
val jsonResponse = client.newCall(
|
||||
GET(
|
||||
"${host}encrypt-ajax.php?id=$encryptedId$tokenString&alias=$id",
|
||||
"${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id",
|
||||
Headers.headersOf(
|
||||
"X-Requested-With", "XMLHttpRequest",
|
||||
"Referer", host,
|
||||
"Alias", id
|
||||
"X-Requested-With", "XMLHttpRequest"
|
||||
)
|
||||
)
|
||||
).execute().body!!.string()
|
||||
|
@ -0,0 +1,63 @@
|
||||
package eu.kanade.tachiyomi.animeextension.en.gogoanime.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
class StreamSBExtractor(private val client: OkHttpClient) {
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
fun videosFromUrl(url: String, headers: Headers): List<Video> {
|
||||
try {
|
||||
val sbHeaders = headers.newBuilder()
|
||||
.set("Referer", url)
|
||||
.set(
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0"
|
||||
)
|
||||
.set("Accept-Language", "en-US,en;q=0.5")
|
||||
.set("watchsb", "streamsb")
|
||||
.build()
|
||||
val id = url.substringAfter("e/").substringBefore("?")
|
||||
val bytes = id.toByteArray()
|
||||
val bytesToHex = bytesToHex(bytes)
|
||||
val master = "https://sbplay2.com/sources43/566d337678566f743674494a7c7c${bytesToHex}7c7c346b6767586d6934774855537c7c73747265616d7362/6565417268755339773461447c7c346133383438333436313335376136323337373433383634376337633465366534393338373136643732373736343735373237613763376334363733353737303533366236333463353333363534366137633763373337343732363536313664373336327c7c6b586c3163614468645a47617c7c73747265616d7362"
|
||||
val json = Json.decodeFromString<JsonObject>(
|
||||
client.newCall(GET(master, sbHeaders))
|
||||
.execute().body!!.string()
|
||||
)
|
||||
val masterUrl = json["stream_data"]!!.jsonObject["file"].toString().trim('"')
|
||||
val masterPlaylist = client.newCall(GET(masterUrl, sbHeaders)).execute().body!!.string()
|
||||
val videoList = mutableListOf<Video>()
|
||||
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:")
|
||||
.forEach {
|
||||
val quality = "StreamSB: " + it.substringAfter("RESOLUTION=").substringAfter("x")
|
||||
.substringBefore(",") + "p"
|
||||
val videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
videoList.add(Video(videoUrl, quality, videoUrl, null, sbHeaders))
|
||||
}
|
||||
return videoList.reversed()
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user