AllAnime: New server (#1510)

This commit is contained in:
Secozzi
2023-04-18 12:40:28 +02:00
committed by GitHub
parent 216bdf6ae9
commit beb84f33b8
5 changed files with 51 additions and 18 deletions

View File

@ -9,6 +9,8 @@ class OkruExtractor(private val client: OkHttpClient) {
private fun fixQuality(quality: String): String {
val qualities = listOf(
Pair("ultra", "2160p"),
Pair("quad", "1440p"),
Pair("full", "1080p"),
Pair("hd", "720p"),
Pair("sd", "480p"),

View File

@ -6,7 +6,7 @@ ext {
extName = 'AllAnime'
pkgNameSuffix = 'en.allanime'
extClass = '.AllAnime'
extVersionCode = 16
extVersionCode = 17
libVersion = '13'
}

View File

@ -363,6 +363,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
video.sourceUrl.startsWith("/apivtwo/") && (
(hosterSelection.contains("default") && video.sourceName.lowercase().contains("default")) ||
(hosterSelection.contains("ac") && video.sourceName.lowercase().contains("ac")) ||
(hosterSelection.contains("ak") && video.sourceName.lowercase().contains("ak")) ||
(hosterSelection.contains("luf-mp4") && video.sourceName.lowercase().contains("luf-mp4")) ||
(hosterSelection.contains("si-hls") && video.sourceName.lowercase().contains("si-hls")) ||
(hosterSelection.contains("s-mp4") && video.sourceName.lowercase().contains("s-mp4")) ||
@ -370,7 +371,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
(hosterSelection.contains("uv-mp4") && video.sourceName.lowercase().contains("uv-mp4")) ||
(hosterSelection.contains("pn-hls") && video.sourceName.lowercase().contains("pn-hls"))
) -> {
serverList.add(Server(video.sourceUrl, "internal", video.priority))
serverList.add(Server(video.sourceUrl, "internal ${video.sourceName}", video.priority))
}
altHosterSelection.contains("player") && video.type == "player" -> {
serverList.add(Server(video.sourceUrl, "player", video.priority))
@ -402,8 +403,9 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
videoList.addAll(
serverList.parallelMap { server ->
runCatching {
when (server.sourceName) {
"internal" -> {
val sName = server.sourceName
when {
sName.startsWith("internal ") -> {
val extractor = AllAnimeExtractor(client)
val videos = runCatching {
extractor.videoFromUrl(server.sourceUrl, server.sourceName)
@ -412,7 +414,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"player" -> {
sName == "player" -> {
listOf(
Pair(
Video(
@ -424,7 +426,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
),
)
}
"streamsb" -> {
sName == "streamsb" -> {
val extractor = StreamSBExtractor(client)
val videos = runCatching {
extractor.videosFromUrl(server.sourceUrl, headers)
@ -433,7 +435,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"gogo" -> {
sName == "gogo" -> {
val extractor = VidstreamingExtractor(client, json)
val videos = runCatching {
extractor.videosFromUrl(server.sourceUrl.replace(Regex("^//"), "https://"))
@ -442,7 +444,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"dood" -> {
sName == "dood" -> {
val extractor = DoodExtractor(client)
val videos = runCatching {
extractor.videosFromUrl(server.sourceUrl)
@ -451,7 +453,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"okru" -> {
sName == "okru" -> {
val extractor = OkruExtractor(client)
val videos = runCatching {
extractor.videosFromUrl(server.sourceUrl)
@ -460,7 +462,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"mp4upload" -> {
sName == "mp4upload" -> {
val headers = headers.newBuilder().set("referer", "https://mp4upload.com/").build()
val videos = runCatching {
Mp4uploadExtractor(client).getVideoFromUrl(server.sourceUrl, headers)
@ -469,7 +471,7 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
Pair(it, server.priority)
}
}
"streamlare" -> {
sName == "streamlare" -> {
val extractor = StreamlareExtractor(client)
val videos = runCatching {
extractor.videosFromUrl(server.sourceUrl)
@ -573,9 +575,9 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
val hostSelection = MultiSelectListPreference(screen.context).apply {
key = "hoster_selection"
title = "Enable/Disable Hosts"
entries = arrayOf("Default", "Ac", "Luf-mp4", "Si-Hls", "S-mp4", "Ac-Hls", "Uv-mp4", "Pn-Hls")
entryValues = arrayOf("default", "ac", "luf-mp4", "si-hls", "s-mp4", "ac-hls", "uv-mp4", "pn-hls")
setDefaultValue(setOf("default", "ac", "luf-mp4", "si-hls", "s-mp4", "ac-hls"))
entries = arrayOf("Default", "Ac", "Ak", "Luf-mp4", "Si-Hls", "S-mp4", "Ac-Hls", "Uv-mp4", "Pn-Hls")
entryValues = arrayOf("default", "ac", "ak", "luf-mp4", "si-hls", "s-mp4", "ac-hls", "uv-mp4", "pn-hls")
setDefaultValue(setOf("default", "ac", "ak", "luf-mp4", "si-hls", "s-mp4", "ac-hls"))
setOnPreferenceChangeListener { _, newValue ->
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
@ -597,8 +599,8 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
val videoQualityPref = ListPreference(screen.context).apply {
key = "preferred_quality"
title = "Preferred quality"
entries = arrayOf("1080p", "720p", "480p", "360p", "240p", "80p")
entryValues = arrayOf("1080", "720", "480", "360", "240", "80")
entries = arrayOf("1080p", "720p", "480p", "360p", "240p", "80p", "1440p (okru only)", "2160p (okru only)")
entryValues = arrayOf("1080", "720", "480", "360", "240", "80", "1440", "2160")
setDefaultValue("1080")
summary = "%s"

View File

@ -21,9 +21,11 @@ data class VideoLink(
val link: String,
val hls: Boolean? = null,
val mp4: Boolean? = null,
val dash: Boolean? = null,
val crIframe: Boolean? = null,
val resolutionStr: String,
val subtitles: List<Subtitles>? = null,
val rawUrls: RawUrl? = null,
val portData: Stream? = null,
) {
@Serializable
@ -45,6 +47,19 @@ data class VideoLink(
val hardsub_lang: String,
)
}
@Serializable
data class RawUrl(
val vids: List<DashStreamObject>? = null,
val audios: List<DashStreamObject>? = null,
) {
@Serializable
data class DashStreamObject(
val bandwidth: Long,
val height: Int,
val url: String,
)
}
}
}
@ -52,7 +67,7 @@ class AllAnimeExtractor(private val client: OkHttpClient) {
private val json: Json by injectLazy()
private fun bytesIntoHumanReadable(bytes: Long): String? {
private fun bytesIntoHumanReadable(bytes: Long): String {
val kilobyte: Long = 1000
val megabyte = kilobyte * 1000
val gigabyte = megabyte * 1000
@ -234,6 +249,20 @@ class AllAnimeExtractor(private val client: OkHttpClient) {
}
}
}
} else if (link.dash == true) {
val audioList = link.rawUrls?.audios?.map {
Track(it.url, bytesIntoHumanReadable(it.bandwidth))
}
val videos = link.rawUrls?.vids?.map {
if (audioList == null) {
Video(it.url, "$name - ${it.height} ${bytesIntoHumanReadable(it.bandwidth)}", it.url, subtitleTracks = subtitles)
} else {
Video(it.url, "$name - ${it.height} ${bytesIntoHumanReadable(it.bandwidth)}", it.url, audioTracks = audioList, subtitleTracks = subtitles)
}
}
if (videos != null) {
videoList.addAll(videos)
}
} else {}
}

View File

@ -26,7 +26,7 @@ class StreamlareExtractor(private val client: OkHttpClient) {
val separator = "#EXT-X-STREAM-INF"
masterPlaylist.substringAfter(separator).split(separator).map {
val quality = it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",") + "p"
val quality = it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore("\n").substringBefore(",") + "p"
var videoUrl = it.substringAfter("\n").substringBefore("\n")
if (!videoUrl.startsWith("http")) videoUrl = "${masterPlaylistUrl.substringBefore("master.m3u8")}$videoUrl"
videoList.add(Video(videoUrl, "$quality (Streamlare)", videoUrl))