fix(tr/hdfilmcehennemi): Fix urls on search + add support for series (#2518)
This commit is contained in:
parent
e808670ed9
commit
51f7fbefca
@ -8,7 +8,7 @@ ext {
|
|||||||
extName = 'HDFilmCehennemi'
|
extName = 'HDFilmCehennemi'
|
||||||
pkgNameSuffix = 'tr.hdfilmcehennemi'
|
pkgNameSuffix = 'tr.hdfilmcehennemi'
|
||||||
extClass = '.HDFilmCehennemi'
|
extClass = '.HDFilmCehennemi'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
libVersion = '13'
|
libVersion = '13'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ import rx.Observable
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
@ -106,22 +108,22 @@ class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SearchResponse(val result: List<MovieDto>)
|
data class SearchResponse(val result: List<ItemDto>)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MovieDto(val title: String, val poster: String, val slug: String)
|
data class ItemDto(val title: String, val poster: String, val slug: String, val slug_prefix: String)
|
||||||
|
|
||||||
override fun searchAnimeParse(response: Response): AnimesPage {
|
override fun searchAnimeParse(response: Response): AnimesPage {
|
||||||
val data = response.parseAs<SearchResponse>()
|
val data = response.parseAs<SearchResponse>()
|
||||||
val movies = data.result.map {
|
val items = data.result.map {
|
||||||
SAnime.create().apply {
|
SAnime.create().apply {
|
||||||
title = it.title
|
title = it.title
|
||||||
thumbnail_url = "$baseUrl/uploads/poster/" + it.poster
|
thumbnail_url = "$baseUrl/uploads/poster/" + it.poster
|
||||||
url = "/" + it.slug
|
url = "/" + it.slug_prefix + it.slug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AnimesPage(movies, false)
|
return AnimesPage(items, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchAnimeSelector(): String {
|
override fun searchAnimeSelector(): String {
|
||||||
@ -138,7 +140,10 @@ class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
// =========================== Anime Details ============================
|
// =========================== Anime Details ============================
|
||||||
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
||||||
status = SAnime.COMPLETED
|
status = when {
|
||||||
|
document.location().contains("/dizi/") -> SAnime.UNKNOWN // serie
|
||||||
|
else -> SAnime.COMPLETED // movie
|
||||||
|
}
|
||||||
|
|
||||||
val div = document.selectFirst("div.card-body > div.row")!!
|
val div = document.selectFirst("div.card-body > div.row")!!
|
||||||
|
|
||||||
@ -154,21 +159,39 @@ class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================== Episodes ==============================
|
// ============================== Episodes ==============================
|
||||||
override fun fetchEpisodeList(anime: SAnime) = Observable.just(
|
override fun fetchEpisodeList(anime: SAnime): Observable<List<SEpisode>> {
|
||||||
|
// Series
|
||||||
|
if (anime.url.contains("/dizi/")) return super.fetchEpisodeList(anime)
|
||||||
|
|
||||||
|
// Movies
|
||||||
|
return Observable.just(
|
||||||
listOf(
|
listOf(
|
||||||
SEpisode.create().apply {
|
SEpisode.create().apply {
|
||||||
url = anime.url
|
url = anime.url
|
||||||
name = "Movie"
|
name = "Movie"
|
||||||
|
episode_number = 1F
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun episodeListSelector(): String {
|
|
||||||
throw UnsupportedOperationException("Not used.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun episodeFromElement(element: Element): SEpisode {
|
override fun episodeListParse(response: Response) =
|
||||||
throw UnsupportedOperationException("Not used.")
|
super.episodeListParse(response).sortedByDescending { it.episode_number }
|
||||||
|
|
||||||
|
override fun episodeListSelector() = "div#seasonsTabs-tabContent div.card-list-item > a"
|
||||||
|
|
||||||
|
private val numberRegex by lazy { Regex("(\\d+)\\.") }
|
||||||
|
|
||||||
|
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
||||||
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
|
|
||||||
|
name = element.selectFirst("h3")!!.text()
|
||||||
|
|
||||||
|
date_upload = element.selectFirst("date")?.attr("datetime")?.toDate() ?: 0L
|
||||||
|
|
||||||
|
val (seasonNum, epNum) = numberRegex.findAll(name).map { it.groupValues.last() }.toList()
|
||||||
|
// good luck trying to track this xD
|
||||||
|
episode_number = "$seasonNum.${epNum.padStart(3, '0')}".toFloatOrNull() ?: 1F
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================ Video Links =============================
|
// ============================ Video Links =============================
|
||||||
@ -179,9 +202,9 @@ class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
override fun videoListParse(response: Response): List<Video> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
val doc = response.use { it.asJsoup() }
|
val doc = response.use { it.asJsoup() }
|
||||||
|
|
||||||
return doc.select("div.card-body > nav > a:not([href=#])")
|
return doc.select("div.card-body > nav > a:not([href^=#])")
|
||||||
.drop(1)
|
.drop(1)
|
||||||
.parallelMap { client.newCall(GET(it.attr("href") + "/")).execute().use { it.asJsoup() } }
|
.parallelMap { client.newCall(GET(it.absUrl("href") + "/")).execute().use { it.asJsoup() } }
|
||||||
.let { listOf(doc) + it }
|
.let { listOf(doc) + it }
|
||||||
.mapNotNull { it.selectFirst("div.card-video > iframe")?.attr("data-src") }
|
.mapNotNull { it.selectFirst("div.card-video > iframe")?.attr("data-src") }
|
||||||
.filter(String::isNotBlank)
|
.filter(String::isNotBlank)
|
||||||
@ -246,9 +269,18 @@ class HDFilmCehennemi : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
).reversed()
|
).reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.toDate(): Long {
|
||||||
|
return runCatching { DATE_FORMATTER.parse(trim())?.time }
|
||||||
|
.getOrNull() ?: 0L
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PREFIX_SEARCH = "id:"
|
const val PREFIX_SEARCH = "id:"
|
||||||
|
|
||||||
|
private val DATE_FORMATTER by lazy {
|
||||||
|
SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
|
||||||
|
}
|
||||||
|
|
||||||
private const val PREF_QUALITY_KEY = "pref_quality_key"
|
private const val PREF_QUALITY_KEY = "pref_quality_key"
|
||||||
private const val PREF_QUALITY_TITLE = "Preferred quality"
|
private const val PREF_QUALITY_TITLE = "Preferred quality"
|
||||||
private const val PREF_QUALITY_DEFAULT = "720p"
|
private const val PREF_QUALITY_DEFAULT = "720p"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user