small fix

This commit is contained in:
hexated 2023-03-11 07:52:21 +07:00
parent 491298857c
commit ec7c2a1be7
2 changed files with 26 additions and 9 deletions

View file

@ -2738,19 +2738,34 @@ object SoraExtractor : SoraStream() {
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit, callback: (ExtractorLink) -> Unit,
) { ) {
val slug = title.createSlug() val query = if (season == null) {
val url = if (season == null) { title
"$ask4MoviesAPI/$slug-$year"
} else { } else {
"$ask4MoviesAPI/$slug-season-$season" "$title season $season"
}
val mediaData =
app.get("$ask4MoviesAPI/?s=$query").document.select("div#search-content div.item").map {
it.selectFirst("div.main-item a")
}
val media = if (mediaData.size == 1) {
mediaData.firstOrNull()
} else {
mediaData.find {
if (season == null) {
it?.text().equals("$title ($year)", true)
} else {
it?.text().equals("$title (Season $season)", true)
}
}
} }
val doc = app.get(url).document val epsDoc = app.get(media?.attr("href") ?: return).document
val iframe = if(season == null) { val iframe = if (season == null) {
doc.select("div#player-embed iframe").attr("data-src") epsDoc.select("div#player-embed iframe").attr("data-src")
} else { } else {
doc.select("ul.group-links-list li:nth-child($episode) a").attr("data-embed-src") epsDoc.select("ul.group-links-list li:nth-child($episode) a").attr("data-embed-src")
} }
loadExtractor(iframe, ask4MoviesAPI, subtitleCallback, callback) loadExtractor(iframe, ask4MoviesAPI, subtitleCallback, callback)

View file

@ -898,7 +898,9 @@ fun Headers.getGomoviesCookies(cookieKey: String = "set-cookie"): Map<String, St
} }
fun String?.createSlug(): String? { fun String?.createSlug(): String? {
return this?.replace(Regex("[!%:'?,]|( &)"), "")?.replace(Regex("( )|( -)|(- )"), "-") return this?.replace(Regex("[^\\w\\s]"), "")
?.replace(Regex("( )|( -)|(- )"), "-")
?.replace("--", "-")
?.replace(" ", "-")?.lowercase() ?.replace(" ", "-")?.lowercase()
} }