Skip to content

Commit

Permalink
Fix(en/OppaiStream): Fixed video empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark25 committed Sep 5, 2024
1 parent fe7c3e5 commit 5d29590
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/en/oppaistream/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Oppai Stream'
extClass = '.OppaiStream'
extVersionCode = 6
extVersionCode = 7
isNsfw = true
}

Expand Down
Binary file modified src/en/oppaistream/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/en/oppaistream/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/en/oppaistream/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/en/oppaistream/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/en/oppaistream/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.util.asJsoup
import eu.kanade.tachiyomi.util.parseAs
import kotlinx.serialization.json.Json
import okhttp3.FormBody
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Request
Expand All @@ -27,8 +28,8 @@ import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.net.URLDecoder
import java.nio.charset.StandardCharsets
import uy.kohesive.injekt.injectLazy
import java.net.URLEncoder.encode

class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {

Expand All @@ -46,6 +47,8 @@ class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
}

private val json: Json by injectLazy()

// ============================== Popular ===============================
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/$SEARCH_PATH?order=views&page=$page&limit=$SEARCH_LIMIT")

Expand Down Expand Up @@ -122,13 +125,7 @@ class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
override fun searchAnimeFromElement(element: Element) = SAnime.create().apply {
thumbnail_url = element.selectFirst("img.cover-img-in")?.attr("abs:src")
title = element.selectFirst(".title-ep")!!.text().replace(TITLE_CLEANUP_REGEX, "")
val encodedUrl = element.attr("href").substringAfter("to=")
val decodedUrl = URLDecoder.decode(encodedUrl, StandardCharsets.UTF_8.toString())
setUrlWithoutDomain(
decodedUrl.replace(Regex("(?<=\\?e=)(.*?)(?=&f=)")) {
java.net.URLEncoder.encode(it.groupValues[1], "UTF-8")
},
)
setUrlWithoutDomain(element.attr("exur").fixLink())
}

// =========================== Anime Details ============================
Expand Down Expand Up @@ -157,50 +154,26 @@ class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
}

// ============================== Episodes ==============================
// override fun episodeListParse(response: Response): List<SEpisode> {
// val doc = response.asJsoup()
// return buildList {
// doc.select(episodeListSelector())
// .map(::episodeFromElement)
// .let(::addAll)
//
// add(
// SEpisode.create().apply {
// setUrlWithoutDomain(
// doc.location().replace(Regex("(?<=\\?e=)(.*?)(?=&f=)")) {
// java.net.URLEncoder.encode(it.groupValues[1], "UTF-8")
// },
// )
// val num = doc.selectFirst("div.episode-info > h1")!!.text().substringAfter(" Ep ")
// name = "Episode $num"
// episode_number = num.toFloatOrNull() ?: 1F
// scanlator = doc.selectFirst("div.episode-info a.red")?.text()
// },
// )
// }.sortedByDescending { it.episode_number }
// }
override fun episodeListParse(response: Response): List<SEpisode> {
val doc = response.asJsoup()
return doc.select("div.more-same-eps .in-main-gr > a").map(::episodeFromElement).reversed()
}

override fun episodeListSelector() = "div.more-same-eps > div > div > a"

override fun episodeFromElement(element: Element) = SEpisode.create().apply {
val encodedUrl = element.attr("href").substringAfter("to=")
val decodedUrl = URLDecoder.decode(encodedUrl, StandardCharsets.UTF_8.toString())
setUrlWithoutDomain(
decodedUrl.replace(Regex("(?<=\\?e=)(.*?)(?=&f=)")) {
java.net.URLEncoder.encode(it.groupValues[1], "UTF-8")
},
)
setUrlWithoutDomain(element.attr("exur").fixLink())
val num = element.selectFirst("font.ep")?.text() ?: "1"
name = "Episode $num"
episode_number = "0.$num".toFloat()
episode_number = num.toFloatOrNull() ?: 1F
scanlator = element.selectFirst("h6 > a")?.text()
}

// ============================ Video Links =============================
override fun videoListParse(response: Response): List<Video> {
val doc = response.asJsoup()
val script = doc.selectFirst("script:containsData(var availableres)")!!.data()
val subtitles = doc.select("track[kind=subtitles]").map {
val subtitles = doc.select("track[kind=captions], track[kind=subtitles]").map {
Track(it.attr("src"), it.attr("label"))
}

Expand Down Expand Up @@ -228,9 +201,7 @@ class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
).reversed()
}

override fun videoUrlParse(document: Document): String {
throw UnsupportedOperationException()
}
override fun videoUrlParse(document: Document) = throw UnsupportedOperationException()

// ============================== Settings ==============================
override fun setupPreferenceScreen(screen: PreferenceScreen) {
Expand Down Expand Up @@ -324,6 +295,9 @@ class OppaiStream : ParsedAnimeHttpSource(), ConfigurableAnimeSource {
return Pair(coverURL, studiosList)
}

private fun String.fixLink(): String =
this.replace(Regex("(?<=\\?e=)(.*?)(?=&f=)")) { encode(it.groupValues[1], "UTF-8") }

companion object {
private const val SEARCH_PATH = "actions/search.php"
private const val SEARCH_LIMIT = 36
Expand Down

0 comments on commit 5d29590

Please sign in to comment.