Update MegaCloudExtractor.kt
This commit is contained in:
parent
a8a2b0f548
commit
fe5677035b
1 changed files with 1 additions and 26 deletions
|
@ -1,7 +1,6 @@
|
|||
package eu.kanade.tachiyomi.lib.megacloudextractor
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.lib.cryptoaes.CryptoAES
|
||||
|
@ -21,7 +20,6 @@ import okhttp3.Headers
|
|||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
|
||||
class MegaCloudExtractor(
|
||||
private val client: OkHttpClient,
|
||||
|
@ -136,7 +134,7 @@ class MegaCloudExtractor(
|
|||
?.filter { it.kind == "captions" }
|
||||
?.map { Track(it.file, it.label) }
|
||||
.orEmpty()
|
||||
.let { fixSubtitles(it) }
|
||||
.let { playlistUtils.fixSubtitles(it) }
|
||||
return playlistUtils.extractFromHls(
|
||||
masterUrl,
|
||||
videoNameGen = { "$name - $it - $type" },
|
||||
|
@ -145,29 +143,6 @@ class MegaCloudExtractor(
|
|||
)
|
||||
}
|
||||
|
||||
private fun cleanSubtitleData(matchResult: MatchResult): String {
|
||||
val lineCount = matchResult.groupValues[1].count { it == '\n' }
|
||||
return "\n" + " \n".repeat(lineCount - 1)
|
||||
}
|
||||
|
||||
private fun fixSubtitles(subtitleList: List<Track>): List<Track> {
|
||||
return subtitleList.mapNotNull {
|
||||
try {
|
||||
val subData = client.newCall(GET(it.url)).execute().body.string()
|
||||
|
||||
val file = File.createTempFile("subs", "vtt")
|
||||
.also(File::deleteOnExit)
|
||||
|
||||
file.writeText(FIX_SUBTITLE_REGEX.replace(subData, ::cleanSubtitleData))
|
||||
val uri = Uri.fromFile(file)
|
||||
|
||||
Track(uri.toString(), it.lang)
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getVideoDto(url: String): VideoDto {
|
||||
val type = if (url.startsWith("https://megacloud.tv") or url.startsWith("https://megacloud.blog")) 0 else 1
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue