Anime24: fix & update (#908)

-dub & sub are separate now
- video list isn't empty anymore
This commit is contained in:
LuftVerbot
2022-10-09 15:08:29 +02:00
committed by GitHub
parent 1018b8cb45
commit a21fb3763e
2 changed files with 13 additions and 61 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Anime24' extName = 'Anime24'
pkgNameSuffix = 'de.anime24' pkgNameSuffix = 'de.anime24'
extClass = '.Anime24' extClass = '.Anime24'
extVersionCode = 1 extVersionCode = 2
libVersion = '13' libVersion = '13'
} }

View File

@ -78,7 +78,7 @@ class Anime24 : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
episode.episode_number = element.select("a div.epl-num").text().toFloat() episode.episode_number = element.select("a div.epl-num").text().toFloat()
val folge = element.select("a div.epl-num").text() val folge = element.select("a div.epl-num").text()
episode.name = "Folge $folge : " + element.select("a div.epl-title").text() episode.name = "Folge $folge : " + element.select("a div.epl-title").text()
episode.setUrlWithoutDomain(element.select("a").attr("href").replace("dub", "sub")) episode.setUrlWithoutDomain(element.select("a").attr("href"))
return episode return episode
} }
@ -91,75 +91,43 @@ class Anime24 : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
private fun videosFromElement(document: Document): List<Video> { private fun videosFromElement(document: Document): List<Video> {
val videoList = mutableListOf<Video>() val videoList = mutableListOf<Video>()
val link = document.select("#pembed iframe").attr("src") val link = document.select("#pembed iframe[data-lazy-src]").attr("data-lazy-src")
val hosterSelection = preferences.getStringSet("hoster_selection", setOf("stape", "voe")) val hosterSelection = preferences.getStringSet("hoster_selection", setOf("stape", "voe"))
when { when {
link.contains("https://streamtape") || link.contains("https://adblockeronstape") && hosterSelection?.contains("stape") == true -> { link.contains("https://streamtape") || link.contains("https://adblockeronstape") && hosterSelection?.contains("stape") == true -> {
val quality = "Streamtape, Sub" val quality = "Streamtape"
val video = StreamTapeExtractor(client).videoFromUrl(link, quality) val video = StreamTapeExtractor(client).videoFromUrl(link, quality)
if (video != null) { if (video != null) {
videoList.add(video) videoList.add(video)
} }
} }
link.contains("https://voe.sx") && hosterSelection?.contains("voe") == true -> { link.contains("https://voe.sx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe, Sub" val quality = "Voe"
val video = VoeExtractor(client).videoFromUrl(link, quality) val video = VoeExtractor(client).videoFromUrl(link, quality)
if (video != null) { if (video != null) {
videoList.add(video) videoList.add(video)
} }
} }
} }
val duburl = document.select("link[rel=canonical]").attr("href").replace("sub", "dub")
val dubdoc = client.newCall(GET(duburl)).execute().asJsoup()
val dublink = dubdoc.select("#pembed iframe").attr("src")
when {
dublink.contains("https://streamtape") || dublink.contains("https://adblockeronstape") && hosterSelection?.contains("stape") == true -> {
val quality = "Streamtape, Dub"
val video = StreamTapeExtractor(client).videoFromUrl(dublink, quality)
if (video != null) {
videoList.add(video)
}
}
dublink.contains("https://voe.sx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe, Dub"
val video = VoeExtractor(client).videoFromUrl(dublink, quality)
if (video != null) {
videoList.add(video)
}
}
}
return videoList.reversed() return videoList.reversed()
} }
override fun List<Video>.sort(): List<Video> { override fun List<Video>.sort(): List<Video> {
val hoster = preferences.getString("preferred_hoster", null) val hoster = preferences.getString("preferred_hoster", null)
val subPreference = preferences.getString("preferred_sub", "Sub")!!
val hosterList = mutableListOf<Video>()
val otherList = mutableListOf<Video>()
if (hoster != null) { if (hoster != null) {
val newList = mutableListOf<Video>()
var preferred = 0
for (video in this) { for (video in this) {
if (video.url.contains(hoster)) { if (video.quality.contains(hoster)) {
hosterList.add(video) newList.add(preferred, video)
preferred++
} else { } else {
otherList.add(video) newList.add(video)
} }
} }
} else otherList += this return newList
val newList = mutableListOf<Video>()
var preferred = 0
for (video in hosterList) {
if (video.quality.contains(subPreference)) {
newList.add(preferred, video)
preferred++
} else newList.add(video)
} }
for (video in otherList) { return this
if (video.quality.contains(subPreference)) {
newList.add(preferred, video)
preferred++
} else newList.add(video)
}
return newList
} }
override fun videoListSelector() = throw Exception("not used") override fun videoListSelector() = throw Exception("not used")
@ -236,22 +204,6 @@ class Anime24 : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
preferences.edit().putStringSet(key, newValue as Set<String>).commit() preferences.edit().putStringSet(key, newValue as Set<String>).commit()
} }
} }
val subPref = ListPreference(screen.context).apply {
key = "preferred_sub"
title = "Standardmäßig Sub oder Dub?"
entries = arrayOf("Sub", "Dub")
entryValues = arrayOf("Sub", "Dub")
setDefaultValue("Sub")
summary = "%s"
setOnPreferenceChangeListener { _, newValue ->
val selected = newValue as String
val index = findIndexOfValue(selected)
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}
screen.addPreference(subPref)
screen.addPreference(hosterPref) screen.addPreference(hosterPref)
screen.addPreference(subSelection) screen.addPreference(subSelection)
} }