@@ -168,73 +168,51 @@ class OtakudesuProvider : MainAPI() {
168168 ): Boolean = coroutineScope {
169169
170170 val document = app.get(data).document
171-
172- // Gunakan coroutineScope + async untuk menggantikan argamap
173- val jobs = listOf (
174- async {
175- val scriptData =
176- document.select(" script:containsData(action:)" ).lastOrNull()?.data()
177- val token =
178- scriptData?.substringAfter(" {action:\" " )?.substringBefore(" \" }" ).toString()
179-
180- val nonce =
181- app.post(" $mainUrl /wp-admin/admin-ajax.php" , data = mapOf (" action" to token))
182- .parsed<ResponseData >().data
183- val action =
184- scriptData?.substringAfter(" ,action:\" " )?.substringBefore(" \" }" ).toString()
185-
186- val mirrorData = document.select(" div.mirrorstream > ul > li" ).mapNotNull {
187- base64Decode(it.select(" a" ).attr(" data-content" ))
188- }.toString()
189-
190- tryParseJson<List <ResponseSources >>(mirrorData)?.map { res ->
191- async {
192- val id = res.id
193- val i = res.i
194- val q = res.q
195-
196- val sources = Jsoup .parse(
197- base64Decode(
198- app.post(
199- " ${mainUrl} /wp-admin/admin-ajax.php" , data = mapOf (
200- " id" to id,
201- " i" to i,
202- " q" to q,
203- " nonce" to nonce,
204- " action" to action
205- )
206- ).parsed<ResponseData >().data
171+ val jobs = mutableListOf< kotlinx.coroutines.Deferred <Unit >>()
172+
173+ // Mirrorstream
174+ val scriptData = document.select(" script:containsData(action:)" ).lastOrNull()?.data()
175+ val token = scriptData?.substringAfter(" {action:\" " )?.substringBefore(" \" }" ).toString()
176+ val nonce = app.post(" $mainUrl /wp-admin/admin-ajax.php" , data = mapOf (" action" to token))
177+ .parsed<ResponseData >().data
178+ val action = scriptData?.substringAfter(" ,action:\" " )?.substringBefore(" \" }" ).toString()
179+
180+ val mirrorData = document.select(" div.mirrorstream > ul > li" ).mapNotNull {
181+ base64Decode(it.select(" a" ).attr(" data-content" ))
182+ }.toString()
183+
184+ tryParseJson<List <ResponseSources >>(mirrorData)?.forEach { res ->
185+ jobs.add(async {
186+ val sources = Jsoup .parse(
187+ base64Decode(
188+ app.post(
189+ " ${mainUrl} /wp-admin/admin-ajax.php" , data = mapOf (
190+ " id" to res.id,
191+ " i" to res.i,
192+ " q" to res.q,
193+ " nonce" to nonce,
194+ " action" to action
207195 )
208- ).select(" iframe" ).attr(" src" )
209-
210- loadCustomExtractor(sources, data, subtitleCallback, callback, getQuality(q))
211- }
212- }?.awaitAll()
213- },
214- async {
215- document.select(" div.download li" ).map { ele ->
216- async {
217- val quality = getQuality(ele.select(" strong" ).text())
218- ele.select(" a" ).map {
219- it.attr(" href" ) to it.text()
220- }.filter {
221- ! inBlacklist(it.first) && quality != Qualities .P360 .value
222- }.map { pair ->
223- async {
224- val link = app.get(pair.first, referer = " $mainUrl /" ).url
225- loadCustomExtractor(
226- fixedIframe(link),
227- data,
228- subtitleCallback,
229- callback,
230- quality
231- )
232- }
233- }.awaitAll()
234- }
235- }.awaitAll()
236- }
237- )
196+ ).parsed<ResponseData >().data
197+ )
198+ ).select(" iframe" ).attr(" src" )
199+
200+ loadCustomExtractor(sources, data, subtitleCallback, callback, getQuality(res.q))
201+ })
202+ }
203+
204+ // Download links
205+ document.select(" div.download li" ).forEach { ele ->
206+ val quality = getQuality(ele.select(" strong" ).text())
207+ ele.select(" a" ).map { it.attr(" href" ) to it.text() }
208+ .filter { ! inBlacklist(it.first) && quality != Qualities .P360 .value }
209+ .forEach { pair ->
210+ jobs.add(async {
211+ val link = app.get(pair.first, referer = " $mainUrl /" ).url
212+ loadCustomExtractor(fixedIframe(link), data, subtitleCallback, callback, quality)
213+ })
214+ }
215+ }
238216
239217 jobs.awaitAll()
240218 true
@@ -248,7 +226,6 @@ class OtakudesuProvider : MainAPI() {
248226 quality : Int = Qualities .Unknown .value,
249227 ) {
250228 loadExtractor(url, referer, subtitleCallback) { link ->
251- // langsung panggil callback, tidak perlu runBlocking
252229 callback.invoke(
253230 newExtractorLink(
254231 link.name,
@@ -271,7 +248,6 @@ class OtakudesuProvider : MainAPI() {
271248 val id = Regex (""" (?:/f/|/file/)(\w+)""" ).find(url)?.groupValues?.getOrNull(1 )
272249 " ${acefile} /player/$id "
273250 }
274-
275251 else -> fixUrl(url)
276252 }
277253 }
0 commit comments