Skip to content

Commit

Permalink
fix(tr/animeler): Fix anime pages + fix extractor (aniyomiorg#2943)
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudemirovsky authored Feb 16, 2024
1 parent 2b3537e commit 0064c56
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/tr/animeler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Animeler'
extClass = '.Animeler'
extVersionCode = 9
extVersionCode = 10
}

apply from: "$rootDir/common.gradle"
Expand All @@ -17,4 +17,4 @@ dependencies {
implementation(project(":lib:uqload-extractor"))
implementation(project(":lib:voe-extractor"))
implementation(project(":lib:vudeo-extractor"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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\": \"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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())

Expand Down

0 comments on commit 0064c56

Please sign in to comment.