Skip to content

Commit

Permalink
fix(multisrc/animestream): Prevent some crashes + reorder functions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudemirovsky authored Oct 26, 2023
1 parent 57ef471 commit 6cc22da
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 208 deletions.
13 changes: 0 additions & 13 deletions multisrc/overrides/animestream/lmanime/src/LMAnime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.dailymotionextractor.DailymotionExtractor
import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor
import eu.kanade.tachiyomi.multisrc.animestream.AnimeStream
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Response

Expand All @@ -34,18 +33,6 @@ class LMAnime : AnimeStream(
}.flatten().ifEmpty { throw Exception("Empty video list!") }
}

override fun getHosterUrl(encodedData: String) =
client.newCall(GET(encodedData, headers)).execute()
.use { it.asJsoup() }
.selectFirst("iframe[src~=.]")!!
.attr("src")
.let { // sometimes the url dont specify its protocol
when {
it.startsWith("http") -> it
else -> "https:$it"
}
}

private val okruExtractor by lazy { OkruExtractor(client) }
private val dailyExtractor by lazy { DailymotionExtractor(client, headers) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
package eu.kanade.tachiyomi.animeextension.en.luciferdonghua

import android.util.Base64
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.dailymotionextractor.DailymotionExtractor
import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor
import eu.kanade.tachiyomi.lib.streamwishextractor.StreamWishExtractor
import eu.kanade.tachiyomi.multisrc.animestream.AnimeStream
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import org.jsoup.Jsoup

class LuciferDonghua : AnimeStream(
"en",
"LuciferDonghua",
"https://luciferdonghua.in",
) {
// ============================ Video Links =============================

override fun getHosterUrl(encodedData: String): String {
val doc = if (encodedData.toHttpUrlOrNull() == null) {
Base64.decode(encodedData, Base64.DEFAULT)
.let(::String) // bytearray -> string
.let(Jsoup::parse) // string -> document
} else {
client.newCall(GET(encodedData, headers)).execute().use { it.asJsoup() }
}

return doc.selectFirst("iframe[src~=.]")?.attr("abs:src")
?: doc.selectFirst("meta[content~=.][itemprop=embedUrl]")!!.attr("abs:content")
}

private val okruExtractor by lazy { OkruExtractor(client) }
private val dailymotionExtractor by lazy { DailymotionExtractor(client, headers) }
private val filelionsExtractor by lazy { StreamWishExtractor(client, headers) }
Expand All @@ -46,7 +27,6 @@ class LuciferDonghua : AnimeStream(
}

// ============================= Utilities ==============================

override fun List<Video>.sort(): List<Video> {
val quality = preferences.getString(videoSortPrefKey, videoSortPrefDefault)!!
return sortedWith(
Expand Down
Loading

0 comments on commit 6cc22da

Please sign in to comment.