AllAnime: Add source - AC (#1211)

* AllAnime: Add source - AC

* Remove lies from allanime

* Add AC to preferred server list
This commit is contained in:
Secozzi
2023-01-26 07:53:41 +01:00
committed by GitHub
parent e5751ce719
commit c75ae69fd2
3 changed files with 68 additions and 8 deletions

View File

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

View File

@ -248,13 +248,14 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
val hosterSelection = preferences.getStringSet( val hosterSelection = preferences.getStringSet(
"hoster_selection", "hoster_selection",
setOf("default", "luf-mp4", "si-hls", "s-mp4", "ac-hls") setOf("default", "ac", "luf-mp4", "si-hls", "s-mp4", "ac-hls")
)!! )!!
for (video in videoJson.data.episode.sourceUrls) { for (video in videoJson.data.episode.sourceUrls) {
when { when {
video.sourceUrl.startsWith("/apivtwo/") && ( video.sourceUrl.startsWith("/apivtwo/") && (
(hosterSelection.contains("default") && video.sourceName.lowercase().contains("default")) || (hosterSelection.contains("default") && video.sourceName.lowercase().contains("default")) ||
(hosterSelection.contains("ac") && video.sourceName.lowercase().contains("ac")) ||
(hosterSelection.contains("luf-mp4") && video.sourceName.lowercase().contains("luf-mp4")) || (hosterSelection.contains("luf-mp4") && video.sourceName.lowercase().contains("luf-mp4")) ||
(hosterSelection.contains("si-hls") && video.sourceName.lowercase().contains("si-hls")) || (hosterSelection.contains("si-hls") && video.sourceName.lowercase().contains("si-hls")) ||
(hosterSelection.contains("s-mp4") && video.sourceName.lowercase().contains("s-mp4")) || (hosterSelection.contains("s-mp4") && video.sourceName.lowercase().contains("s-mp4")) ||
@ -391,8 +392,8 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
val serverPref = ListPreference(screen.context).apply { val serverPref = ListPreference(screen.context).apply {
key = "preferred_server" key = "preferred_server"
title = "Preferred Video Server" title = "Preferred Video Server"
entries = arrayOf("Site Default", "Luf-mp4", "Vid-mp4", "Yt-mp4", "Ok.ru", "Mp4upload", "Sl-mp4", "Uv-mp4", "S-mp4", "Ac-Hls", "Default") entries = arrayOf("Site Default", "Ac", "Luf-mp4", "Vid-mp4", "Yt-mp4", "Ok.ru", "Mp4upload", "Sl-mp4", "Uv-mp4", "S-mp4", "Ac-Hls", "Default")
entryValues = arrayOf("site_default", "luf-mp4", "vid-mp4", "yt-mp4", "okru", "mp4upload", "sl-mp4", "uv-mp4", "s-mp4", "ac-hls", "default") entryValues = arrayOf("site_default", "ac", "luf-mp4", "vid-mp4", "yt-mp4", "okru", "mp4upload", "sl-mp4", "uv-mp4", "s-mp4", "ac-hls", "default")
setDefaultValue("site_default") setDefaultValue("site_default")
summary = "%s" summary = "%s"
@ -407,9 +408,9 @@ class AllAnime : ConfigurableAnimeSource, AnimeHttpSource() {
val hostSelection = MultiSelectListPreference(screen.context).apply { val hostSelection = MultiSelectListPreference(screen.context).apply {
key = "hoster_selection" key = "hoster_selection"
title = "Enable/Disable Hosts" title = "Enable/Disable Hosts"
entries = arrayOf("Default", "Luf-mp4", "Si-Hls", "S-mp4", "Ac-Hls", "Uv-mp4", "Pn-Hls") entries = arrayOf("Default", "Ac", "Luf-mp4", "Si-Hls", "S-mp4", "Ac-Hls", "Uv-mp4", "Pn-Hls")
entryValues = arrayOf("default", "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", "luf-mp4", "si-hls", "s-mp4", "ac-hls")) setDefaultValue(setOf("default", "ac", "luf-mp4", "si-hls", "s-mp4", "ac-hls"))
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
preferences.edit().putStringSet(key, newValue as Set<String>).commit() preferences.edit().putStringSet(key, newValue as Set<String>).commit()

View File

@ -19,14 +19,29 @@ data class VideoLink(
val link: String, val link: String,
val hls: Boolean? = null, val hls: Boolean? = null,
val mp4: Boolean? = null, val mp4: Boolean? = null,
val crIframe: Boolean? = null,
val resolutionStr: String, val resolutionStr: String,
val subtitles: List<Subtitles>? = null val subtitles: List<Subtitles>? = null,
val portData: Stream? = null,
) { ) {
@Serializable @Serializable
data class Subtitles( data class Subtitles(
val lang: String, val lang: String,
val src: String, val src: String,
) )
@Serializable
data class Stream(
val streams: List<StreamObject>
) {
@Serializable
data class StreamObject(
val format: String,
val url: String,
val audio_lang: String,
val hardsub_lang: String,
)
}
} }
} }
@ -103,6 +118,50 @@ class AllAnimeExtractor(private val client: OkHttpClient) {
} }
} }
} }
} else if (link.crIframe == true) {
link.portData!!.streams.forEach {
if (it.format == "adaptive_dash") {
try {
videoList.add(
Video(
it.url,
"Original (AC - Dash${if (it.hardsub_lang.isEmpty()) "" else " - Hardsub: ${it.hardsub_lang}"})",
it.url,
subtitleTracks = subtitles
)
)
} catch (a: Error) {
videoList.add(
Video(
it.url,
"Original (AC - Dash${if (it.hardsub_lang.isEmpty()) "" else " - Hardsub: ${it.hardsub_lang}"})",
it.url
)
)
}
} else if (it.format == "adaptive_hls") {
val resp = runCatching {
client.newCall(
GET(it.url, headers = Headers.headersOf("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0"))
).execute()
}.getOrNull()
if (resp != null && resp.code == 200) {
val masterPlaylist = resp.body!!.string()
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:")
.forEach { t ->
val quality = t.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",") + "p (AC - HLS${if (it.hardsub_lang.isEmpty()) "" else " - Hardsub: ${it.hardsub_lang}"})"
var videoUrl = t.substringAfter("\n").substringBefore("\n")
try {
videoList.add(Video(videoUrl, quality, videoUrl, subtitleTracks = subtitles))
} catch (_: Error) {
videoList.add(Video(videoUrl, quality, videoUrl))
}
}
}
}
}
} else {} } else {}
} }