Skip to content

Commit

Permalink
fix(en/superstream): remove alt urls to fix search
Browse files Browse the repository at this point in the history
  • Loading branch information
Samfun75 committed Nov 5, 2023
1 parent 9524d83 commit de518a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/en/superstream/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ext {
extName = 'SuperStream'
pkgNameSuffix = 'en.superstream'
extClass = '.SuperStream'
extVersionCode = 9
extVersionCode = 10
libVersion = '13'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() {

override val name = "SuperStream"

override val baseUrl by lazy { preferences.getString("preferred_domain", superStreamAPI.apiUrl)!! }
override val baseUrl = "https://i1.sndcdn.com/artworks-000570872354-fmnvll-t500x500.jpg"

override val lang = "en"

Expand Down Expand Up @@ -137,7 +137,7 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() {
override fun searchAnimeParse(response: Response) = throw Exception("not used")

override fun fetchAnimeDetails(anime: SAnime): Observable<SAnime> {
val data = superStreamAPI.load(anime.url, true)
val data = superStreamAPI.load(anime.url)
val ani = SAnime.create()
val (movie, seriesData) = data
val (detail, _) = seriesData
Expand Down Expand Up @@ -192,21 +192,6 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() {
override fun animeDetailsParse(response: Response) = throw Exception("not used")

override fun setupPreferenceScreen(screen: PreferenceScreen) {
val domainPref = ListPreference(screen.context).apply {
key = "preferred_domain"
title = "Preferred domain (requires app restart)"
entries = arrayOf("Default")
entryValues = arrayOf(superStreamAPI.apiUrl)
setDefaultValue(superStreamAPI.apiUrl)
summary = "%s"

setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}
val videoQualityPref = ListPreference(screen.context).apply {
key = "preferred_quality"
title = "Preferred quality"
Expand All @@ -222,7 +207,6 @@ class SuperStream : ConfigurableAnimeSource, AnimeHttpSource() {
preferences.edit().putString(key, entry).commit()
}
}
screen.addPreference(domainPref)
screen.addPreference(videoQualityPref)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ import eu.kanade.tachiyomi.animesource.model.SAnime
import eu.kanade.tachiyomi.animesource.model.Track
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.POST
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonPrimitive
Expand Down Expand Up @@ -815,7 +814,7 @@ class SuperStreamAPI(val json: Json) {
}
}

private fun queryApi(query: String, altApi: Boolean = false): Response {
private fun queryApi(query: String): Response {
val encryptedQuery = CipherUtils.encrypt(query, key, iv)!!
val appKeyHash = CipherUtils.md5(appKey)!!
val newBody =
Expand All @@ -837,15 +836,14 @@ class SuperStreamAPI(val json: Json) {
.add("medium", "Website&token$token")
.build()
try {
val url = if (altApi) secondApiUrl else thirdApiUrl
return client.newCall(POST(url, headers = headers, body = formData)).execute()
return client.newCall(POST(apiUrl, headers = headers, body = formData)).execute()
} catch (e: Exception) {
throw Exception("Query Failed\n$e")
}
}

private inline fun <reified T : Any> queryApiParsed(query: String, altApi: Boolean = false): T {
return parseJson(queryApi(query, altApi).body.string())
private inline fun <reified T : Any> queryApiParsed(query: String): T {
return parseJson(queryApi(query).body.string())
}

private val unixTime: Long
Expand All @@ -864,13 +862,7 @@ class SuperStreamAPI(val json: Json) {
// Free Tibet, The Tienanmen Square protests of 1989
private val iv = base64Decode("d0VpcGhUbiE=")
private val key = base64Decode("MTIzZDZjZWRmNjI2ZHk1NDIzM2FhMXc2")
private val ip = base64Decode("aHR0cHM6Ly8xNTIuMzIuMTQ5LjE2MA==")
val apiUrl = "$ip${base64Decode("L2FwaS9hcGlfY2xpZW50L2luZGV4Lw==")}"

// Thanks @Blatzar and his dream from cloudstream for the secondurl
private val secondApiUrl =
base64Decode("aHR0cHM6Ly9tYnBhcGkuc2hlZ3UubmV0L2FwaS9hcGlfY2xpZW50L2luZGV4Lw==")
private val thirdApiUrl = base64Decode("aHR0cHM6Ly9zaG93Ym94LnNoZWd1Lm5ldC9hcGkvYXBpX2NsaWVudC9pbmRleC8=")
private val apiUrl = base64Decode("aHR0cHM6Ly9zaG93Ym94LnNoZWd1Lm5ldC9hcGkvYXBpX2NsaWVudC9pbmRleC8=")
private val appKey = base64Decode("bW92aWVib3g=")
private val appId = base64Decode("Y29tLnRkby5zaG93Ym94")

Expand Down Expand Up @@ -940,13 +932,13 @@ class SuperStreamAPI(val json: Json) {
val apiQuery =
// Originally 8 pagelimit
"""{"childmode":"$hideNsfw","app_version":"11.5","appid":"$appId","module":"Search3","channel":"Website","page":"$page","lang":"en","type":"all","keyword":"$query","pagelimit":"20","expired_date":"${getExpiryDate()}","platform":"android"}"""
val searchResponse = parseJson<MainData>(queryApi(apiQuery, true).body.string()).data.mapNotNull {
val searchResponse = parseJson<MainData>(queryApi(apiQuery).body.string()).data.mapNotNull {
it.toSearchResponse()
}
return searchResponse
}

fun load(url: String, altApi: Boolean = false): Pair<MovieData?, Pair<SeriesData?, List<SeriesEpisode>?>> {
fun load(url: String): Pair<MovieData?, Pair<SeriesData?, List<SeriesEpisode>?>> {
val loadData = parseJson<LoadData>(url)
// val module = if(type === "TvType.Movie") "Movie_detail" else "*tv series module*"

Expand All @@ -955,14 +947,14 @@ class SuperStreamAPI(val json: Json) {
if (isMovie) { // 1 = Movie
val apiQuery =
"""{"childmode":"$hideNsfw","uid":"","app_version":"11.5","appid":"$appId","module":"Movie_detail","channel":"Website","mid":"${loadData.id}","lang":"en","expired_date":"${getExpiryDate()}","platform":"android","oss":"","group":""}"""
val data = queryApiParsed<MovieDataProp>(apiQuery, altApi).data
val data = queryApiParsed<MovieDataProp>(apiQuery).data
?: throw RuntimeException("API error")

return Pair(data, Pair(null, null))
} else { // 2 Series
val apiQuery =
"""{"childmode":"$hideNsfw","uid":"","app_version":"11.5","appid":"$appId","module":"TV_detail_1","display_all":"1","channel":"Website","lang":"en","expired_date":"${getExpiryDate()}","platform":"android","tid":"${loadData.id}"}"""
val data = queryApiParsed<SeriesDataProp>(apiQuery, altApi).data
val data = queryApiParsed<SeriesDataProp>(apiQuery).data
?: throw RuntimeException("API error")

val episodes = data.season.mapNotNull {
Expand Down

0 comments on commit de518a3

Please sign in to comment.