fix(en/edytjedhgmdhm): Fix urls, update selectors & episode counter (#2126)
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 = 3
|
extVersionCode = 4
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ 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 java.net.URI
|
||||||
|
import java.net.URISyntaxException
|
||||||
|
|
||||||
class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
@ -36,19 +38,19 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
private val miscList by lazy {
|
private val miscList by lazy {
|
||||||
client.newCall(GET("$baseUrl/misc/")).execute()
|
client.newCall(GET("$baseUrl/misc/")).execute()
|
||||||
.asJsoup()
|
.asJsoup()
|
||||||
.select("a")
|
.select(LINK_SELECTOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val moviesList by lazy {
|
private val moviesList by lazy {
|
||||||
client.newCall(GET("$baseUrl/movies/")).execute()
|
client.newCall(GET("$baseUrl/movies/")).execute()
|
||||||
.asJsoup()
|
.asJsoup()
|
||||||
.select("a")
|
.select(LINK_SELECTOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val tvsList by lazy {
|
private val tvsList by lazy {
|
||||||
client.newCall(GET("$baseUrl/tvs/")).execute()
|
client.newCall(GET("$baseUrl/tvs/")).execute()
|
||||||
.asJsoup()
|
.asJsoup()
|
||||||
.select("a")
|
.select(LINK_SELECTOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================== Popular ===============================
|
// ============================== Popular ===============================
|
||||||
@ -60,10 +62,10 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
val animeList = if (results.isEmpty()) {
|
val animeList = if (results.isEmpty()) {
|
||||||
emptyList()
|
emptyList()
|
||||||
} else {
|
} else {
|
||||||
results.get(page - 1).map {
|
results[page - 1].map {
|
||||||
SAnime.create().apply {
|
SAnime.create().apply {
|
||||||
title = it.text()
|
title = it.text()
|
||||||
setUrlWithoutDomain(it.attr("abs:href"))
|
url = getUrlWithoutDomain(it.attr("abs:href"))
|
||||||
thumbnail_url = ""
|
thumbnail_url = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,10 +122,10 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
val animeList = if (results.isEmpty()) {
|
val animeList = if (results.isEmpty()) {
|
||||||
emptyList()
|
emptyList()
|
||||||
} else {
|
} else {
|
||||||
results.get(page - 1).map {
|
results[page - 1].map {
|
||||||
SAnime.create().apply {
|
SAnime.create().apply {
|
||||||
title = it.text()
|
title = it.text()
|
||||||
setUrlWithoutDomain(it.attr("abs:href"))
|
url = getUrlWithoutDomain(it.attr("abs:href"))
|
||||||
thumbnail_url = ""
|
thumbnail_url = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,13 +172,14 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> {
|
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> {
|
||||||
val episodeList = mutableListOf<SEpisode>()
|
val episodeList = mutableListOf<SEpisode>()
|
||||||
var counter = 1
|
|
||||||
|
|
||||||
fun traverseDirectory(url: String) {
|
fun traverseDirectory(url: String) {
|
||||||
val doc = client.newCall(GET(url)).execute().asJsoup()
|
val doc = client.newCall(GET(url)).execute().asJsoup()
|
||||||
|
|
||||||
doc.select("a").forEach { link ->
|
var counter = 1
|
||||||
val href = link.selectFirst("a")!!.attr("abs:href")
|
|
||||||
|
doc.select(LINK_SELECTOR).forEach { link ->
|
||||||
|
val href = link.attr("abs:href")
|
||||||
|
|
||||||
if (href.isNotBlank()) {
|
if (href.isNotBlank()) {
|
||||||
if (href.endsWith("/")) {
|
if (href.endsWith("/")) {
|
||||||
@ -190,12 +193,15 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
} else {
|
} else {
|
||||||
"/"
|
"/"
|
||||||
}
|
}
|
||||||
val size = link.selectFirst("td[data-order]")?.let { formatBytes(it.attr("data-order").toLongOrNull()) }
|
|
||||||
|
val size = link.parent()?.parent()?.nextElementSibling()?.attr("data-order")?.toLongOrNull()?.let {
|
||||||
|
formatBytes(it)
|
||||||
|
}
|
||||||
|
|
||||||
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() }
|
||||||
setUrlWithoutDomain(href)
|
this.url = getUrlWithoutDomain(href)
|
||||||
scanlator = "${if (size == null) "" else "$size • "}$extraInfo"
|
scanlator = "${if (size == null) "" else "$size • "}$extraInfo"
|
||||||
date_upload = -1L
|
date_upload = -1L
|
||||||
episode_number = counter.toFloat()
|
episode_number = counter.toFloat()
|
||||||
@ -231,15 +237,33 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
// ============================= Utilities ==============================
|
// ============================= Utilities ==============================
|
||||||
|
|
||||||
private fun formatBytes(bytes: Long?): String? {
|
private fun formatBytes(bytes: Long): String {
|
||||||
val units = arrayOf("B", "KB", "MB", "GB", "TB", "PB", "EB")
|
return when {
|
||||||
var value = bytes?.toDouble() ?: return null
|
bytes >= 1_000_000_000 -> "%.2f GB".format(bytes / 1_000_000_000.0)
|
||||||
var i = 0
|
bytes >= 1_000_000 -> "%.2f MB".format(bytes / 1_000_000.0)
|
||||||
while (value >= 1000 && i < units.size - 1) {
|
bytes >= 1_000 -> "%.2f KB".format(bytes / 1_000.0)
|
||||||
value /= 1000
|
bytes > 1 -> "$bytes bytes"
|
||||||
i++
|
bytes == 1L -> "$bytes byte"
|
||||||
|
else -> ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same as the one in `AnimeHttpSource` but path, query, and fragment are replaced with it's
|
||||||
|
// "raw" equivalent as to not decode url characters when it shouldn't
|
||||||
|
private fun getUrlWithoutDomain(orig: String): String {
|
||||||
|
return try {
|
||||||
|
val uri = URI(orig.replace(" ", "%20"))
|
||||||
|
var out = uri.rawPath
|
||||||
|
if (uri.query != null) {
|
||||||
|
out += "?" + uri.rawQuery
|
||||||
|
}
|
||||||
|
if (uri.fragment != null) {
|
||||||
|
out += "#" + uri.rawFragment
|
||||||
|
}
|
||||||
|
out
|
||||||
|
} catch (e: URISyntaxException) {
|
||||||
|
orig
|
||||||
}
|
}
|
||||||
return String.format("%.2f %s", value, units[i])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.trimInfo(): String {
|
private fun String.trimInfo(): String {
|
||||||
@ -257,5 +281,6 @@ class Edytjedhgmdhm : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val CHUNKED_SIZE = 30
|
private const val CHUNKED_SIZE = 30
|
||||||
|
private const val LINK_SELECTOR = "table tbody a:not([href=..])"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user