added new episode path id resolution
This commit is contained in:
parent
27217d4ef0
commit
62071cc84b
1 changed files with 31 additions and 32 deletions
|
@ -123,48 +123,37 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
// =========================== Anime Details ============================
|
// =========================== Anime Details ============================
|
||||||
|
|
||||||
override fun animeDetailsParse(document: Document): SAnime = SAnime.create().apply {
|
override fun animeDetailsParse(document: Document): SAnime {
|
||||||
title = document.select("h1.title").text()
|
val anime = SAnime.create()
|
||||||
genre = document.select("div:contains(Genre) > span > a").joinToString { it.text() }
|
val newDocument = resolveSearchAnime(anime, document)
|
||||||
description = document.select("div.synopsis > div.shorting > div.content").text()
|
anime.apply {
|
||||||
author = document.select("div:contains(Studio) > span > a").text()
|
title = newDocument.select("h1.title").text()
|
||||||
status = parseStatus(document.select("div:contains(Status) > span").text())
|
genre = newDocument.select("div:contains(Genre) > span > a").joinToString { it.text() }
|
||||||
|
description = newDocument.select("div.synopsis > div.shorting > div.content").text()
|
||||||
|
author = newDocument.select("div:contains(Studio) > span > a").text()
|
||||||
|
status = parseStatus(newDocument.select("div:contains(Status) > span").text())
|
||||||
|
|
||||||
val altName = "Other name(s): "
|
val altName = "Other name(s): "
|
||||||
document.select("h1.title").attr("data-jp").let {
|
newDocument.select("h1.title").attr("data-jp").let {
|
||||||
if (it.isNotBlank()) {
|
if (it.isNotBlank()) {
|
||||||
description = when {
|
description = when {
|
||||||
description.isNullOrBlank() -> altName + it
|
description.isNullOrBlank() -> altName + it
|
||||||
else -> description + "\n\n$altName" + it
|
else -> description + "\n\n$altName" + it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return anime
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================== Episodes ==============================
|
// ============================== Episodes ==============================
|
||||||
|
|
||||||
override fun episodeListRequest(anime: SAnime): Request {
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
Log.i(name, "episodeListRequest")
|
Log.i(name, "episodeListRequest")
|
||||||
var document: Document? = null
|
val response = client.newCall(GET(baseUrl + anime.url)).execute()
|
||||||
try {
|
var document = response.asJsoup()
|
||||||
val response = client.newCall(GET(baseUrl + anime.url)).execute()
|
document = resolveSearchAnime(anime, document)
|
||||||
document = response.asJsoup()
|
val id = document.selectFirst("div[data-id]")?.attr("data-id") ?: throw Exception("ID not found")
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(name, e.toString())
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
var id = ""
|
|
||||||
if (document.location().startsWith("$baseUrl/filter?keyword=")) { // redirected to search
|
|
||||||
val tip = document.selectFirst("div.tip[data-tip]")?.attr("data-tip") ?: throw Exception("data-tip not found")
|
|
||||||
val tipParts = tip.split("?")
|
|
||||||
if (tipParts.count() == 2) {
|
|
||||||
id = tipParts[0]
|
|
||||||
} else {
|
|
||||||
throw Exception("data-tip malformed")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
id = document.selectFirst("div[data-id]")?.attr("data-id") ?: throw Exception("ID not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
val vrf = utils.vrfEncrypt(ENCRYPTION_KEY, id)
|
val vrf = utils.vrfEncrypt(ENCRYPTION_KEY, id)
|
||||||
|
|
||||||
|
@ -335,6 +324,16 @@ class Aniwave : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveSearchAnime(anime: SAnime, document: Document): Document {
|
||||||
|
if (document.location().startsWith("$baseUrl/filter?keyword=")) { // redirected to search
|
||||||
|
val element = document.selectFirst(searchAnimeSelector())
|
||||||
|
val foundAnimePath = element?.selectFirst("a[href]")?.attr("href") ?: throw Exception("Search element not found (resolveSearch)")
|
||||||
|
anime.url = foundAnimePath //probably doesn't work as intended
|
||||||
|
return client.newCall(GET(baseUrl + foundAnimePath)).execute().asJsoup()
|
||||||
|
}
|
||||||
|
return document
|
||||||
|
}
|
||||||
|
|
||||||
private fun getHosters(): Set<String> {
|
private fun getHosters(): Set<String> {
|
||||||
val hosterSelection = preferences.getStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!!
|
val hosterSelection = preferences.getStringSet(PREF_HOSTER_KEY, PREF_HOSTER_DEFAULT)!!
|
||||||
var invalidRecord = false
|
var invalidRecord = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue