|
|
|
@ -1,22 +1,27 @@
|
|
|
|
|
package eu.kanade.tachiyomi.animeextension.de.animebase
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
|
|
|
|
import android.content.SharedPreferences
|
|
|
|
|
import androidx.preference.ListPreference
|
|
|
|
|
import androidx.preference.PreferenceScreen
|
|
|
|
|
import eu.kanade.tachiyomi.animeextension.de.animebase.extractors.UnpackerExtractor
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.Video
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
|
|
|
|
import eu.kanade.tachiyomi.lib.streamwishextractor.StreamWishExtractor
|
|
|
|
|
import eu.kanade.tachiyomi.lib.voeextractor.VoeExtractor
|
|
|
|
|
import eu.kanade.tachiyomi.network.GET
|
|
|
|
|
import eu.kanade.tachiyomi.network.POST
|
|
|
|
|
import eu.kanade.tachiyomi.util.asJsoup
|
|
|
|
|
import okhttp3.MediaType.Companion.toMediaType
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.async
|
|
|
|
|
import kotlinx.coroutines.awaitAll
|
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
import okhttp3.FormBody
|
|
|
|
|
import okhttp3.OkHttpClient
|
|
|
|
|
import okhttp3.Request
|
|
|
|
|
import okhttp3.RequestBody.Companion.toRequestBody
|
|
|
|
|
import okhttp3.Response
|
|
|
|
|
import org.jsoup.nodes.Document
|
|
|
|
|
import org.jsoup.nodes.Element
|
|
|
|
@ -31,110 +36,181 @@ class AnimeBase : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|
|
|
|
|
|
|
|
|
override val lang = "de"
|
|
|
|
|
|
|
|
|
|
override val supportsLatest = false
|
|
|
|
|
override val supportsLatest = true
|
|
|
|
|
|
|
|
|
|
override val client: OkHttpClient = network.cloudflareClient
|
|
|
|
|
|
|
|
|
|
private val preferences: SharedPreferences by lazy {
|
|
|
|
|
private val preferences by lazy {
|
|
|
|
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun popularAnimeSelector(): String = "div.table-responsive a"
|
|
|
|
|
// ============================== Popular ===============================
|
|
|
|
|
override fun popularAnimeRequest(page: Int) = GET("$baseUrl/favorites", headers)
|
|
|
|
|
|
|
|
|
|
override fun popularAnimeRequest(page: Int): Request {
|
|
|
|
|
val cookieInterceptor = client.newBuilder().addInterceptor(CookieInterceptor(baseUrl)).build()
|
|
|
|
|
val headers = cookieInterceptor.newCall(GET(baseUrl)).execute().request.headers
|
|
|
|
|
return GET("$baseUrl/favorites", headers = headers)
|
|
|
|
|
override fun popularAnimeSelector() = "div.table-responsive > a"
|
|
|
|
|
|
|
|
|
|
override fun popularAnimeFromElement(element: Element) = SAnime.create().apply {
|
|
|
|
|
setUrlWithoutDomain(element.attr("href").replace("/link/", "/anime/"))
|
|
|
|
|
thumbnail_url = element.selectFirst("div.thumbnail img")?.absUrl("src")
|
|
|
|
|
title = element.selectFirst("div.caption h3")!!.text()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun popularAnimeFromElement(element: Element): SAnime {
|
|
|
|
|
val anime = SAnime.create()
|
|
|
|
|
anime.setUrlWithoutDomain(element.attr("href"))
|
|
|
|
|
anime.thumbnail_url = element.select("div.thumbnail img").attr("src")
|
|
|
|
|
anime.title = element.select("div.thumbnail div.caption h3").text()
|
|
|
|
|
return anime
|
|
|
|
|
override fun popularAnimeNextPageSelector() = null
|
|
|
|
|
|
|
|
|
|
// =============================== Latest ===============================
|
|
|
|
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/updates", headers)
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesSelector() = "div.box-header + div.box-body > a"
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesFromElement(element: Element) = popularAnimeFromElement(element)
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesNextPageSelector() = null
|
|
|
|
|
|
|
|
|
|
// =============================== Search ===============================
|
|
|
|
|
private val searchToken by lazy {
|
|
|
|
|
client.newCall(GET("$baseUrl/searching", headers)).execute()
|
|
|
|
|
.use { it.asJsoup() }
|
|
|
|
|
.selectFirst("form > input[name=_token]")!!
|
|
|
|
|
.attr("value")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun popularAnimeNextPageSelector(): String? = null
|
|
|
|
|
|
|
|
|
|
// episodes
|
|
|
|
|
|
|
|
|
|
override fun episodeListSelector() = throw Exception("not used")
|
|
|
|
|
|
|
|
|
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
|
|
|
|
val document = response.asJsoup()
|
|
|
|
|
val episodeList = mutableListOf<SEpisode>()
|
|
|
|
|
val episodeElement = document.select(
|
|
|
|
|
"div.tab-content #gersub div.panel, div.tab-content #filme div.panel button[${
|
|
|
|
|
if (document.select("div.tab-content #filme div.panel button[data-dubbed=\"0\"]").isNullOrEmpty()) {
|
|
|
|
|
"data-dubbed=\"1\""
|
|
|
|
|
} else {
|
|
|
|
|
"data-dubbed=\"0\""
|
|
|
|
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
|
|
|
|
val body = FormBody.Builder()
|
|
|
|
|
.add("_token", searchToken)
|
|
|
|
|
.add("_token", searchToken)
|
|
|
|
|
.add("name_serie", query)
|
|
|
|
|
.add("jahr", "")
|
|
|
|
|
.build()
|
|
|
|
|
return POST("$baseUrl/searching", headers, body)
|
|
|
|
|
}
|
|
|
|
|
}][data-hoster=\"1\"], div.tab-content #specials div.panel button[data-dubbed=\"0\"][data-hoster=\"1\"]",
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeSelector(): String = "div.col-lg-9.col-md-8 div.box-body a"
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeFromElement(element: Element) = popularAnimeFromElement(element)
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeNextPageSelector() = null
|
|
|
|
|
|
|
|
|
|
// =========================== Anime Details ============================
|
|
|
|
|
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
|
|
|
|
setUrlWithoutDomain(document.location())
|
|
|
|
|
|
|
|
|
|
val boxBody = document.selectFirst("div.box-body.box-profile > center")!!
|
|
|
|
|
title = boxBody.selectFirst("h3")!!.text()
|
|
|
|
|
thumbnail_url = boxBody.selectFirst("img")!!.absUrl("src")
|
|
|
|
|
|
|
|
|
|
val infosDiv = document.selectFirst("div.box-body > div.col-md-9")!!
|
|
|
|
|
status = parseStatus(infosDiv.getInfo("Status"))
|
|
|
|
|
genre = infosDiv.select("strong:contains(Genre) + p > a").eachText()
|
|
|
|
|
.joinToString()
|
|
|
|
|
.takeIf(String::isNotBlank)
|
|
|
|
|
|
|
|
|
|
description = buildString {
|
|
|
|
|
infosDiv.getInfo("Beschreibung")?.also(::append)
|
|
|
|
|
|
|
|
|
|
infosDiv.getInfo("Originalname")?.also { append("\nOriginal name: $it") }
|
|
|
|
|
infosDiv.getInfo("Erscheinungsjahr")?.also { append("\nErscheinungsjahr: $it") }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun parseStatus(status: String?) = when (status?.orEmpty()) {
|
|
|
|
|
"Laufend" -> SAnime.ONGOING
|
|
|
|
|
"Abgeschlossen" -> SAnime.COMPLETED
|
|
|
|
|
else -> SAnime.UNKNOWN
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun Element.getInfo(selector: String) =
|
|
|
|
|
selectFirst("strong:contains($selector) + p")?.text()?.trim()
|
|
|
|
|
|
|
|
|
|
// ============================== Episodes ==============================
|
|
|
|
|
override fun episodeListParse(response: Response) =
|
|
|
|
|
super.episodeListParse(response).sortedWith(
|
|
|
|
|
compareBy(
|
|
|
|
|
{ it.name.startsWith("Film ") },
|
|
|
|
|
{ it.name.startsWith("Special ") },
|
|
|
|
|
{ it.episode_number },
|
|
|
|
|
),
|
|
|
|
|
).reversed()
|
|
|
|
|
|
|
|
|
|
override fun episodeListSelector() = "div.tab-content > div > div.panel"
|
|
|
|
|
|
|
|
|
|
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
|
|
|
|
val epname = element.selectFirst("h3")?.text() ?: "Episode 1"
|
|
|
|
|
val language = when (element.selectFirst("button")?.attr("data-dubbed").orEmpty()) {
|
|
|
|
|
"0" -> "Subbed"
|
|
|
|
|
else -> "Dubbed"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = epname
|
|
|
|
|
scanlator = language
|
|
|
|
|
episode_number = epname.substringBefore(":").substringAfter(" ").toFloatOrNull() ?: 0F
|
|
|
|
|
val selectorClass = element.classNames().first { it.startsWith("episode-div") }
|
|
|
|
|
setUrlWithoutDomain(element.baseUri() + "?selector=div.panel.$selectorClass")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================ Video Links =============================
|
|
|
|
|
private val hosterSettings by lazy {
|
|
|
|
|
mapOf(
|
|
|
|
|
"Streamwish" to "https://streamwish.to/e/",
|
|
|
|
|
"Voe.SX" to "https://voe.sx/e/",
|
|
|
|
|
"Lulustream" to "https://lulustream.com/e/",
|
|
|
|
|
"VTube" to "https://vtbe.to/embed-",
|
|
|
|
|
)
|
|
|
|
|
episodeElement.forEach {
|
|
|
|
|
val episode = episodeFromElement(it)
|
|
|
|
|
episodeList.add(episode)
|
|
|
|
|
}
|
|
|
|
|
return episodeList.reversed()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun episodeFromElement(element: Element): SEpisode {
|
|
|
|
|
val episode = SEpisode.create()
|
|
|
|
|
val id = element.select("button[data-hoster=\"1\"]").attr("data-serieid")
|
|
|
|
|
val epnum = element.select("button[data-hoster=\"1\"]").attr("data-folge")
|
|
|
|
|
val host = element.select("button[data-hoster=\"1\"]").attr("data-hoster")
|
|
|
|
|
if (element.attr("data-dubbed").contains("1")) {
|
|
|
|
|
if (element.attr("data-special").contains("2")) {
|
|
|
|
|
episode.episode_number = 1F
|
|
|
|
|
episode.name = "Film $epnum"
|
|
|
|
|
episode.setUrlWithoutDomain("/episode/$id/$epnum/1/$host/2")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (element.select("button[data-hoster=\"1\"]").attr("data-special").contains("2")) {
|
|
|
|
|
episode.episode_number = 1F
|
|
|
|
|
episode.name = "Film ${epnum.toInt() - 1}"
|
|
|
|
|
episode.setUrlWithoutDomain("/episode/$id/$epnum/0/$host/2")
|
|
|
|
|
} else {
|
|
|
|
|
val season = element.select("button[data-hoster=\"1\"]").attr("data-embedcontainer")
|
|
|
|
|
.substringAfter("-").substringBefore("-")
|
|
|
|
|
episode.name = "Staffel $season Folge $epnum : " + element.select("h3.panel-title").text()
|
|
|
|
|
.substringAfter(": ")
|
|
|
|
|
.replace("<span title=\"", "").replace("<span class=\"label label-danger\">Filler!</span>", "").replace(" ", "")
|
|
|
|
|
episode.episode_number = element.select("button[data-hoster=\"1\"]").attr("data-folge").toFloat()
|
|
|
|
|
episode.setUrlWithoutDomain("/episode/$id/$epnum/0/$host/0")
|
|
|
|
|
}
|
|
|
|
|
if (element.select("button[data-hoster=\"1\"]").attr("data-special").contains("1")) {
|
|
|
|
|
episode.episode_number = 1F
|
|
|
|
|
episode.name = "Special ${epnum.toInt() - 1}"
|
|
|
|
|
episode.setUrlWithoutDomain("/episode/$id/$epnum/0/$host/1")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return episode
|
|
|
|
|
override fun videoListParse(response: Response): List<Video> {
|
|
|
|
|
val doc = response.use { it.asJsoup() }
|
|
|
|
|
val selector = response.request.url.queryParameter("selector")
|
|
|
|
|
?: return emptyList()
|
|
|
|
|
|
|
|
|
|
return doc.select("$selector div.panel-body > button").toList()
|
|
|
|
|
.filter { it.text() in hosterSettings.keys }
|
|
|
|
|
.parallelMap {
|
|
|
|
|
runCatching {
|
|
|
|
|
val language = when (it.attr("data-dubbed")) {
|
|
|
|
|
"0" -> "SUB"
|
|
|
|
|
else -> "DUB"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Video Extractor
|
|
|
|
|
getVideosFromHoster(it.text(), it.attr("data-streamlink"))
|
|
|
|
|
.map { video ->
|
|
|
|
|
Video(
|
|
|
|
|
video.url,
|
|
|
|
|
"$language ${video.quality}",
|
|
|
|
|
video.videoUrl,
|
|
|
|
|
video.headers,
|
|
|
|
|
video.subtitleTracks,
|
|
|
|
|
video.audioTracks,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}.getOrElse { emptyList() }
|
|
|
|
|
}.flatten().ifEmpty { throw Exception("No videos xDDDDDD") }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun videoListParse(response: Response) =
|
|
|
|
|
throw Exception("This source only uses StreamSB as video hoster, and StreamSB is down.")
|
|
|
|
|
private val streamWishExtractor by lazy { StreamWishExtractor(client, headers) }
|
|
|
|
|
private val voeExtractor by lazy { VoeExtractor(client) }
|
|
|
|
|
private val unpackerExtractor by lazy { UnpackerExtractor(client, headers) }
|
|
|
|
|
|
|
|
|
|
private fun getVideosFromHoster(hoster: String, urlpart: String): List<Video> {
|
|
|
|
|
val url = hosterSettings.get(hoster)!! + urlpart
|
|
|
|
|
return when (hoster) {
|
|
|
|
|
"Streamwish" -> streamWishExtractor.videosFromUrl(url)
|
|
|
|
|
"Voe.SX" -> voeExtractor.videoFromUrl(url)?.let(::listOf)
|
|
|
|
|
"VTube", "Lulustream" -> unpackerExtractor.videosFromUrl(url, hoster)
|
|
|
|
|
else -> null
|
|
|
|
|
} ?: emptyList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun List<Video>.sort(): List<Video> {
|
|
|
|
|
val hoster = preferences.getString("preferred_sub", null)
|
|
|
|
|
if (hoster != null) {
|
|
|
|
|
val newList = mutableListOf<Video>()
|
|
|
|
|
var preferred = 0
|
|
|
|
|
for (video in this) {
|
|
|
|
|
if (video.quality.contains(hoster)) {
|
|
|
|
|
newList.add(preferred, video)
|
|
|
|
|
preferred++
|
|
|
|
|
} else {
|
|
|
|
|
newList.add(video)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return newList
|
|
|
|
|
}
|
|
|
|
|
return this
|
|
|
|
|
val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!!
|
|
|
|
|
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
|
|
|
|
|
|
|
|
|
return sortedWith(
|
|
|
|
|
compareBy(
|
|
|
|
|
{ it.quality.contains(lang) },
|
|
|
|
|
{ it.quality.contains(quality) },
|
|
|
|
|
{ Regex("""(\d+)p""").find(it.quality)?.groupValues?.get(1)?.toIntOrNull() ?: 0 },
|
|
|
|
|
),
|
|
|
|
|
).reversed()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun videoListSelector() = throw Exception("not used")
|
|
|
|
@ -143,70 +219,14 @@ class AnimeBase : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|
|
|
|
|
|
|
|
|
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
|
|
|
|
|
|
|
|
|
// Search
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeFromElement(element: Element): SAnime {
|
|
|
|
|
val anime = SAnime.create()
|
|
|
|
|
if (!element.text().contains("PainterCrowe")) {
|
|
|
|
|
anime.setUrlWithoutDomain(element.attr("href"))
|
|
|
|
|
anime.thumbnail_url = element.select("div.thumbnail img").attr("src")
|
|
|
|
|
anime.title = element.select("div.caption h3").text()
|
|
|
|
|
} else {
|
|
|
|
|
throw Exception("Keine Ergebnisse gefunden")
|
|
|
|
|
}
|
|
|
|
|
return anime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeNextPageSelector(): String? = null
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeSelector(): String = "div.col-lg-9.col-md-8 div.box-body a"
|
|
|
|
|
|
|
|
|
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
|
|
|
|
val cookieInterceptor = client.newBuilder().addInterceptor(CookieInterceptor(baseUrl)).build()
|
|
|
|
|
val headers = cookieInterceptor.newCall(GET(baseUrl)).execute().request.headers
|
|
|
|
|
val token = client.newCall(GET("$baseUrl/searching", headers = headers)).execute().asJsoup()
|
|
|
|
|
.select("div.box-body form input[name=\"_token\"]").attr("value")
|
|
|
|
|
return POST("$baseUrl/searching", headers = headers, body = "_token=$token&_token=$token&name_serie=$query&jahr=".toRequestBody("application/x-www-form-urlencoded".toMediaType()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Details
|
|
|
|
|
|
|
|
|
|
override fun animeDetailsParse(document: Document): SAnime {
|
|
|
|
|
val anime = SAnime.create()
|
|
|
|
|
anime.thumbnail_url = document.select("div.box-body.box-profile center img").attr("src")
|
|
|
|
|
anime.title = document.select("section.content-header small").text()
|
|
|
|
|
anime.genre = document.select("div.box-body p a span").joinToString(", ") { it.text() }
|
|
|
|
|
anime.description = document.select("div.box-body p.text-muted[style=\"text-align: justify;\"]").toString()
|
|
|
|
|
.substringAfter(";\">").substringBefore("<br")
|
|
|
|
|
anime.status = parseStatus(document.select("div.box-body span.label.label-info").text())
|
|
|
|
|
return anime
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun parseStatus(status: String?) = when {
|
|
|
|
|
status == null -> SAnime.UNKNOWN
|
|
|
|
|
status.contains("Laufend", ignoreCase = true) -> SAnime.ONGOING
|
|
|
|
|
else -> SAnime.COMPLETED
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Latest
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesNextPageSelector(): String = throw Exception("Not used")
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesFromElement(element: Element): SAnime = throw Exception("Not used")
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not used")
|
|
|
|
|
|
|
|
|
|
override fun latestUpdatesSelector(): String = throw Exception("Not used")
|
|
|
|
|
|
|
|
|
|
// Preferences
|
|
|
|
|
|
|
|
|
|
// =============================== Search ===============================
|
|
|
|
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
|
|
|
|
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")
|
|
|
|
|
ListPreference(screen.context).apply {
|
|
|
|
|
key = PREF_LANG_KEY
|
|
|
|
|
title = PREF_LANG_TITLE
|
|
|
|
|
entries = PREF_LANG_ENTRIES
|
|
|
|
|
entryValues = PREF_LANG_VALUES
|
|
|
|
|
setDefaultValue(PREF_LANG_DEFAULT)
|
|
|
|
|
summary = "%s"
|
|
|
|
|
|
|
|
|
|
setOnPreferenceChangeListener { _, newValue ->
|
|
|
|
@ -215,7 +235,42 @@ class AnimeBase : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|
|
|
|
val entry = entryValues[index] as String
|
|
|
|
|
preferences.edit().putString(key, entry).commit()
|
|
|
|
|
}
|
|
|
|
|
}.also(screen::addPreference)
|
|
|
|
|
|
|
|
|
|
ListPreference(screen.context).apply {
|
|
|
|
|
key = PREF_QUALITY_KEY
|
|
|
|
|
title = PREF_QUALITY_TITLE
|
|
|
|
|
entries = PREF_QUALITY_ENTRIES
|
|
|
|
|
entryValues = PREF_QUALITY_VALUES
|
|
|
|
|
setDefaultValue(PREF_QUALITY_DEFAULT)
|
|
|
|
|
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)
|
|
|
|
|
}.also(screen::addPreference)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================= Utilities ==============================
|
|
|
|
|
private inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> =
|
|
|
|
|
runBlocking {
|
|
|
|
|
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
private const val PREF_LANG_KEY = "preferred_sub"
|
|
|
|
|
private const val PREF_LANG_TITLE = "Standardmäßig Sub oder Dub?"
|
|
|
|
|
private const val PREF_LANG_DEFAULT = "SUB"
|
|
|
|
|
private val PREF_LANG_ENTRIES = arrayOf("Sub", "Dub")
|
|
|
|
|
private val PREF_LANG_VALUES = arrayOf("SUB", "DUB")
|
|
|
|
|
|
|
|
|
|
private const val PREF_QUALITY_KEY = "preferred_quality"
|
|
|
|
|
private const val PREF_QUALITY_TITLE = "Preferred quality"
|
|
|
|
|
private const val PREF_QUALITY_DEFAULT = "720p"
|
|
|
|
|
private val PREF_QUALITY_ENTRIES = arrayOf("1080p", "720p", "480p", "360p")
|
|
|
|
|
private val PREF_QUALITY_VALUES = arrayOf("1080p", "720p", "480p", "360p")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|