Ask4movie: Fix stuff (#1220)

This commit is contained in:
Secozzi
2023-01-28 19:32:24 +01:00
committed by GitHub
parent 232294fc34
commit 10c5d9d357
3 changed files with 54 additions and 15 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Ask4Movie'
pkgNameSuffix = 'en.ask4movie'
extClass = '.Ask4Movie'
extVersionCode = 2
extVersionCode = 3
libVersion = '13'
}

View File

@ -645,7 +645,14 @@ class Ask4Movie : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val bodyString = client.newCall(
GET(season.select("div.top-item a").attr("href"))
).execute().body!!.string()
val episodeUrlList = episodeListFromSeason(bodyString).reversed()
val document = Jsoup.parse(bodyString)
val episodeUrlList = if (document.selectFirst("ul.group-links-list") == null) {
episodeListFromSeason(bodyString).reversed()
} else {
episodeListFromList(document).reversed()
}
for (ep in episodeUrlList) {
val episode = SEpisode.create()
episode.name = ep.name
@ -673,6 +680,18 @@ class Ask4Movie : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
return episodeList
}
private fun episodeListFromList(document: Document): List<EpisodeUrl> {
val seasonNumber = document.selectFirst("div.top-bar-video > a.video-title").text()
.substringAfterLast("(").substringBeforeLast(")")
return document.select("ul.group-links-list > li").map {
EpisodeUrl(
"$seasonNumber Episode ${it.selectFirst("a").text()}",
it.selectFirst("a").attr("data-embed-src")
)
}
}
// https://github.com/recloudstream/cloudstream-extensions/blob/master/Ask4Movie/src/main/kotlin/com/lagradost/Ask4MovieProvider.kt
private fun episodeListFromSeason(bodyString: String): List<EpisodeUrl> {
var soup = Jsoup.parse(bodyString)
@ -681,6 +700,7 @@ class Ask4Movie : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val episodeList = mutableListOf<EpisodeUrl>()
// Get Episodes
val playlistDoc = client.newCall(GET(iframeUrl)).execute().asJsoup()
val episodeRegex = Regex("""([^\n\t]+) S(\d+).E(\d+)""")

View File

@ -19,27 +19,46 @@ data class CaptionElement(
class FilemoonExtractor(private val client: OkHttpClient) {
fun videoFromUrl(url: String): List<Video> {
try {
val jsE = client.newCall(GET(url)).execute().asJsoup().selectFirst("script:containsData(eval)").data()
val unpacked = client.newCall(GET(url)).execute().asJsoup().select("script:containsData(eval)").map {
JsUnpacker(it.data()).unpack().toString()
}.first { it.contains("{file:") }
val subtitleString = JsUnpacker(jsE).unpack().toString().substringAfter("fetch('").substringBefore("').")
val subtitleTracks = mutableListOf<Track>()
try {
if (subtitleString.isNotEmpty()) {
val subResponse = client.newCall(
GET(subtitleString)
).execute()
if (unpacked.contains("fetch('")) {
val subtitleString = unpacked.substringAfter("fetch('").substringBefore("').")
val subtitles = Json.decodeFromString<List<CaptionElement>>(subResponse.body!!.string())
for (sub in subtitles) {
subtitleTracks.add(Track(sub.file, sub.label))
try {
if (subtitleString.isNotEmpty()) {
val subResponse = client.newCall(
GET(subtitleString)
).execute()
val subtitles = Json.decodeFromString<List<CaptionElement>>(subResponse.body!!.string())
for (sub in subtitles) {
subtitleTracks.add(Track(sub.file, sub.label))
}
}
}
} catch (e: Error) {}
} catch (e: Error) {}
}
val masterUrl = unpacked.substringAfter("{file:\"").substringBefore("\"}")
val masterUrl = JsUnpacker(jsE).unpack().toString().substringAfter("{file:\"").substringBefore("\"}")
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body!!.string()
val videoList = mutableListOf<Video>()
val subtitleRegex = Regex("""#EXT-X-MEDIA:TYPE=SUBTITLES.*?NAME="(.*?)".*?URI="(.*?)"""")
try {
subtitleTracks.addAll(
subtitleRegex.findAll(masterPlaylist).map {
Track(
it.groupValues[2],
it.groupValues[1]
)
}
)
} catch (e: Error) {}
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:")
.forEach {
val quality = "Filemoon:" + it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",") + "p "