fix(en/edytjedhgmdhm): small code cleanup & fix file sizes (#1773)
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'edytjedhgmdhm'
|
extName = 'edytjedhgmdhm'
|
||||||
pkgNameSuffix = 'en.edytjedhgmdhm'
|
pkgNameSuffix = 'en.edytjedhgmdhm'
|
||||||
extClass = '.Edytjedhgmdhm'
|
extClass = '.Edytjedhgmdhm'
|
||||||
extVersionCode = 1
|
extVersionCode = 2
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.en.edytjedhgmdhm
|
package eu.kanade.tachiyomi.animeextension.en.edytjedhgmdhm
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.preference.PreferenceScreen
|
|
||||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||||
@ -21,11 +17,9 @@ import okhttp3.Response
|
|||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import java.net.URLEncoder
|
import java.net.URLEncoder
|
||||||
|
|
||||||
class Edytjedhgmdhm : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
override val name = "edytjedhgmdhm"
|
override val name = "edytjedhgmdhm"
|
||||||
|
|
||||||
@ -39,10 +33,6 @@ class Edytjedhgmdhm : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
private val preferences: SharedPreferences by lazy {
|
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================== Popular ===============================
|
// ============================== Popular ===============================
|
||||||
|
|
||||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/tvs/#$page")
|
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/tvs/#$page")
|
||||||
@ -189,25 +179,19 @@ class Edytjedhgmdhm : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
if (videoFormats.any { t -> fullUrl.endsWith(t) }) {
|
if (videoFormats.any { t -> fullUrl.endsWith(t) }) {
|
||||||
val paths = fullUrl.toHttpUrl().pathSegments
|
val paths = fullUrl.toHttpUrl().pathSegments
|
||||||
|
|
||||||
val seasonInfoRegex = """(\([\s\w-]+\))(?: ?\[[\s\w-]+\])?${'$'}""".toRegex()
|
|
||||||
val seasonInfo = if (seasonInfoRegex.containsMatchIn(paths[1])) {
|
|
||||||
"${seasonInfoRegex.find(paths[1])!!.groups[1]!!.value} • "
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
|
|
||||||
val extraInfo = if (paths.size > 3) {
|
val extraInfo = if (paths.size > 3) {
|
||||||
"/" + paths.subList(2, paths.size - 1).joinToString("/") { it.trimInfo() }
|
"/" + paths.subList(2, paths.size - 1).joinToString("/") { it.trimInfo() }
|
||||||
} else {
|
} else {
|
||||||
""
|
"/"
|
||||||
}
|
}
|
||||||
val size = link.selectFirst("td[data-order]")?.let { formatBytes(it.text().toLongOrNull()) }
|
val size = link.selectFirst("td[data-order]")?.let { formatBytes(it.attr("data-order").toLongOrNull()) }
|
||||||
|
|
||||||
episodeList.add(
|
episodeList.add(
|
||||||
SEpisode.create().apply {
|
SEpisode.create().apply {
|
||||||
name = videoFormats.fold(paths.last()) { acc, suffix -> acc.removeSuffix(suffix).trimInfo() }
|
name = videoFormats.fold(paths.last()) { acc, suffix -> acc.removeSuffix(suffix).trimInfo() }
|
||||||
this.url = fullUrl
|
this.url = fullUrl
|
||||||
scanlator = "${if (size == null) "" else "$size"} • $seasonInfo$extraInfo"
|
scanlator = "${if (size == null) "" else "$size • "}$extraInfo"
|
||||||
|
date_upload = -1L
|
||||||
episode_number = counter.toFloat()
|
episode_number = counter.toFloat()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -258,12 +242,13 @@ class Edytjedhgmdhm : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val units = arrayOf("B", "KB", "MB", "GB", "TB", "PB", "EB")
|
val units = arrayOf("B", "KB", "MB", "GB", "TB", "PB", "EB")
|
||||||
var value = bytes?.toDouble() ?: return null
|
var value = bytes?.toDouble() ?: return null
|
||||||
var i = 0
|
var i = 0
|
||||||
while (value >= 1024 && i < units.size - 1) {
|
while (value >= 1000 && i < units.size - 1) {
|
||||||
value /= 1024
|
value /= 1000
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
return String.format("%.1f %s", value, units[i])
|
return String.format("%.2f %s", value, units[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.trimInfo(): String {
|
private fun String.trimInfo(): String {
|
||||||
var newString = this.replaceFirst("""^\[\w+\] ?""".toRegex(), "")
|
var newString = this.replaceFirst("""^\[\w+\] ?""".toRegex(), "")
|
||||||
val regex = """( ?\[[\s\w-]+\]| ?\([\s\w-]+\))(\.mkv|\.mp4|\.avi)?${'$'}""".toRegex()
|
val regex = """( ?\[[\s\w-]+\]| ?\([\s\w-]+\))(\.mkv|\.mp4|\.avi)?${'$'}""".toRegex()
|
||||||
@ -278,10 +263,6 @@ class Edytjedhgmdhm : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val CHUNKED_SIZE = 300
|
private const val CHUNKED_SIZE = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================== Settings ==============================
|
|
||||||
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) { }
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user