@@ -25,6 +25,7 @@ import com.lagradost.cloudstream3.newAnimeSearchResponse
2525import com.lagradost.cloudstream3.newEpisode
2626import com.lagradost.cloudstream3.newHomePageResponse
2727import com.lagradost.cloudstream3.newMovieLoadResponse
28+ import com.lagradost.cloudstream3.newSubtitleFile
2829import com.lagradost.cloudstream3.utils.ExtractorLink
2930import com.lagradost.cloudstream3.utils.M3u8Helper
3031import com.lagradost.models.AESPlayerDecodedModel
@@ -55,6 +56,7 @@ class UASerialsProProvider : MainAPI() {
5556 )
5657
5758 val fileRegex = " file\\ s*:\\ s*[\" ']([^\" ,']+?)[\" ']" .toRegex()
59+ val subsRegex = " subtitle\\ s*:\\ s*[\" ']([^\" ,']+?)[\" ']" .toRegex()
5860 val USER_AGENT = " Mozilla/5.0 (X11; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0"
5961
6062 // Sections
@@ -242,6 +244,17 @@ class UASerialsProProvider : MainAPI() {
242244 streamUrl = if (m3u8Url.startsWith(" http" )) m3u8Url else Decoder .decodeAndReverse(m3u8Url)!! ,
243245 referer = " https://tortuga.wtf/" ,
244246 ).dropLast(1 ).forEach(callback)
247+
248+ val subtitleUrl = Decoder .decodeAndReverse(subsRegex.find(html)?.groups?.get(1 )?.value ? : " " )
249+
250+ if (subtitleUrl.isNullOrBlank()) return true
251+ subtitleCallback.invoke(
252+ newSubtitleFile(
253+ subtitleUrl.substringAfterLast(" [" ).substringBefore(" ]" ),
254+ subtitleUrl.substringAfter(" ]" )
255+ )
256+ )
257+
245258 return true
246259 }
247260
@@ -258,17 +271,28 @@ class UASerialsProProvider : MainAPI() {
258271 // Log.d("CakesTwix-Debug", decryptData)
259272 Gson ().fromJson<List <DecodedJSON >>(decryptData, listDecodedJSONModel)[0 ]
260273 .seasons[dataList[0 ].toInt()].episodes[dataList[1 ].toInt()].sounds.forEach { episode ->
261- val m3u8Url = fileRegex.find( app.get(episode.url,
274+ val playerData = app.get(episode.url,
262275 headers = mapOf (
263276 " User-Agent" to USER_AGENT ,
264277 " Referer" to mainUrl
265- )).document.select(" script[type=text/javascript]" ).html())?.groups?.get(1 )?.value ? : " "
278+ ))
279+
280+ val m3u8Url = fileRegex.find(playerData.document.select(" script[type=text/javascript]" ).html())?.groups?.get(1 )?.value ? : " "
266281
267282 M3u8Helper .generateM3u8(
268283 source = episode.title,
269284 streamUrl = if (m3u8Url.startsWith(" http" )) m3u8Url else Decoder .decodeAndReverse(m3u8Url)!! ,
270285 referer = mainUrl
271286 ).dropLast(1 ).forEach(callback)
287+
288+ val subtitleUrl = Decoder .decodeAndReverse(subsRegex.find(playerData.document.select(" script[type=text/javascript]" ).html())?.groups?.get(1 )?.value ? : " " )
289+
290+ subtitleCallback.invoke(
291+ newSubtitleFile(
292+ subtitleUrl!! .substringAfterLast(" [" ).substringBefore(" ]" ),
293+ subtitleUrl.substringAfter(" ]" )
294+ )
295+ )
272296 }
273297 return true
274298 }
0 commit comments