fix(de/kinoking): Fix video extractor (#2466)

This commit is contained in:
Claudemirovsky
2023-11-02 19:37:18 -03:00
committed by GitHub
parent 861ddd35a7
commit e0e9141062
2 changed files with 29 additions and 26 deletions

View File

@ -22,14 +22,14 @@ class Kinoking : DooPlay(
private const val PREF_HOSTER_KEY = "preferred_hoster" private const val PREF_HOSTER_KEY = "preferred_hoster"
private const val PREF_HOSTER_TITLE = "Standard-Hoster" private const val PREF_HOSTER_TITLE = "Standard-Hoster"
private const val PREF_HOSTER_DEFAULT = "https://dood" private const val PREF_HOSTER_DEFAULT = "https://dood"
private val PREF_HOSTER_ENTRIES = arrayOf("Doodstream", "Voe") private val PREF_HOSTER_ENTRIES = arrayOf("Doodstream", "Voe", "Filehosted")
private val PREF_HOSTER_VALUES = arrayOf("https://dood", "https://watchsb.com", "https://voe.sx") private val PREF_HOSTER_VALUES = arrayOf("https://dood", "https://voe.sx", "https://fs1.filehosted")
private const val PREF_HOSTER_SELECTION_KEY = "hoster_selection" private const val PREF_HOSTER_SELECTION_KEY = "hoster_selection"
private const val PREF_HOSTER_SELECTION_TITLE = "Hoster auswählen" private const val PREF_HOSTER_SELECTION_TITLE = "Hoster auswählen"
private val PREF_HOSTER_SELECTION_ENTRIES = PREF_HOSTER_ENTRIES private val PREF_HOSTER_SELECTION_ENTRIES = PREF_HOSTER_ENTRIES
private val PREF_HOSTER_SELECTION_VALUES = arrayOf("dood", "watchsb", "voe") private val PREF_HOSTER_SELECTION_VALUES = arrayOf("dood", "voe", "filehosted")
private val PREF_HOSTER_SELECTION_DEFAULT = PREF_HOSTER_SELECTION_ENTRIES.toSet() private val PREF_HOSTER_SELECTION_DEFAULT = PREF_HOSTER_SELECTION_VALUES.toSet()
} }
override val videoSortPrefKey = PREF_HOSTER_KEY override val videoSortPrefKey = PREF_HOSTER_KEY
@ -40,6 +40,9 @@ class Kinoking : DooPlay(
// ============================== Popular =============================== // ============================== Popular ===============================
override fun popularAnimeSelector(): String = "div#featured-titles div.poster" override fun popularAnimeSelector(): String = "div#featured-titles div.poster"
// =============================== Latest ===============================
override fun latestUpdatesNextPageSelector(): String = "#nextpagination"
// ============================== Episodes ============================== // ============================== Episodes ==============================
// Little workaround to show season episode names like the original extension // Little workaround to show season episode names like the original extension
// TODO: Create a "getEpisodeName(element, seasonName)" function in DooPlay class // TODO: Create a "getEpisodeName(element, seasonName)" function in DooPlay class
@ -51,19 +54,16 @@ class Kinoking : DooPlay(
name = name.replace("$substring -", "$newString :") name = name.replace("$substring -", "$newString :")
} }
// =============================== Latest ===============================
override fun latestUpdatesNextPageSelector(): String = "#nextpagination"
// ============================ Video Links ============================= // ============================ Video Links =============================
override fun videoListParse(response: Response): List<Video> { override fun videoListParse(response: Response): List<Video> {
val players = response.use { it.asJsoup().select("li.dooplay_player_option") } val players = response.use { it.asJsoup().select("li.dooplay_player_option") }
val hosterSelection = preferences.getStringSet(PREF_HOSTER_SELECTION_KEY, PREF_HOSTER_SELECTION_DEFAULT)!! val hosterSelection = preferences.getStringSet(PREF_HOSTER_SELECTION_KEY, PREF_HOSTER_SELECTION_DEFAULT)!!
return players.mapNotNull { player -> return players.flatMap { player ->
runCatching { runCatching {
val link = getPlayerUrl(player) val link = getPlayerUrl(player)
getPlayerVideos(link, player, hosterSelection) getPlayerVideos(link, player, hosterSelection)
}.getOrDefault(emptyList<Video>()) }.getOrElse { emptyList() }
}.flatten() }
} }
private fun getPlayerUrl(player: Element): String { private fun getPlayerUrl(player: Element): String {
@ -83,27 +83,30 @@ class Kinoking : DooPlay(
} }
} }
private fun getPlayerVideos(link: String, element: Element, hosterSelection: Set<String>): List<Video>? { private val doodExtractor by lazy { DoodExtractor(client) }
private val voeExtractor by lazy { VoeExtractor(client) }
private fun getPlayerVideos(link: String, element: Element, hosterSelection: Set<String>): List<Video> {
return when { return when {
link.contains("https://dood.") || link.contains("https://doodstream.") && hosterSelection.contains("dood") -> { link.contains("https://dood") && hosterSelection.contains("dood") -> {
val quality = "Doodstream" val quality = "Doodstream"
val redirect = !link.contains("https://doodstream") val redirect = !link.contains("https://doodstream")
DoodExtractor(client).videoFromUrl(link, quality, redirect) doodExtractor.videosFromUrl(link, quality, redirect)
?.let(::listOf)
} }
link.contains("https://voe.sx") && hosterSelection.contains("voe") == true -> { link.contains("https://voe.sx") && hosterSelection.contains("voe") -> {
val quality = "Voe" voeExtractor.videosFromUrl(link, "Voe")
VoeExtractor(client).videoFromUrl(link, quality) }
?.let(::listOf) link.contains("filehosted") && hosterSelection.contains("filehosted") -> {
listOf(Video(link, "Filehosted", link))
} }
else -> null else -> null
} }.orEmpty()
} }
// ============================== Settings ============================== // ============================== Settings ==============================
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
override fun setupPreferenceScreen(screen: PreferenceScreen) { override fun setupPreferenceScreen(screen: PreferenceScreen) {
val hosterPref = ListPreference(screen.context).apply { ListPreference(screen.context).apply {
key = PREF_HOSTER_KEY key = PREF_HOSTER_KEY
title = PREF_HOSTER_TITLE title = PREF_HOSTER_TITLE
entries = PREF_HOSTER_ENTRIES entries = PREF_HOSTER_ENTRIES
@ -117,8 +120,9 @@ class Kinoking : DooPlay(
val entry = entryValues[index] as String val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit() preferences.edit().putString(key, entry).commit()
} }
} }.also(screen::addPreference)
val subSelection = MultiSelectListPreference(screen.context).apply {
MultiSelectListPreference(screen.context).apply {
key = PREF_HOSTER_SELECTION_KEY key = PREF_HOSTER_SELECTION_KEY
title = PREF_HOSTER_SELECTION_TITLE title = PREF_HOSTER_SELECTION_TITLE
entries = PREF_HOSTER_SELECTION_ENTRIES entries = PREF_HOSTER_SELECTION_ENTRIES
@ -126,10 +130,9 @@ class Kinoking : DooPlay(
setDefaultValue(PREF_HOSTER_SELECTION_DEFAULT) setDefaultValue(PREF_HOSTER_SELECTION_DEFAULT)
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
@Suppress("UNCHECKED_CAST")
preferences.edit().putStringSet(key, newValue as Set<String>).commit() preferences.edit().putStringSet(key, newValue as Set<String>).commit()
} }
} }.also(screen::addPreference)
screen.addPreference(hosterPref)
screen.addPreference(subSelection)
} }
} }

