Skip to content

Commit

Permalink
Merge pull request #82 from Dark25/update-unversal
Browse files Browse the repository at this point in the history
feat(lib): Update universal and Animefenix
  • Loading branch information
Dark25 authored Sep 15, 2024
2 parents 0533872 + 4949892 commit 5cf89dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,39 @@ class UniversalExtractor(private val client: OkHttpClient) {
webView?.destroy()
webView = null
}
// terabox special case start
if ("M3U8_AUTO_360" in resultUrl) {
val qualities = listOf("1080", "720", "480", "360")
val allVideos = mutableListOf<Video>()

for (quality in qualities) {
val modifiedUrl = resultUrl.replace("M3U8_AUTO_360", "M3U8_AUTO_$quality")
val videos = playlistUtils.extractFromHls(modifiedUrl, origRequestUrl, videoNameGen = { "$prefix - $host: $it $quality" + "p" })

if (videos.isNotEmpty()) {
allVideos.addAll(videos)
}
}

if (allVideos.isNotEmpty()) {
return allVideos
}
}
// terabox special case end

return when {
"m3u8" in resultUrl -> playlistUtils.extractFromHls(resultUrl, origRequestUrl, videoNameGen = { "$prefix - $host: $it" })
"mpd" in resultUrl -> playlistUtils.extractFromDash(resultUrl, { it -> "$prefix - $host: $it" }, referer = origRequestUrl)
"mp4" in resultUrl -> Video(resultUrl, "$prefix - $host: ${customQuality ?: "Mirror"}", resultUrl, origRequestHeader.newBuilder().add("referer", origRequestUrl).build()).let(::listOf)
"m3u8" in resultUrl -> {
Log.d("UniversalExtractor", "m3u8 URL: $resultUrl")
playlistUtils.extractFromHls(resultUrl, origRequestUrl, videoNameGen = { "$prefix - $host: $it" })
}
"mpd" in resultUrl -> {
Log.d("UniversalExtractor", "mpd URL: $resultUrl")
playlistUtils.extractFromDash(resultUrl, { it -> "$prefix - $host: $it" }, referer = origRequestUrl)
}
"mp4" in resultUrl -> {
Log.d("UniversalExtractor", "mp4 URL: $resultUrl")
Video(resultUrl, "$prefix - $host: ${customQuality ?: "Mirror"}", resultUrl, origRequestHeader.newBuilder().add("referer", origRequestUrl).build()).let(::listOf)
}
else -> emptyList()
}
}
Expand All @@ -80,7 +109,7 @@ class UniversalExtractor(private val client: OkHttpClient) {
}

companion object {
const val TIMEOUT_SEC: Long = 20
private val VIDEO_REGEX by lazy { Regex("\\.(mp4|m3u8|mpd)") }
const val TIMEOUT_SEC: Long = 10
private val VIDEO_REGEX by lazy { Regex(".*\\.(mp4|m3u8|mpd)(\\?.*)?$") }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Animefenix : ConfigurableAnimeSource, AnimeHttpSource() {
StreamWishExtractor(client, headers).videosFromUrl(url, videoNameGen = { "FileLions:$it" }).also(videoList::addAll)
}
else ->
UniversalExtractor(client).videosFromUrl(url, headers).also(videoList::addAll)
UniversalExtractor(client).videosFromUrl(url, headers).let { videoList.addAll(it) }
}
} catch (_: Exception) { }
return videoList
Expand Down

0 comments on commit 5cf89dc

Please sign in to comment.