refactor: Fix some codefactor warnings (#2406)

This commit is contained in:
Claudemirovsky
2023-10-25 04:31:16 -03:00
committed by GitHub
parent 8eea5ac8f6
commit 7ae7ecdc49
56 changed files with 227 additions and 339 deletions

View File

@ -27,7 +27,7 @@ object JsUnpacker {
val count = args[3].toInt() val count = args[3].toInt()
val origList = args[4].split("|") val origList = args[4].split("|")
val replaceMap = (0..(count - 1)).map { val replaceMap = (0..count - 1).map {
val key = convert(base, it) val key = convert(base, it)
key to try { origList[it] } catch (e: Exception) { key } key to try { origList[it] } catch (e: Exception) { key }
}.toMap() }.toMap()

View File

@ -770,9 +770,6 @@ class AutoEmbedExtractor(private val client: OkHttpClient) {
videoUrl.contains("rabbitstream") -> { videoUrl.contains("rabbitstream") -> {
RabbitStreamExtractor(client).videosFromUrl(videoUrl, headers = videoHeaders, prefix = prefix) RabbitStreamExtractor(client).videosFromUrl(videoUrl, headers = videoHeaders, prefix = prefix)
} }
videoUrl.contains("mixdrop") -> {
MixDropExtractor(client).videoFromUrl(videoUrl, prefix = prefix)
}
videoUrl.contains("https://dood") -> { videoUrl.contains("https://dood") -> {
DoodExtractor(client).videoFromUrl(videoUrl, server.name, false) DoodExtractor(client).videoFromUrl(videoUrl, server.name, false)
?.let(::listOf) ?.let(::listOf)
@ -863,7 +860,7 @@ class AutoEmbedExtractor(private val client: OkHttpClient) {
private fun getCaptchaToken(url: String, key: String): String? { private fun getCaptchaToken(url: String, key: String): String? {
return runCatching { return runCatching {
val httpUrl = url.toHttpUrl() val httpUrl = url.toHttpUrl()
val pureDomain = (httpUrl.scheme + "://" + httpUrl.host + ":443") val pureDomain = httpUrl.scheme + "://" + httpUrl.host + ":443"
val domain = Base64.encodeToString(pureDomain.encodeToByteArray(), Base64.DEFAULT) val domain = Base64.encodeToString(pureDomain.encodeToByteArray(), Base64.DEFAULT)
.replace("\n", "") .replace("\n", "")
.replace("=", ".") .replace("=", ".")

View File

@ -663,60 +663,59 @@ class Jellyfin(private val suffix: String) : ConfigurableAnimeSource, AnimeHttpS
} }
private fun medialibPreference(screen: PreferenceScreen) = private fun medialibPreference(screen: PreferenceScreen) =
( object : MediaLibPreference(screen.context) {
object : MediaLibPreference(screen.context) { override fun reload() {
override fun reload() { this.apply {
this.apply { key = JFConstants.MEDIALIB_KEY
key = JFConstants.MEDIALIB_KEY title = JFConstants.MEDIALIB_TITLE
title = JFConstants.MEDIALIB_TITLE summary = "%s"
summary = "%s"
Thread { Thread {
try { try {
val mediaLibsResponse = client.newCall( val mediaLibsResponse = client.newCall(
GET("$baseUrl/Users/$userId/Items?api_key=$apiKey"), GET("$baseUrl/Users/$userId/Items?api_key=$apiKey"),
).execute() ).execute()
val mediaJson = mediaLibsResponse.body.let { json.decodeFromString<ItemsResponse>(it.string()) }?.Items val mediaJson = mediaLibsResponse.body.let { json.decodeFromString<ItemsResponse>(it.string()) }?.Items
val entriesArray = mutableListOf<String>() val entriesArray = mutableListOf<String>()
val entriesValueArray = mutableListOf<String>() val entriesValueArray = mutableListOf<String>()
if (mediaJson != null) { if (mediaJson != null) {
for (media in mediaJson) { for (media in mediaJson) {
entriesArray.add(media.Name) entriesArray.add(media.Name)
entriesValueArray.add(media.Id) entriesValueArray.add(media.Id)
}
} }
entries = entriesArray.toTypedArray()
entryValues = entriesValueArray.toTypedArray()
} catch (ex: Exception) {
entries = emptyArray()
entryValues = emptyArray()
} }
}.start()
setOnPreferenceChangeListener { _, newValue -> entries = entriesArray.toTypedArray()
val selected = newValue as String entryValues = entriesValueArray.toTypedArray()
val index = findIndexOfValue(selected) } catch (ex: Exception) {
val entry = entryValues[index] as String entries = emptyArray()
parentId = entry entryValues = emptyArray()
preferences.edit().putString(key, entry).commit()
} }
}.start()
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
parentId = entry
preferences.edit().putString(key, entry).commit()
} }
} }
} }
).apply { reload() } }.apply { reload() }
private fun getSummary(isPassword: Boolean, value: String, placeholder: String) = when {
isPassword && value.isNotEmpty() || !isPassword && value.isEmpty() -> placeholder
else -> value
}
private fun PreferenceScreen.editTextPreference(key: String, title: String, default: String, value: String, isPassword: Boolean = false, placeholder: String, mediaLibPref: MediaLibPreference): EditTextPreference { private fun PreferenceScreen.editTextPreference(key: String, title: String, default: String, value: String, isPassword: Boolean = false, placeholder: String, mediaLibPref: MediaLibPreference): EditTextPreference {
return EditTextPreference(context).apply { return EditTextPreference(context).apply {
this.key = key this.key = key
this.title = title this.title = title
summary = if ((isPassword && value.isNotEmpty()) || (!isPassword && value.isEmpty())) { summary = getSummary(isPassword, value, placeholder)
placeholder
} else {
value
}
this.setDefaultValue(default) this.setDefaultValue(default)
dialogTitle = title dialogTitle = title
@ -732,11 +731,7 @@ class Jellyfin(private val suffix: String) : ConfigurableAnimeSource, AnimeHttpS
try { try {
val newValueString = newValue as String val newValueString = newValue as String
val res = preferences.edit().putString(key, newValueString).commit() val res = preferences.edit().putString(key, newValueString).commit()
summary = if ((isPassword && newValueString.isNotEmpty()) || (!isPassword && newValueString.isEmpty())) { summary = getSummary(isPassword, newValueString, placeholder)
placeholder
} else {
newValueString
}
val loginRes = login(true, context) val loginRes = login(true, context)
if (loginRes == true) { if (loginRes == true) {
mediaLibPref.reload() mediaLibPref.reload()

View File

@ -379,7 +379,7 @@ class Yomiroll : ConfigurableAnimeSource, AnimeHttpSource() {
} }
) + ) +
( (
if ((series_metadata?.audio_locales?.size ?: 0) > 1 || if (series_metadata?.audio_locales?.size ?: 0 > 1 ||
movie_metadata?.is_dubbed == true movie_metadata?.is_dubbed == true
) { ) {
" Dub" " Dub"
@ -501,33 +501,31 @@ class Yomiroll : ConfigurableAnimeSource, AnimeHttpSource() {
} }
private fun localSubsPreference(screen: PreferenceScreen) = private fun localSubsPreference(screen: PreferenceScreen) =
( object : LocalSubsPreference(screen.context) {
object : LocalSubsPreference(screen.context) { override fun reload() {
override fun reload() { this.apply {
this.apply { key = PREF_USE_LOCAL_TOKEN_KEY
key = PREF_USE_LOCAL_TOKEN_KEY title = PREF_USE_LOCAL_TOKEN_TITLE
title = PREF_USE_LOCAL_TOKEN_TITLE summary = runBlocking {
summary = runBlocking { withContext(Dispatchers.IO) { getTokenDetail() }
withContext(Dispatchers.IO) { getTokenDetail() } }
} setDefaultValue(false)
setDefaultValue(false) setOnPreferenceChangeListener { _, newValue ->
setOnPreferenceChangeListener { _, newValue -> val new = newValue as Boolean
val new = newValue as Boolean preferences.edit().putBoolean(key, new).commit().also {
preferences.edit().putBoolean(key, new).commit().also { Thread {
Thread { summary = runBlocking {
summary = runBlocking { withContext(Dispatchers.IO) { getTokenDetail(true) }
withContext(Dispatchers.IO) { getTokenDetail(true) } }
} }.start()
}.start()
}
} }
} }
} }
} }
).apply { reload() } }.apply { reload() }
// From Dopebox // From Dopebox
private fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> = private inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> =
runBlocking { runBlocking {
map { async(Dispatchers.Default) { f(it) } }.awaitAll() map { async(Dispatchers.Default) { f(it) } }.awaitAll()
} }

View File

@ -86,7 +86,7 @@ class Akwam : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.setUrlWithoutDomain(element.attr("href")) episode.setUrlWithoutDomain(element.attr("href"))
episode.name = element.text() episode.name = element.text()
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
return episode return episode

View File

@ -97,7 +97,7 @@ class Anime4Up : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.setUrlWithoutDomain(element.select("div.episodes-card-container div.episodes-card div.ehover6 h3 a").attr("href")) episode.setUrlWithoutDomain(element.select("div.episodes-card-container div.episodes-card div.ehover6 h3 a").attr("href"))
// episode.episode_number = element.select("span:nth-child(3)").text().replace(" - ", "").toFloat() // episode.episode_number = element.select("span:nth-child(3)").text().replace(" - ", "").toFloat()
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.name = element.select("div.episodes-card-container div.episodes-card div.ehover6 h3 a").text() episode.name = element.select("div.episodes-card-container div.episodes-card div.ehover6 h3 a").text()

View File

@ -1,33 +0,0 @@
package eu.kanade.tachiyomi.animeextension.ar.anime4up.extractors
import android.util.Log
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.util.asJsoup
import okhttp3.Headers
import okhttp3.OkHttpClient
class MoshahdaExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String, headers: Headers): List<Video> {
val callPlayer = client.newCall(GET(url, headers)).execute().asJsoup()
Log.i("embeddd", "$callPlayer")
val data = callPlayer.data().substringAfter("sources: [").substringBefore("],")
val sources = data.split("file: \"").drop(1)
val videoList = mutableListOf<Video>()
for (source in sources) {
val masterUrl = source.substringBefore("\"}")
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body.string()
val videoList = mutableListOf<Video>()
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:")
.forEach {
val quality = it.substringAfter("RESOLUTION=").substringAfter("x")
.substringBefore(",") + "p"
val videoUrl = it.substringAfter("\n").substringBefore("\n")
videoList.add(Video(videoUrl, quality, videoUrl))
}
return videoList
}
return videoList
}
}

View File

@ -131,7 +131,7 @@ class AnimeBlkom : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val eptitle = element.selectFirst("span:nth-child(3)")!!.text() val eptitle = element.selectFirst("span:nth-child(3)")!!.text()
val epNum = eptitle.filter { it.isDigit() } val epNum = eptitle.filter { it.isDigit() }
episode_number = when { episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloatOrNull() ?: 1F epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
name = eptitle + " :" + element.selectFirst("span:nth-child(1)")!!.text() name = eptitle + " :" + element.selectFirst("span:nth-child(1)")!!.text()

View File

@ -68,7 +68,7 @@ class AnimeLek : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
name = text name = text
val epNum = text.filter { it.isDigit() } val epNum = text.filter { it.isDigit() }
episode_number = when { episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloatOrNull() ?: 1F epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
} }

View File

@ -102,7 +102,7 @@ class MyCima : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.setUrlWithoutDomain(if (type == "mSeries") element.select("a").attr("href") else element.attr("abs:href")) episode.setUrlWithoutDomain(if (type == "mSeries") element.select("a").attr("href") else element.attr("abs:href"))
if (type == "series") { if (type == "series") {
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
} }

View File

@ -86,7 +86,7 @@ class Okanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} }
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList) = override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList) =
("$baseUrl/search/?s=$query") "$baseUrl/search/?s=$query"
.let { if (page > 1) "$it&page=$page" else it } .let { if (page > 1) "$it&page=$page" else it }
.let(::GET) .let(::GET)
@ -165,7 +165,7 @@ class Okanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private fun extractVideosFromUrl(url: String, quality: String, selection: Set<String>): List<Video> { private fun extractVideosFromUrl(url: String, quality: String, selection: Set<String>): List<Video> {
return runCatching { return runCatching {
when { when {
("https://doo" in url && "/e/" in url) && selection.contains("Dood") -> { "https://doo" in url && "/e/" in url && selection.contains("Dood") -> {
doodExtractor.videoFromUrl(url, "DoodStream - $quality") doodExtractor.videoFromUrl(url, "DoodStream - $quality")
?.let(::listOf) ?.let(::listOf)
} }

View File

@ -64,7 +64,7 @@ class XsAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.setUrlWithoutDomain(element.attr("abs:href")) episode.setUrlWithoutDomain(element.attr("abs:href"))
episode.name = element.select("a > em").text() episode.name = element.select("a > em").text()
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }

View File

@ -26,7 +26,7 @@ class JsUnpacker(packedJS: String?) {
*/ */
fun unpack(): String? { fun unpack(): String? {
val js = packedJS val js = packedJS
try { runCatching {
var p = var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js) var m = p.matcher(js)
@ -35,16 +35,8 @@ class JsUnpacker(packedJS: String?) {
val radixStr = m.group(2) val radixStr = m.group(2)
val countStr = m.group(3) val countStr = m.group(3)
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray() val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
var radix = 36 val radix = radixStr.toIntOrNull() ?: 36
var count = 0 val count = countStr.toIntOrNull() ?: 0
try {
radix = radixStr.toInt()
} catch (e: Exception) {
}
try {
count = countStr.toInt()
} catch (e: Exception) {
}
if (symtab.size != count) { if (symtab.size != count) {
throw Exception("Unknown p.a.c.k.e.r. encoding") throw Exception("Unknown p.a.c.k.e.r. encoding")
} }
@ -67,7 +59,6 @@ class JsUnpacker(packedJS: String?) {
} }
return decoded.toString() return decoded.toString()
} }
} catch (e: Exception) {
} }
return null return null
} }

View File

@ -26,7 +26,7 @@ class JsUnpacker(packedJS: String?) {
*/ */
fun unpack(): String? { fun unpack(): String? {
val js = packedJS val js = packedJS
try { runCatching {
var p = var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js) var m = p.matcher(js)
@ -35,16 +35,8 @@ class JsUnpacker(packedJS: String?) {
val radixStr = m.group(2) val radixStr = m.group(2)
val countStr = m.group(3) val countStr = m.group(3)
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray() val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
var radix = 36 val radix = radixStr.toIntOrNull() ?: 36
var count = 0 val count = countStr.toIntOrNull() ?: 0
try {
radix = radixStr.toInt()
} catch (e: Exception) {
}
try {
count = countStr.toInt()
} catch (e: Exception) {
}
if (symtab.size != count) { if (symtab.size != count) {
throw Exception("Unknown p.a.c.k.e.r. encoding") throw Exception("Unknown p.a.c.k.e.r. encoding")
} }
@ -67,7 +59,6 @@ class JsUnpacker(packedJS: String?) {
} }
return decoded.toString() return decoded.toString()
} }
} catch (e: Exception) {
} }
return null return null
} }

View File

@ -65,7 +65,7 @@ class MoflixStream : ConfigurableAnimeSource, AnimeHttpSource() {
val pagination = response.parseAs<PopularPaginationDto>().pagination val pagination = response.parseAs<PopularPaginationDto>().pagination
val animeList = pagination.data.parseItems() val animeList = pagination.data.parseItems()
val hasNextPage = pagination.current_page < (pagination.next_page ?: 1) val hasNextPage = pagination.current_page < pagination.next_page ?: 1
return AnimesPage(animeList, hasNextPage) return AnimesPage(animeList, hasNextPage)
} }

View File

@ -96,7 +96,7 @@ class StreamCloud : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
when { when {
li.text().contains("streamtape.com") && hosterSelection?.contains("stape") == true -> { li.text().contains("streamtape.com") && hosterSelection?.contains("stape") == true -> {
val url = li.attr("data-link") val url = li.attr("data-link")
try { runCatching {
with( with(
client.newCall(GET(url, headers = Headers.headersOf("Referer", baseUrl, "Cookie", "Fuck Streamtape because they add concatenation to fuck up scrapers"))) client.newCall(GET(url, headers = Headers.headersOf("Referer", baseUrl, "Cookie", "Fuck Streamtape because they add concatenation to fuck up scrapers")))
.execute().asJsoup(), .execute().asJsoup(),
@ -108,7 +108,6 @@ class StreamCloud : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
videoList.add(Video(videoUrl, quality, videoUrl)) videoList.add(Video(videoUrl, quality, videoUrl))
} }
} }
} catch (e: Exception) {
} }
} }

View File

@ -430,7 +430,9 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
.toByteArray().map { .toByteArray().map {
(it.toInt() xor 56).toChar() (it.toInt() xor 56).toChar()
}.joinToString("") }.joinToString("")
} else this } else {
this
}
} }
private fun prioritySort(pList: List<Pair<Video, Float>>): List<Video> { private fun prioritySort(pList: List<Pair<Video, Float>>): List<Video> {

View File

@ -188,7 +188,7 @@ class AllAnimeExtractor(private val client: OkHttpClient, private val headers: H
if (videos != null) { if (videos != null) {
videoList.addAll(videos) videoList.addAll(videos)
} }
} else {} }
} }
return videoList return videoList

View File

@ -68,7 +68,7 @@ class Animension() : ConfigurableAnimeSource, AnimeHttpSource() {
// Episode // Episode
override fun episodeListRequest(anime: SAnime): Request { override fun episodeListRequest(anime: SAnime): Request {
return (GET("$apiUrl/episodes.php?id=${anime.url}", headers)) return GET("$apiUrl/episodes.php?id=${anime.url}", headers)
} }
override fun episodeListParse(response: Response): List<SEpisode> { override fun episodeListParse(response: Response): List<SEpisode> {

View File

@ -218,12 +218,12 @@ class AnimePahe : ConfigurableAnimeSource, AnimeHttpSource() {
val subPreference = preferences.getString(PREF_SUB_KEY, PREF_SUB_DEFAULT)!! val subPreference = preferences.getString(PREF_SUB_KEY, PREF_SUB_DEFAULT)!!
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!! val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
val shouldBeAv1 = preferences.getBoolean(PREF_AV1_KEY, PREF_AV1_DEFAULT) val shouldBeAv1 = preferences.getBoolean(PREF_AV1_KEY, PREF_AV1_DEFAULT)
val shouldEndWithEng = (subPreference == "eng") val shouldEndWithEng = subPreference == "eng"
return this.sortedWith( return this.sortedWith(
compareBy( compareBy(
{ it.quality.contains(quality) }, { it.quality.contains(quality) },
{ (Regex("""\beng\b""").find(it.quality.lowercase()) != null) == shouldEndWithEng }, { Regex("""\beng\b""").containsMatchIn(it.quality.lowercase()) == shouldEndWithEng },
{ it.quality.lowercase().contains("av1") == shouldBeAv1 }, { it.quality.lowercase().contains("av1") == shouldBeAv1 },
), ),
).reversed() ).reversed()

View File

@ -65,7 +65,7 @@ class KwikExtractor(private val client: OkHttpClient) {
.header("location")!!.substringAfterLast("https://") .header("location")!!.substringAfterLast("https://")
val fContent = val fContent =
client.newCall(GET(kwikUrl, Headers.headersOf("referer", "https://kwik.cx/"))).execute() client.newCall(GET(kwikUrl, Headers.headersOf("referer", "https://kwik.cx/"))).execute()
cookies += (fContent.header("set-cookie")!!) cookies += fContent.header("set-cookie")!!
val fContentString = fContent.body.string() val fContentString = fContent.body.string()
val (fullString, key, v1, v2) = kwikParamsRegex.find(fContentString)!!.destructured val (fullString, key, v1, v2) = kwikParamsRegex.find(fContentString)!!.destructured
@ -138,12 +138,10 @@ class KwikExtractor(private val client: OkHttpClient) {
var acc: Long = 0 var acc: Long = 0
for ((n, i) in content.reversed().withIndex()) { for ((n, i) in content.reversed().withIndex()) {
acc += ( acc += when (isNumber("$i")) {
when (isNumber("$i")) { true -> "$i".toLong()
true -> "$i".toLong() false -> 0L
false -> "0".toLong() } * s1.toDouble().pow(n.toDouble()).toInt()
}
) * s1.toDouble().pow(n.toDouble()).toInt()
} }
var k = "" var k = ""

View File

@ -102,7 +102,7 @@ class AsianLoad : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epNum = element.selectFirst("div.name")!!.text().substringAfter("Episode ") val epNum = element.selectFirst("div.name")!!.text().substringAfter("Episode ")
name = element.selectFirst("div.type span")!!.text() + " Episode: $epNum" name = element.selectFirst("div.type span")!!.text() + " Episode: $epNum"
episode_number = when { episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloatOrNull() ?: 1F epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
date_upload = element.selectFirst("span.date")?.text()?.toDate() ?: 0L date_upload = element.selectFirst("span.date")?.text()?.toDate() ?: 0L

View File

@ -125,7 +125,7 @@ class DramaCool : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
setUrlWithoutDomain(element.attr("abs:href")) setUrlWithoutDomain(element.attr("abs:href"))
name = element.select("span.type").text() + ": Episode " + element.select("h3").text().substringAfter("Episode ") name = element.select("span.type").text() + ": Episode " + element.select("h3").text().substringAfter("Episode ")
episode_number = when { episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
date_upload = parseDate(element.select("span.time").text()) date_upload = parseDate(element.select("span.time").text())
@ -171,13 +171,6 @@ class DramaCool : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
videoList.add(video) videoList.add(video)
} }
} }
url.contains("streamtape") -> {
val video = StreamTapeExtractor(client).videoFromUrl(url)
if (video != null) {
videoList.add(video)
}
}
} }
} }
return videoList return videoList

View File

@ -96,7 +96,7 @@ class HentaiMama : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
.add("action", "get_player_contents") .add("action", "get_player_contents")
.add( .add(
"a", "a",
(document.select("#post_report input:nth-child(5)").attr("value")).toString(), document.selectFirst("#post_report input:nth-child(5)")?.attr("value").toString(),
) )
.build() .build()
@ -196,7 +196,7 @@ class HentaiMama : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val parameters = getSearchParameters(filters) val parameters = getSearchParameters(filters)
return if (query.isNotEmpty()) { return if (query.isNotEmpty()) {
filterSearch = false filterSearch = false
GET("$baseUrl/page/$page/?s=${query.replace(("[\\W]").toRegex(), " ")}") // regular search GET("$baseUrl/page/$page/?s=${query.replace(Regex("[\\W]"), " ")}") // regular search
} else { } else {
filterSearch = true filterSearch = true
GET("$baseUrl/advance-search/page/$page/?$parameters") // filter search GET("$baseUrl/advance-search/page/$page/?$parameters") // filter search

View File

@ -44,7 +44,7 @@ class KickAssAnimeExtractor(
fun videosFromUrl(url: String, name: String): List<Video> { fun videosFromUrl(url: String, name: String): List<Video> {
val host = url.toHttpUrl().host val host = url.toHttpUrl().host
val mid = if (name == "DuckStream") "mid" else "id" val mid = if (name == "DuckStream") "mid" else "id"
val isBird = (name == "BirdStream") val isBird = name == "BirdStream"
val query = url.toHttpUrl().queryParameter(mid)!! val query = url.toHttpUrl().queryParameter(mid)!!
@ -134,7 +134,7 @@ class KickAssAnimeExtractor(
} }
val cid = String(html.substringAfter("cid: '").substringBefore("'").decodeHex()).split("|") val cid = String(html.substringAfter("cid: '").substringBefore("'").decodeHex()).split("|")
val timeStamp = ((System.currentTimeMillis() / 1000) + 60).toString() val timeStamp = (System.currentTimeMillis() / 1000 + 60).toString()
val route = cid[1].replace("player.php", "source.php") val route = cid[1].replace("player.php", "source.php")
val signature = buildString { val signature = buildString {

View File

@ -27,7 +27,6 @@ class YouTubeExtractor(private val client: OkHttpClient) {
fun videosFromUrl(url: String, prefix: String): List<Video> { fun videosFromUrl(url: String, prefix: String): List<Video> {
// Ported from https://github.com/dermasmid/scrapetube/blob/master/scrapetube/scrapetube.py // Ported from https://github.com/dermasmid/scrapetube/blob/master/scrapetube/scrapetube.py
// TODO: Make code prettier
// GET KEY // GET KEY
var ytcfgString = "" var ytcfgString = ""
val videoId = url.substringAfter("/embed/").substringBefore("?") val videoId = url.substringAfter("/embed/").substringBefore("?")
@ -97,7 +96,7 @@ class YouTubeExtractor(private val client: OkHttpClient) {
// Get Audio // Get Audio
for (format in formats) { for (format in formats) {
if (format.jsonObject["mimeType"]!!.jsonPrimitive.content.startsWith("audio/webm")) { if (format.jsonObject["mimeType"]!!.jsonPrimitive.content.startsWith("audio/webm")) {
try { runCatching {
audioTracks.add( audioTracks.add(
Track( Track(
format.jsonObject["url"]!!.jsonPrimitive.content, format.jsonObject["url"]!!.jsonPrimitive.content,
@ -105,7 +104,7 @@ class YouTubeExtractor(private val client: OkHttpClient) {
" (${formatBits(format.jsonObject["averageBitrate"]!!.jsonPrimitive.long)}ps)", " (${formatBits(format.jsonObject["averageBitrate"]!!.jsonPrimitive.long)}ps)",
), ),
) )
} catch (a: Exception) { } }
} }
} }
@ -118,15 +117,14 @@ class YouTubeExtractor(private val client: OkHttpClient) {
for (caption in captionTracks) { for (caption in captionTracks) {
val captionJson = caption.jsonObject val captionJson = caption.jsonObject
try { runCatching {
subtitleTracks.add( subtitleTracks.add(
Track( Track(
// TODO: Would replacing srv3 with vtt work for every video?
captionJson["baseUrl"]!!.jsonPrimitive.content.replace("srv3", "vtt"), captionJson["baseUrl"]!!.jsonPrimitive.content.replace("srv3", "vtt"),
captionJson["name"]!!.jsonObject["runs"]!!.jsonArray[0].jsonObject["text"]!!.jsonPrimitive.content, captionJson["name"]!!.jsonObject["runs"]!!.jsonArray[0].jsonObject["text"]!!.jsonPrimitive.content,
), ),
) )
} catch (a: Exception) { } }
} }
} }

View File

@ -94,7 +94,7 @@ class MyRunningMan : ParsedAnimeHttpSource() {
title = it.label title = it.label
thumbnail_url = buildString { thumbnail_url = buildString {
append("$baseUrl/assets/epimg/${it.value.padStart(3, '0')}") append("$baseUrl/assets/epimg/${it.value.padStart(3, '0')}")
if ((it.value.toIntOrNull() ?: 1) > 396) append("_temp") if (it.value.toIntOrNull() ?: 1 > 396) append("_temp")
append(".jpg") append(".jpg")
} }
} }

View File

@ -1,88 +0,0 @@
package eu.kanade.tachiyomi.animeextension.en.putlocker;
public class JSONUtil {
public static String escape(String input) {
StringBuilder output = new StringBuilder();
for(int i=0; i<input.length(); i++) {
char ch = input.charAt(i);
int chx = (int) ch;
// let's not put any nulls in our strings
assert(chx != 0);
if(ch == '\n') {
output.append("\\n");
} else if(ch == '\t') {
output.append("\\t");
} else if(ch == '\r') {
output.append("\\r");
} else if(ch == '\\') {
output.append("\\\\");
} else if(ch == '"') {
output.append("\\\"");
} else if(ch == '\b') {
output.append("\\b");
} else if(ch == '\f') {
output.append("\\f");
} else if(chx >= 0x10000) {
assert false : "Java stores as u16, so it should never give us a character that's bigger than 2 bytes. It literally can't.";
} else if(chx > 127) {
output.append(String.format("\\u%04x", chx));
} else {
output.append(ch);
}
}
return output.toString();
}
public static String unescape(String input) {
StringBuilder builder = new StringBuilder();
int i = 0;
while (i < input.length()) {
char delimiter = input.charAt(i); i++; // consume letter or backslash
if(delimiter == '\\' && i < input.length()) {
// consume first after backslash
char ch = input.charAt(i); i++;
if(ch == '\\' || ch == '/' || ch == '"' || ch == '\'') {
builder.append(ch);
}
else if(ch == 'n') builder.append('\n');
else if(ch == 'r') builder.append('\r');
else if(ch == 't') builder.append('\t');
else if(ch == 'b') builder.append('\b');
else if(ch == 'f') builder.append('\f');
else if(ch == 'u') {
StringBuilder hex = new StringBuilder();
// expect 4 digits
if (i+4 > input.length()) {
throw new RuntimeException("Not enough unicode digits! ");
}
for (char x : input.substring(i, i + 4).toCharArray()) {
if(!Character.isLetterOrDigit(x)) {
throw new RuntimeException("Bad character in unicode escape.");
}
hex.append(Character.toLowerCase(x));
}
i+=4; // consume those four digits.
int code = Integer.parseInt(hex.toString(), 16);
builder.append((char) code);
} else {
throw new RuntimeException("Illegal escape sequence: \\"+ch);
}
} else { // it's not a backslash, or it's the last character.
builder.append(delimiter);
}
}
return builder.toString();
}
}

View File

@ -0,0 +1,76 @@
package eu.kanade.tachiyomi.animeextension.en.putlocker
object JSONUtil {
fun escape(input: String): String {
val output = StringBuilder()
for (ch in input) {
// let's not put any nulls in our strings
val charInt = ch.code
assert(charInt != 0)
// 0x10000 = 65536 = 2^16 = u16 max value
assert(charInt < 0x10000) { "Java stores as u16, so it should never give us a character that's bigger than 2 bytes. It literally can't." }
val escapedChar = when (ch) {
'\b' -> "\\b"
'\u000C' -> "\\f" // '\u000C' == '\f', Kotlin doesnt support \f
'\n' -> "\\n"
'\r' -> "\\r"
'\t' -> "\\t"
'\\' -> "\\\\"
'"' -> "\\\""
else -> {
if (charInt > 127) {
String.format("\\u%04x", charInt)
} else {
ch
}
}
}
output.append(escapedChar)
}
return output.toString()
}
fun unescape(input: String): String {
val builder = StringBuilder()
var index = 0
while (index < input.length) {
val delimiter = input.get(index) // consume letter or backslash
index++
if (delimiter == '\\' && index < input.length) {
// consume first after backslash
val ch = input.get(index)
index++
val unescaped = when (ch) {
'\\', '/', '"', '\'' -> ch // "
'b' -> '\b'
'f' -> '\u000C' // '\f' in java
'n' -> '\n'
'r' -> '\r'
't' -> '\t'
'u' -> {
if (index + 4 > input.length) {
throw RuntimeException("Not enough unicode digits!")
}
val hex = input.substring(index, index + 4)
if (hex.any { !it.isLetterOrDigit() }) {
throw RuntimeException("Bad character in unicode escape.")
}
hex.toInt(16).toChar()
}
else -> throw RuntimeException("Illegal escape sequence: \\" + ch)
}
builder.append(unescaped)
} else {
builder.append(delimiter)
}
}
return builder.toString()
}
}

View File

@ -955,20 +955,20 @@ class SuperStreamAPI(val json: Json) {
if (isMovie) { // 1 = Movie if (isMovie) { // 1 = Movie
val apiQuery = 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":""}""" """{"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, altApi).data
?: throw RuntimeException("API error") ?: throw RuntimeException("API error")
return Pair(data, Pair(null, null)) return Pair(data, Pair(null, null))
} else { // 2 Series } else { // 2 Series
val apiQuery = 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}"}""" """{"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, altApi).data
?: throw RuntimeException("API error") ?: throw RuntimeException("API error")
val episodes = data.season.mapNotNull { val episodes = data.season.mapNotNull {
val seasonQuery = val seasonQuery =
"""{"childmode":"$hideNsfw","app_version":"11.5","year":"0","appid":"$appId","module":"TV_episode","display_all":"1","channel":"Website","season":"$it","lang":"en","expired_date":"${getExpiryDate()}","platform":"android","tid":"${loadData.id}"}""" """{"childmode":"$hideNsfw","app_version":"11.5","year":"0","appid":"$appId","module":"TV_episode","display_all":"1","channel":"Website","season":"$it","lang":"en","expired_date":"${getExpiryDate()}","platform":"android","tid":"${loadData.id}"}"""
(queryApiParsed<SeriesSeasonProp>(seasonQuery)).data queryApiParsed<SeriesSeasonProp>(seasonQuery).data
}.flatten().reversed() }.flatten().reversed()
return Pair(null, Pair(data, episodes)) return Pair(null, Pair(data, episodes))

View File

@ -180,7 +180,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}.mapIndexed { index, linkElement -> }.mapIndexed { index, linkElement ->
val episode = linkElement?.text() val episode = linkElement?.text()
?.replace("Episode", "", true) ?.replace("Episode", "", true)
?.trim()?.toIntOrNull() ?: (index + 1) ?.trim()?.toIntOrNull() ?: index + 1
Triple( Triple(
season + "_$episode" + "_$part", season + "_$episode" + "_$part",
linkElement?.attr("href") ?: return@mapIndexed null, linkElement?.attr("href") ?: return@mapIndexed null,

View File

@ -108,7 +108,7 @@ class Wcofun : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val ep = epName.substringAfter("Episode ") val ep = epName.substringAfter("Episode ")
val seasonNum = season.substringBefore(" ").toIntOrNull() ?: 1 val seasonNum = season.substringBefore(" ").toIntOrNull() ?: 1
val epNum = ep.substringBefore(" ").toIntOrNull() ?: 1 val epNum = ep.substringBefore(" ").toIntOrNull() ?: 1
episode_number = ((seasonNum * 100) + epNum).toFloat() episode_number = (seasonNum * 100 + epNum).toFloat()
name = "Season $seasonNum - Episode $epNum" name = "Season $seasonNum - Episode $epNum"
} }

View File

@ -83,7 +83,7 @@ class WCOStream : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.setUrlWithoutDomain(element.select("a").attr("href").toHttpUrl().encodedPath) episode.setUrlWithoutDomain(element.select("a").attr("href").toHttpUrl().encodedPath)
episode.name = "Episode: " + element.select("a").text() episode.name = "Episode: " + element.select("a").text()
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
return episode return episode

View File

@ -342,7 +342,7 @@ class Animefenix : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun setupPreferenceScreen(screen: PreferenceScreen) { override fun setupPreferenceScreen(screen: PreferenceScreen) {
val qualities = arrayOf( val qualities = arrayOf(
"Okru:1080p", "Okru:720p", "Okru:480p", "Okru:360p", "Okru:240p", "Okru:144p", // Okru "Okru:1080p", "Okru:720p", "Okru:480p", "Okru:360p", "Okru:240p", "Okru:144p", // Okru
"Amazon", "AmazonES", "StreamTape", "Fireload", "Mp4upload", "YourUpload", "StreamWish" "Amazon", "AmazonES", "StreamTape", "Fireload", "Mp4upload", "YourUpload", "StreamWish",
) )
val videoQualityPref = ListPreference(screen.context).apply { val videoQualityPref = ListPreference(screen.context).apply {
key = "preferred_quality" key = "preferred_quality"

View File

@ -26,7 +26,7 @@ class JsUnpacker(packedJS: String?) {
*/ */
fun unpack(): String? { fun unpack(): String? {
val js = packedJS val js = packedJS
try { runCatching {
var p = var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js) var m = p.matcher(js)
@ -35,16 +35,8 @@ class JsUnpacker(packedJS: String?) {
val radixStr = m.group(2) val radixStr = m.group(2)
val countStr = m.group(3) val countStr = m.group(3)
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray() val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
var radix = 36 val radix = radixStr.toIntOrNull() ?: 36
var count = 0 val count = countStr.toIntOrNull() ?: 0
try {
radix = radixStr.toInt()
} catch (e: Exception) {
}
try {
count = countStr.toInt()
} catch (e: Exception) {
}
if (symtab.size != count) { if (symtab.size != count) {
throw Exception("Unknown p.a.c.k.e.r. encoding") throw Exception("Unknown p.a.c.k.e.r. encoding")
} }
@ -67,7 +59,6 @@ class JsUnpacker(packedJS: String?) {
} }
return decoded.toString() return decoded.toString()
} }
} catch (e: Exception) {
} }
return null return null
} }

View File

@ -63,7 +63,7 @@ class Animeyt : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epNum = getNumberFromEpsString(element.select("span.sa-series-link__number").text()) val epNum = getNumberFromEpsString(element.select("span.sa-series-link__number").text())
episode.setUrlWithoutDomain(element.attr("href")) episode.setUrlWithoutDomain(element.attr("href"))
val epParsed = when { val epParsed = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.episode_number = epParsed episode.episode_number = epParsed

View File

@ -63,8 +63,8 @@ class AsiaLiveAction : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val year = document.select("header div.asia-post-main p.Info span.Date a").text().toInt() val year = document.select("header div.asia-post-main p.Info span.Date a").text().toInt()
val currentYear = Calendar.getInstance().get(Calendar.YEAR) val currentYear = Calendar.getInstance().get(Calendar.YEAR)
anime.status = when { anime.status = when {
(year < currentYear) -> SAnime.COMPLETED year < currentYear -> SAnime.COMPLETED
(year == currentYear) -> SAnime.ONGOING year == currentYear -> SAnime.ONGOING
else -> SAnime.UNKNOWN else -> SAnime.UNKNOWN
} }
return anime return anime
@ -81,7 +81,7 @@ class AsiaLiveAction : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epNum = getNumberFromEpsString(element.select("div.flex-grow-1 p").text()) val epNum = getNumberFromEpsString(element.select("div.flex-grow-1 p").text())
episode.setUrlWithoutDomain(element.attr("href")) episode.setUrlWithoutDomain(element.attr("href"))
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.name = element.select("div.flex-grow-1 p").text().trim() episode.name = element.select("div.flex-grow-1 p").text().trim()

View File

@ -70,7 +70,7 @@ class Doramasyt : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epNum = getNumberFromEpsString(element.select("a div.flimss div.dtlsflim p").text()) val epNum = getNumberFromEpsString(element.select("a div.flimss div.dtlsflim p").text())
Log.i("bruh ep", element.select("a").attr("href")) Log.i("bruh ep", element.select("a").attr("href"))
val formatedEp = when { val formatedEp = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.setUrlWithoutDomain(element.select("a").attr("href")) episode.setUrlWithoutDomain(element.select("a").attr("href"))

View File

@ -204,7 +204,7 @@ class Gnula : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val videoList = mutableListOf<Video>() val videoList = mutableListOf<Video>()
val embedUrl = url.lowercase() val embedUrl = url.lowercase()
if (embedUrl.contains("tomatomatela")) { if (embedUrl.contains("tomatomatela")) {
try { runCatching {
val mainUrl = url.substringBefore("/embed.html#").substringAfter("https://") val mainUrl = url.substringBefore("/embed.html#").substringAfter("https://")
val headers = headers.newBuilder() val headers = headers.newBuilder()
.set("authority", mainUrl) .set("authority", mainUrl)
@ -226,7 +226,7 @@ class Gnula : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val status = json["status"]!!.jsonPrimitive!!.content val status = json["status"]!!.jsonPrimitive!!.content
val file = json["file"]!!.jsonPrimitive!!.content val file = json["file"]!!.jsonPrimitive!!.content
if (status == "200") { videoList.add(Video(file, "$prefix Tomatomatela", file, headers = null)) } if (status == "200") { videoList.add(Video(file, "$prefix Tomatomatela", file, headers = null)) }
} catch (e: Exception) { } }
} }
if (embedUrl.contains("yourupload")) { if (embedUrl.contains("yourupload")) {
val videos = YourUploadExtractor(client).videoFromUrl(url, headers = headers) val videos = YourUploadExtractor(client).videoFromUrl(url, headers = headers)

View File

@ -131,10 +131,9 @@ class Hentaijk : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val serverId = it.attr("data-id") val serverId = it.attr("data-id")
document.select("script").forEach { script -> document.select("script").forEach { script ->
if (script.data().contains("var video = [];")) { if (script.data().contains("var video = [];")) {
val url = ( val url = script.data()
script.data().substringAfter("video[$serverId] = '<iframe class=\"player_conte\" src=\"") .substringAfter("video[$serverId] = '<iframe class=\"player_conte\" src=\"")
.substringBefore("\"") .substringBefore("\"")
)
.replace("$baseUrl/jkokru.php?u=", "http://ok.ru/videoembed/") .replace("$baseUrl/jkokru.php?u=", "http://ok.ru/videoembed/")
.replace("$baseUrl/jkvmixdrop.php?u=", "https://mixdrop.co/e/") .replace("$baseUrl/jkvmixdrop.php?u=", "https://mixdrop.co/e/")
.replace("$baseUrl/jk.php?u=", "$baseUrl/") .replace("$baseUrl/jk.php?u=", "$baseUrl/")

View File

@ -129,7 +129,7 @@ class MonosChinos : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} }
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
val genreFilter = (filters.find { it is GenreFilter } as? GenreFilter?) ?: GenreFilter() val genreFilter = filters.filterIsInstance<GenreFilter>().firstOrNull() ?: GenreFilter()
val yearFilter = try { val yearFilter = try {
(filters.find { it is YearFilter } as YearFilter).state.toInt() (filters.find { it is YearFilter } as YearFilter).state.toInt()
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -16,7 +16,7 @@ class ProteaExtractor() {
private val json: Json by injectLazy() private val json: Json by injectLazy()
fun videosFromUrl(url: String, qualityPrefix: String = "Protea", headers: Headers): List<Video> { fun videosFromUrl(url: String, qualityPrefix: String = "Protea", headers: Headers): List<Video> {
val videoList = mutableListOf<Video>() val videoList = mutableListOf<Video>()
try { runCatching {
val document = Jsoup.connect(url).headers(headers.toMap()).ignoreContentType(true).method(Connection.Method.POST).execute() val document = Jsoup.connect(url).headers(headers.toMap()).ignoreContentType(true).method(Connection.Method.POST).execute()
if (document!!.body()!!.isNotEmpty()) { if (document!!.body()!!.isNotEmpty()) {
val responseString = document.body().removePrefix("[").removeSuffix("]") val responseString = document.body().removePrefix("[").removeSuffix("]")
@ -44,7 +44,6 @@ class ProteaExtractor() {
videoList.add(Video("https://$urlVideo", quality, "https://$urlVideo", headers = newHeaders)) videoList.add(Video("https://$urlVideo", quality, "https://$urlVideo", headers = newHeaders))
} }
} }
} catch (e: Exception) {
} }
return videoList return videoList
} }

View File

@ -89,7 +89,7 @@ class SeriesflixClass : Pelisflix("Seriesflix", "https://seriesflix.video") {
val iframe = it.attr("src") val iframe = it.attr("src")
if (iframe.contains("https://sc.seriesflix.video/index.php")) { if (iframe.contains("https://sc.seriesflix.video/index.php")) {
val postKey = iframe.replace("https://sc.seriesflix.video/index.php?h=", "") val postKey = iframe.replace("https://sc.seriesflix.video/index.php?h=", "")
val mediaType = ("application/x-www-form-urlencoded").toMediaType() val mediaType = "application/x-www-form-urlencoded".toMediaType()
val body: RequestBody = "h=$postKey".toRequestBody(mediaType) val body: RequestBody = "h=$postKey".toRequestBody(mediaType)
val newClient = OkHttpClient().newBuilder().build() val newClient = OkHttpClient().newBuilder().build()
val requestServer = Request.Builder() val requestServer = Request.Builder()

View File

@ -167,7 +167,7 @@ open class PelisForte : ConfigurableAnimeSource, AnimeHttpSource() {
lang.contains("Castellano", true) -> "[CAST]" lang.contains("Castellano", true) -> "[CAST]"
else -> "" else -> ""
} }
val locationsDdh = client.newCall(GET(player,headers = headers.newBuilder().add("referer", src).build())) val locationsDdh = client.newCall(GET(player, headers = headers.newBuilder().add("referer", src).build()))
.execute().networkResponse.toString() .execute().networkResponse.toString()
fetchUrls(locationsDdh).forEach { fetchUrls(locationsDdh).forEach {

View File

@ -79,14 +79,14 @@ class Pelisplusph(override val name: String, override val baseUrl: String) : Pel
} else { } else {
var index = 0 var index = 0
jsoup.select(".item-season").reversed().mapIndexed { idxSeas, season -> jsoup.select(".item-season").reversed().mapIndexed { idxSeas, season ->
val seasonNumber = try { val seasonNumber = runCatching {
getNumberFromString(season.selectFirst(".item-season-title")!!.ownText()) getNumberFromString(season.selectFirst(".item-season-title")!!.ownText())
} catch (_: Exception) { idxSeas + 1 } }.getOrElse { idxSeas + 1 }
season.select(".item-season-episodes a").reversed().mapIndexed { idx, ep -> season.select(".item-season-episodes a").reversed().mapIndexed { idx, ep ->
index += 1 index += 1
val noEp = try { val noEp = runCatching {
getNumberFromString(ep.ownText()) getNumberFromString(ep.ownText())
} catch (_: Exception) { idx + 1 } }.getOrElse { idx + 1 }
val episode = SEpisode.create() val episode = SEpisode.create()
episode.episode_number = index.toFloat() episode.episode_number = index.toFloat()
@ -130,7 +130,7 @@ class Pelisplusph(override val name: String, override val baseUrl: String) : Pel
val videoList = mutableListOf<Video>() val videoList = mutableListOf<Video>()
val embedUrl = url.lowercase() val embedUrl = url.lowercase()
if (embedUrl.contains("tomatomatela")) { if (embedUrl.contains("tomatomatela")) {
try { runCatching {
val mainUrl = url.substringBefore("/embed.html#").substringAfter("https://") val mainUrl = url.substringBefore("/embed.html#").substringAfter("https://")
val headers = headers.newBuilder() val headers = headers.newBuilder()
.set("authority", mainUrl) .set("authority", mainUrl)
@ -152,7 +152,7 @@ class Pelisplusph(override val name: String, override val baseUrl: String) : Pel
val status = json["status"]!!.jsonPrimitive!!.content val status = json["status"]!!.jsonPrimitive!!.content
val file = json["file"]!!.jsonPrimitive!!.content val file = json["file"]!!.jsonPrimitive!!.content
if (status == "200") { videoList.add(Video(file, "$prefix Tomatomatela", file, headers = null)) } if (status == "200") { videoList.add(Video(file, "$prefix Tomatomatela", file, headers = null)) }
} catch (e: Exception) { } }
} }
if (embedUrl.contains("yourupload")) { if (embedUrl.contains("yourupload")) {
val videos = YourUploadExtractor(client).videoFromUrl(url, headers = headers) val videos = YourUploadExtractor(client).videoFromUrl(url, headers = headers)

View File

@ -26,7 +26,7 @@ class JsUnpacker(packedJS: String?) {
*/ */
fun unpack(): String? { fun unpack(): String? {
val js = packedJS val js = packedJS
try { runCatching {
var p = var p =
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL) Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
var m = p.matcher(js) var m = p.matcher(js)
@ -35,16 +35,8 @@ class JsUnpacker(packedJS: String?) {
val radixStr = m.group(2) val radixStr = m.group(2)
val countStr = m.group(3) val countStr = m.group(3)
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray() val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
var radix = 36 val radix = radixStr.toIntOrNull() ?: 36
var count = 0 val count = countStr.toIntOrNull() ?: 0
try {
radix = radixStr.toInt()
} catch (e: Exception) {
}
try {
count = countStr.toInt()
} catch (e: Exception) {
}
if (symtab.size != count) { if (symtab.size != count) {
throw Exception("Unknown p.a.c.k.e.r. encoding") throw Exception("Unknown p.a.c.k.e.r. encoding")
} }
@ -67,7 +59,6 @@ class JsUnpacker(packedJS: String?) {
} }
return decoded.toString() return decoded.toString()
} }
} catch (e: Exception) {
} }
return null return null
} }

View File

@ -72,7 +72,7 @@ class Vostfree : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode_number = "1".toFloat() episode_number = "1".toFloat()
name = "Film" name = "Film"
} }
episode.url = ("?episode:${0}/${response.request.url}") episode.url = "?episode:0/${response.request.url}"
episodes.add(episode) episodes.add(episode)
} else { } else {
val episode = SEpisode.create().apply { val episode = SEpisode.create().apply {
@ -104,10 +104,10 @@ class Vostfree : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
if (server.lowercase() == "vudeo") { if (server.lowercase() == "vudeo") {
val playerId = it.attr("id") val playerId = it.attr("id")
val url = document.select("div#player-tabs div.tab-blocks div.tab-content div div#content_$playerId").text() val url = document.select("div#player-tabs div.tab-blocks div.tab-content div div#content_$playerId").text()
try { runCatching {
val video = VudeoExtractor(client).videosFromUrl(url) val video = VudeoExtractor(client).videosFromUrl(url)
videoList.addAll(video) videoList.addAll(video)
} catch (e: Exception) {} }
} }
if (server.lowercase() == "ok") { if (server.lowercase() == "ok") {
val playerId = it.attr("id") val playerId = it.attr("id")

View File

@ -61,7 +61,7 @@ class Kuramanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epsNum = getNumberFromEpsString(element.text()) val epsNum = getNumberFromEpsString(element.text())
episode.setUrlWithoutDomain(element.attr("href")) episode.setUrlWithoutDomain(element.attr("href"))
episode.episode_number = when { episode.episode_number = when {
(epsNum.isNotEmpty()) -> epsNum.toFloat() epsNum.isNotEmpty() -> epsNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.name = element.text() episode.name = element.text()

View File

@ -66,7 +66,7 @@ class Kuronime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epsNum = getNumberFromEpsString(element.select("span.lchx").text()) val epsNum = getNumberFromEpsString(element.select("span.lchx").text())
episode.setUrlWithoutDomain(element.selectFirst("a")!!.attr("href")) episode.setUrlWithoutDomain(element.selectFirst("a")!!.attr("href"))
episode.episode_number = when { episode.episode_number = when {
(epsNum.isNotEmpty()) -> epsNum.toFloat() epsNum.isNotEmpty() -> epsNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.name = element.select("span.lchx").text() episode.name = element.select("span.lchx").text()

View File

@ -188,7 +188,7 @@ class NeoNime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epsNum = getNumberFromEpsString(element.select("div.episodiotitle > a").text()) val epsNum = getNumberFromEpsString(element.select("div.episodiotitle > a").text())
episode.setUrlWithoutDomain(element.select("div.episodiotitle > a").attr("href")) episode.setUrlWithoutDomain(element.select("div.episodiotitle > a").attr("href"))
episode.episode_number = when { episode.episode_number = when {
(epsNum.isNotEmpty()) -> epsNum.toFloat() epsNum.isNotEmpty() -> epsNum.toFloat()
else -> 1F else -> 1F
} }
episode.name = element.select("div.episodiotitle > a").text() episode.name = element.select("div.episodiotitle > a").text()

View File

@ -71,7 +71,7 @@ class Oploverz : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val epsNum = getNumberFromEpsString(element.select(".epl-num").text()) val epsNum = getNumberFromEpsString(element.select(".epl-num").text())
episode.setUrlWithoutDomain(element.select("a").attr("href")) episode.setUrlWithoutDomain(element.select("a").attr("href"))
episode.episode_number = when { episode.episode_number = when {
(epsNum.isNotEmpty()) -> epsNum.toFloat() epsNum.isNotEmpty() -> epsNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
episode.name = element.select(".epl-title").text() episode.name = element.select(".epl-title").text()

View File

@ -76,7 +76,7 @@ class ANIMEWORLD : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.name = "Episode: " + element.text() episode.name = "Episode: " + element.text()
val epNum = getNumberFromEpsString(element.text()) val epNum = getNumberFromEpsString(element.text())
episode.episode_number = when { episode.episode_number = when {
(epNum.isNotEmpty()) -> epNum.toFloat() epNum.isNotEmpty() -> epNum.toFloatOrNull() ?: 1F
else -> 1F else -> 1F
} }
return episode return episode

View File

@ -92,8 +92,9 @@ class StreamingCommunity : ConfigurableAnimeSource, AnimeHttpSource() {
} }
} }
val hasNextPage = (response.request.url.queryParameter("offset")?.let { it.toInt() < 120 } ?: true) && val hasNextPage = response.request.url.queryParameter("offset")
animeList.size == 60 ?.toIntOrNull()
?.let { it < 120 } ?: true && animeList.size == 60
return AnimesPage(animeList, hasNextPage) return AnimesPage(animeList, hasNextPage)
} }
@ -174,8 +175,9 @@ class StreamingCommunity : ConfigurableAnimeSource, AnimeHttpSource() {
} }
} }
val hasNextPage = (response.request.url.queryParameter("offset")?.let { it.toInt() < 120 } ?: true) && val hasNextPage = response.request.url.queryParameter("offset")
animeList.size == 60 ?.toIntOrNull()
?.let { it < 120 } ?: true && animeList.size == 60
return AnimesPage(animeList, hasNextPage) return AnimesPage(animeList, hasNextPage)
} }

View File

@ -547,7 +547,7 @@ class VVVVID : ConfigurableAnimeSource, AnimeHttpSource() {
} }
private fun getRandomIntString(): String { private fun getRandomIntString(): String {
val allowedChars = ('0'..'9') val allowedChars = '0'..'9'
return (1..16) return (1..16)
.map { allowedChars.random() } .map { allowedChars.random() }
.joinToString("") .joinToString("")
@ -571,7 +571,7 @@ class VVVVID : ConfigurableAnimeSource, AnimeHttpSource() {
var b = false var b = false
val mSize = m.size val mSize = m.size
while ((!b) && o < mSize) { while (!b && o < mSize) {
var n = m[o] shl 2 var n = m[o] shl 2
o++ o++
var k = -1 var k = -1

View File

@ -238,17 +238,6 @@ class Wbijam : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
override fun episodeFromElement(element: Element): SEpisode = throw Exception("Not used") override fun episodeFromElement(element: Element): SEpisode = throw Exception("Not used")
// private fun episodeFromElement(element: Element, seasonName: String): SEpisode {
// return SEpisode.create().apply {
// name = "[$seasonName] ${element.selectFirst("td a").text()}"
// episode_number = if (episodeName.contains("Episode ", true)) {
// episodeName.substringAfter("Episode ").substringBefore(" ").toFloatOrNull() ?: 0F
// } else { 0F }
// date_upload = element.selectFirst("span.date")?.let { parseDate(it.text()) } ?: 0L
// setUrlWithoutDomain(element.selectFirst("a[href]")!!.attr("href"))
// }
// }
// ============================ Video Links ============================= // ============================ Video Links =============================
override fun fetchVideoList(episode: SEpisode): Observable<List<Video>> { override fun fetchVideoList(episode: SEpisode): Observable<List<Video>> {
@ -275,7 +264,7 @@ class Wbijam : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
?: serverDoc.selectFirst("span.odtwarzaj_vk")?.let { t -> "https://vk.com/video${t.attr("rel")}_${t.attr("id")}" } ?: "", ?: serverDoc.selectFirst("span.odtwarzaj_vk")?.let { t -> "https://vk.com/video${t.attr("rel")}_${t.attr("id")}" } ?: "",
) )
} }
} else {} }
} }
videoList.addAll( videoList.addAll(

View File

@ -152,7 +152,7 @@ class Megaflix : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
?.let { ?.let {
val season = it.first().toFloatOrNull() ?: 0F val season = it.first().toFloatOrNull() ?: 0F
val episode = it.last().toFloatOrNull() ?: 0F val episode = it.last().toFloatOrNull() ?: 0F
(season * 100F) + episode season * 100F + episode
} }
?: 0F ?: 0F
} }