fix(tr/animeler): Fix anime pages + fix extractor (#2943)

This commit is contained in:
Claudemirovsky 2024-02-16 04:47:41 -03:00 committed by GitHub
parent 2b3537e96f
commit 0064c5658d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 22 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'Animeler'
extClass = '.Animeler'
extVersionCode = 9
extVersionCode = 10
}
apply from: "$rootDir/common.gradle"

View File

@ -44,6 +44,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.jsoup.Jsoup
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
@ -71,13 +72,17 @@ class Animeler : AnimeHttpSource(), ConfigurableAnimeSource {
override fun popularAnimeParse(response: Response): AnimesPage {
val results = response.parseAs<SearchResponseDto>()
val animes = results.data.map {
val doc = Jsoup.parseBodyFragment(results.data)
val animes = doc.select("div.w-full:has(div.kira-anime)").map {
SAnime.create().apply {
setUrlWithoutDomain(it.url)
thumbnail_url = it.thumbnail
title = it.title
thumbnail_url = it.selectFirst("img")?.attr("src")
with(it.selectFirst("h3 > a")!!) {
title = text()
setUrlWithoutDomain(attr("href"))
}
}
}
val page = response.request.url.queryParameter("page")?.toIntOrNull() ?: 1
val hasNextPage = page < results.pages
return AnimesPage(animes, hasNextPage)
@ -225,7 +230,7 @@ class Animeler : AnimeHttpSource(), ConfigurableAnimeSource {
override fun videoListParse(response: Response): List<Video> {
val doc = response.asJsoup()
val iframeUrl = doc.selectFirst("div.episode-player-box > iframe")
?.attr("src")
?.run { attr("data-src").ifBlank { attr("src") } }
?: doc.selectFirst("script:containsData(embedUrl)")
?.data()
?.substringAfter("\"embedUrl\": \"")

View File

@ -5,10 +5,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonPrimitive
@Serializable
data class SearchResponseDto(
val data: List<SimpleAnimeDto>,
val pages: Int,
)
data class SearchResponseDto(val data: String, val pages: Int)
@Serializable
data class PostDto(
@ -21,17 +18,6 @@ data class ThumbnailDto(private val featured_url: JsonPrimitive) {
val url = if (featured_url.isString) featured_url.content else null
}
@Serializable
data class SimpleAnimeDto(
val url: String,
val post: PostDto,
private val image: String = "",
private val images: ThumbnailDto? = null,
) {
val thumbnail = image.ifEmpty { images?.url }
val title = post.post_title
}
@Serializable
data class TaxonomyDto(val taxonomy: String = "", val terms: List<Int> = emptyList())