Vidembed: Fix server (#313)
* Add streamSb server * update extension version
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
||||
extName = 'Vidembed'
|
||||
pkgNameSuffix = 'en.vidembed'
|
||||
extClass = '.Vidembed'
|
||||
extVersionCode = 3
|
||||
extVersionCode = 4
|
||||
libVersion = '12'
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.en.vidembed.extractors.StreamSBExtractor
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
@ -109,7 +110,11 @@ class Vidembed : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
if (video != null) videoList.add(video)
|
||||
}
|
||||
url.contains("https://sbplay") -> {
|
||||
val videos = sbplayUrlParse(url, location)
|
||||
val newUrl = url.replace("/d/", "/e/")
|
||||
val headers = headers.newBuilder()
|
||||
.set("watchsb", "streamsb")
|
||||
.build()
|
||||
val videos = StreamSBExtractor(client).videosFromUrl(newUrl, headers)
|
||||
videoList.addAll(videos)
|
||||
}
|
||||
else -> {
|
||||
@ -143,43 +148,6 @@ class Vidembed : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
return videoUrl ?: url
|
||||
}
|
||||
|
||||
private fun sbplayUrlParse(url: String, referer: String): List<Video> {
|
||||
val videoList = mutableListOf<Video>()
|
||||
val refererHeader = Headers.headersOf("Referer", referer)
|
||||
val id = Uri.parse(url).pathSegments[1]
|
||||
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
||||
val respDownloadLinkSelector = noRedirectClient.newCall(GET(url, refererHeader)).execute()
|
||||
val documentDownloadSelector = respDownloadLinkSelector.asJsoup()
|
||||
val downloadElements = documentDownloadSelector.select("div.contentbox table tbody tr td a")
|
||||
for (downloadElement in downloadElements) {
|
||||
val videoData = downloadElement.attr("onclick")
|
||||
val quality = downloadElement.text()
|
||||
val hash = videoData.splitToSequence(",").last().replace("\'", "").replace(")", "")
|
||||
val mode =
|
||||
videoData.splitToSequence(",").elementAt(1).replace("\'", "").replace(")", "")
|
||||
val downloadLink =
|
||||
"https://sbplay2.com/dl?op=download_orig&id=$id&mode=$mode&hash=$hash"
|
||||
respDownloadLinkSelector.close()
|
||||
val video = sbplayVideoParser(downloadLink, quality)
|
||||
if (video != null) videoList.add(video)
|
||||
}
|
||||
return videoList
|
||||
}
|
||||
|
||||
private fun sbplayVideoParser(url: String, quality: String): Video? {
|
||||
return try {
|
||||
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
||||
val refererHeader = Headers.headersOf("Referer", url)
|
||||
val respDownloadLink = noRedirectClient.newCall(GET(url, refererHeader)).execute()
|
||||
val documentDownloadLink = respDownloadLink.asJsoup()
|
||||
val downloadLink = documentDownloadLink.selectFirst("div.contentbox span a").attr("href")
|
||||
respDownloadLink.close()
|
||||
Video(url, quality, downloadLink, null, refererHeader)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun doodUrlParse(url: String): String? {
|
||||
val response = client.newCall(GET(url.replace("/d/", "/e/"))).execute()
|
||||
val content = response.body!!.string()
|
||||
|
@ -0,0 +1,51 @@
|
||||
package eu.kanade.tachiyomi.animeextension.en.vidembed.extractors
|
||||
|
||||
import android.util.Log
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
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
|
||||
import org.jsoup.Jsoup
|
||||
|
||||
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> {
|
||||
val id = url.substringAfter("e/").substringBefore("?")
|
||||
Log.i("id", id)
|
||||
val bytes = id.toByteArray()
|
||||
Log.i("bytes", "$bytes")
|
||||
val bytesToHex = bytesToHex(bytes)
|
||||
Log.i("bytesToHex", bytesToHex)
|
||||
val master = "https://sbplay2.com/sourcesx38/7361696b6f757c7c${bytesToHex}7c7c7361696b6f757c7c73747265616d7362/7361696b6f757c7c363136653639366436343663363136653639366436343663376337633631366536393664363436633631366536393664363436633763376336313665363936643634366336313665363936643634366337633763373337343732363536313664373336327c7c7361696b6f757c7c73747265616d7362"
|
||||
Log.i("master", master)
|
||||
val json = Json.decodeFromString<JsonObject>(Jsoup.connect(master).ignoreContentType(true).header("watchsb", "streamsb").execute().body())
|
||||
Log.i("json", "$json")
|
||||
val masterUrl = json["stream_data"]!!.jsonObject["file"].toString().trim('"')
|
||||
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body!!.string()
|
||||
Log.i("masterplayl", masterPlaylist)
|
||||
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))
|
||||
}
|
||||
return videoList
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user