View File

@ -22,7 +22,7 @@ class DooPlayGenerator : ThemeSourceGenerator {
SingleLang("DonghuaX", "https://donghuax.com", "pt-BR", isNsfw = false, overrideVersionCode = 1), SingleLang("DonghuaX", "https://donghuax.com", "pt-BR", isNsfw = false, overrideVersionCode = 1),
SingleLang("GoAnimes", "https://goanimes.net", "pt-BR", isNsfw = true, overrideVersionCode = 5), SingleLang("GoAnimes", "https://goanimes.net", "pt-BR", isNsfw = true, overrideVersionCode = 5),
SingleLang("JetAnime", "https://ssl.jetanimes.com", "fr", isNsfw = false, overrideVersionCode = 2), SingleLang("JetAnime", "https://ssl.jetanimes.com", "fr", isNsfw = false, overrideVersionCode = 2),
SingleLang("Kinoking", "https://kinoking.cc", "de", isNsfw = false, overrideVersionCode = 18), SingleLang("Kinoking", "https://kinoking.cc", "de", isNsfw = false, overrideVersionCode = 19),
SingleLang("Multimovies", "https://multimovies.live", "en", isNsfw = false, overrideVersionCode = 13), SingleLang("Multimovies", "https://multimovies.live", "en", isNsfw = false, overrideVersionCode = 13),
SingleLang("Pi Fansubs", "https://pifansubs.org", "pt-BR", isNsfw = true, overrideVersionCode = 17), SingleLang("Pi Fansubs", "https://pifansubs.org", "pt-BR", isNsfw = true, overrideVersionCode = 17),
SingleLang("Pobreflix", "https://pobreflix.biz", "pt-BR", isNsfw = true, overrideVersionCode = 2), SingleLang("Pobreflix", "https://pobreflix.biz", "pt-BR", isNsfw = true, overrideVersionCode = 2),