[Sora] fixed missing anime in Sorastream

This commit is contained in:
hexated 2023-02-02 15:28:22 +07:00
parent dbf8e12226
commit b7b1f0ceee
3 changed files with 38 additions and 9 deletions

View File

@ -800,6 +800,7 @@ object SoraExtractor : SoraStream() {
suspend fun invokeSoraStream(
title: String? = null,
isAnime: Boolean = false,
year: Int? = null,
season: Int? = null,
episode: Int? = null,
@ -845,10 +846,9 @@ object SoraExtractor : SoraStream() {
) && (it.second == year || it.first.contains("Season $season", true))
}
else -> {
it.first.contains(
"$title",
true
) && it.second == year && it.first.contains("Season $season", true)
(if (isAnime) it.first.contains(Regex("(?i)$title\\s?($season|${season.toRomanNumeral()})")) else it.first.contains(
Regex("(?i)$title\\s?Season\\s$season")
)) && it.second == year
}
}
}
@ -2034,7 +2034,6 @@ object SoraExtractor : SoraStream() {
episode: Int? = null,
subtitleCallback: (SubtitleFile) -> Unit,
) {
val watchSomuchAPI = "https://watchsomuch.tv"
val id = imdbId?.removePrefix("tt")
val epsId = app.post(
"$watchSomuchAPI/Watch/ajMovieTorrents.aspx",
@ -2089,7 +2088,10 @@ object SoraExtractor : SoraStream() {
"cf_cache_token" to "UKsVpQqBMxB56gBfhYKbfCVkRIXMh42pk6G4DdkXXoVh7j4BjV"
)
val query = getIndexQuery(title, year, season, episode)
val search = app.get("$baymoviesAPI/0:search?q=$query&page_token=&page_index=0", headers = headers).text
val search = app.get(
"$baymoviesAPI/0:search?q=$query&page_token=&page_index=0",
headers = headers
).text
val media = searchIndex(title, season, episode, year, search) ?: return
media.apmap { file ->
@ -2101,8 +2103,9 @@ object SoraExtractor : SoraStream() {
val encryptedExpiry = base64Encode(CryptoAES.encrypt(key, expiry).toByteArray())
val worker = getConfig().workers.randomOrNull() ?: return@apmap null
val link = "https://api.$worker.workers.dev/download.aspx?file=$encryptedId&expiry=$encryptedExpiry&mac=$hmacSign"
if(!app.get(link).isSuccessful) return@apmap null
val link =
"https://api.$worker.workers.dev/download.aspx?file=$encryptedId&expiry=$encryptedExpiry&mac=$hmacSign"
if (!app.get(link).isSuccessful) return@apmap null
val size = file.size?.toDouble() ?: return@apmap null
val sizeFile = "%.2f GB".format(bytesToGigaBytes(size))
val tags = Regex("\\d{3,4}[pP]\\.?(.*?)\\.(mkv|mp4)").find(
@ -2229,7 +2232,7 @@ object SoraExtractor : SoraStream() {
}).text.let {
fixUrl(it, apiUrl)
}.encodeUrl()
if(!app.get(path).isSuccessful) return@apmap null
if (!app.get(path).isSuccessful) return@apmap null
val size = file.size?.toDouble() ?: return@apmap null
val sizeFile = "%.2f GB".format(bytesToGigaBytes(size))
val quality =

View File

@ -116,6 +116,7 @@ open class SoraStream : TmdbProvider() {
const val chillmovies0API = "https://chill.aicirou.workers.dev/0:"
const val chillmovies1API = "https://chill.aicirou.workers.dev/1:"
const val gamMoviesAPI = "https://drive.gamick.workers.dev/0:"
const val watchSomuchAPI = "https://watchsomuch.tv" // sub only
fun getType(t: String?): TvType {
return when (t) {
@ -331,6 +332,7 @@ open class SoraStream : TmdbProvider() {
{
invokeSoraStream(
res.title,
res.isAnime,
res.year,
res.season,
res.episode,

View File

@ -847,4 +847,28 @@ suspend fun loadLinksWithWebView(
true
)
)
}
fun Int.toRomanNumeral(): String = Symbol.closestBelow(this)
.let { symbol ->
if (symbol != null) {
"$symbol${(this - symbol.decimalValue).toRomanNumeral()}"
} else {
""
}
}
private enum class Symbol(val decimalValue: Int) {
I(1),
IV(4),
V(5),
IX(9),
X(10);
companion object {
fun closestBelow(value: Int) =
values()
.sortedByDescending { it.decimalValue }
.firstOrNull { value >= it.decimalValue }
}
}