feat(src/pt): New source: Donghua no Sekai (#1826)
This commit is contained in:
22
src/pt/donghuanosekai/AndroidManifest.xml
Normal file
22
src/pt/donghuanosekai/AndroidManifest.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application>
|
||||||
|
<activity
|
||||||
|
android:name=".pt.donghuanosekai.DonghuaNoSekaiUrlActivity"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@android:style/Theme.NoDisplay">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data
|
||||||
|
android:host="donghuanosekai.com"
|
||||||
|
android:pathPattern="/..*"
|
||||||
|
android:scheme="https" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
18
src/pt/donghuanosekai/build.gradle
Normal file
18
src/pt/donghuanosekai/build.gradle
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
alias(libs.plugins.kotlin.serialization)
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
extName = 'Donghua no Sekai'
|
||||||
|
pkgNameSuffix = 'pt.donghuanosekai'
|
||||||
|
extClass = '.DonghuaNoSekai'
|
||||||
|
extVersionCode = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":lib-streamsb-extractor"))
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$rootDir/common.gradle"
|
BIN
src/pt/donghuanosekai/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
src/pt/donghuanosekai/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
src/pt/donghuanosekai/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
src/pt/donghuanosekai/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
BIN
src/pt/donghuanosekai/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
src/pt/donghuanosekai/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
src/pt/donghuanosekai/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
src/pt/donghuanosekai/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
src/pt/donghuanosekai/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
src/pt/donghuanosekai/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
@ -0,0 +1,302 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.pt.donghuanosekai
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
|
import eu.kanade.tachiyomi.animeextension.pt.donghuanosekai.extractors.DonghuaNoSekaiExtractor
|
||||||
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||||
|
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.network.GET
|
||||||
|
import eu.kanade.tachiyomi.network.POST
|
||||||
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.async
|
||||||
|
import kotlinx.coroutines.awaitAll
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
import kotlinx.serialization.decodeFromString
|
||||||
|
import kotlinx.serialization.json.Json
|
||||||
|
import okhttp3.FormBody
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.Response
|
||||||
|
import org.jsoup.Jsoup
|
||||||
|
import org.jsoup.nodes.Document
|
||||||
|
import org.jsoup.nodes.Element
|
||||||
|
import rx.Observable
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class DonghuaNoSekai : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
|
override val name = "Donghua no Sekai"
|
||||||
|
|
||||||
|
override val baseUrl = "https://donghuanosekai.com"
|
||||||
|
|
||||||
|
override val lang = "pt-BR"
|
||||||
|
|
||||||
|
override val supportsLatest = true
|
||||||
|
|
||||||
|
override fun headersBuilder() = super.headersBuilder()
|
||||||
|
.add("Referer", baseUrl)
|
||||||
|
.add("Origin", baseUrl)
|
||||||
|
|
||||||
|
private val json: Json by injectLazy()
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Popular ===============================
|
||||||
|
override fun popularAnimeRequest(page: Int) = GET(baseUrl, headers)
|
||||||
|
|
||||||
|
override fun popularAnimeSelector() = "div.sidebarContent div.navItensTop li > a"
|
||||||
|
|
||||||
|
override fun popularAnimeFromElement(element: Element) = SAnime.create().apply {
|
||||||
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
|
title = element.attr("title")
|
||||||
|
thumbnail_url = element.selectFirst("img")!!.attr("src")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun popularAnimeNextPageSelector() = null
|
||||||
|
|
||||||
|
// =============================== Latest ===============================
|
||||||
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/lancamentos?pagina=$page", headers)
|
||||||
|
|
||||||
|
override fun latestUpdatesSelector() = "div.boxContent div.itemE > a"
|
||||||
|
|
||||||
|
override fun latestUpdatesFromElement(element: Element) = SAnime.create().apply {
|
||||||
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
|
title = element.selectFirst("div.title h3")!!.text()
|
||||||
|
thumbnail_url = element.selectFirst("div.thumb img")!!.attr("src")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun latestUpdatesNextPageSelector() = "ul.content-pagination > li.next"
|
||||||
|
|
||||||
|
// =============================== Search ===============================
|
||||||
|
override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage> {
|
||||||
|
return if (query.startsWith(PREFIX_SEARCH)) { // URL intent handler
|
||||||
|
val id = query.removePrefix(PREFIX_SEARCH)
|
||||||
|
client.newCall(GET("$baseUrl/$id"))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map(::searchAnimeByIdParse)
|
||||||
|
} else {
|
||||||
|
super.fetchSearchAnime(page, query, filters)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchAnimeByIdParse(response: Response): AnimesPage {
|
||||||
|
val details = animeDetailsParse(response.asJsoup())
|
||||||
|
return AnimesPage(listOf(details), false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SearchResponseDto(
|
||||||
|
val results: List<String>,
|
||||||
|
val page: Int,
|
||||||
|
val total_page: Int = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
private val searchToken by lazy {
|
||||||
|
client.newCall(GET("$baseUrl/donghuas", headers)).execute()
|
||||||
|
.use { it.asJsoup() }
|
||||||
|
.selectFirst("div.menu_filter_box")!!
|
||||||
|
.attr("data-secury")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getFilterList() = DonghuaNoSekaiFilters.FILTER_LIST
|
||||||
|
|
||||||
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||||
|
val params = DonghuaNoSekaiFilters.getSearchParameters(filters)
|
||||||
|
val body = FormBody.Builder().apply {
|
||||||
|
add("type", "lista")
|
||||||
|
add("action", "getListFilter")
|
||||||
|
add("limit", "30")
|
||||||
|
add("token", searchToken)
|
||||||
|
add("search", query.ifBlank { "0" })
|
||||||
|
add("pagina", "$page")
|
||||||
|
val filterData = baseUrl.toHttpUrl().newBuilder().apply {
|
||||||
|
addQueryParameter("filter_animation", params.animation)
|
||||||
|
addQueryParameter("filter_audio", "undefined")
|
||||||
|
addQueryParameter("filter_letter", params.letter)
|
||||||
|
addQueryParameter("filter_order", params.orderBy)
|
||||||
|
addQueryParameter("filter_status", params.status)
|
||||||
|
addQueryParameter("type_url", "ONA")
|
||||||
|
}.build().encodedQuery
|
||||||
|
|
||||||
|
val genres = params.genres.joinToString { "\"$it\"" }
|
||||||
|
val delgenres = params.deleted_genres.joinToString { "\"$it\"" }
|
||||||
|
|
||||||
|
add("filters", """{"filter_data": "$filterData", "filter_genre_add": [$genres], "filter_genre_del": [$delgenres]}""")
|
||||||
|
}.build()
|
||||||
|
|
||||||
|
return POST("$baseUrl/wp-admin/admin-ajax.php", body = body, headers = headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun searchAnimeParse(response: Response): AnimesPage {
|
||||||
|
return runCatching {
|
||||||
|
val data = response.parseAs<SearchResponseDto>()
|
||||||
|
val animes = data.results.map(Jsoup::parse)
|
||||||
|
.mapNotNull { it.selectFirst(searchAnimeSelector()) }
|
||||||
|
.map(::searchAnimeFromElement)
|
||||||
|
val hasNext = data.total_page > data.page
|
||||||
|
AnimesPage(animes, hasNext)
|
||||||
|
}.getOrElse { AnimesPage(emptyList(), false) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun searchAnimeSelector() = "div.itemE > a"
|
||||||
|
|
||||||
|
override fun searchAnimeFromElement(element: Element) = latestUpdatesFromElement(element)
|
||||||
|
|
||||||
|
override fun searchAnimeNextPageSelector(): String? {
|
||||||
|
throw UnsupportedOperationException("Not used.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================== Anime Details ============================
|
||||||
|
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
||||||
|
val doc = getRealDoc(document)
|
||||||
|
setUrlWithoutDomain(doc.location())
|
||||||
|
thumbnail_url = doc.selectFirst("div.poster > img")!!.attr("src")
|
||||||
|
val infos = doc.selectFirst("div.dados")!!
|
||||||
|
|
||||||
|
title = infos.selectFirst("h1")!!.text()
|
||||||
|
genre = infos.select("div.genresL > a").eachText().joinToString()
|
||||||
|
artist = infos.selectFirst("ul > li:contains(Estúdio)")?.ownText()
|
||||||
|
author = infos.selectFirst("ul > li:contains(Fansub)")?.ownText()
|
||||||
|
status = infos.selectFirst("ul > li:contains(Status)")?.ownText().parseStatus()
|
||||||
|
|
||||||
|
description = buildString {
|
||||||
|
doc.select("div.articleContent:has(div:contains(Sinopse)) > div.context > p")
|
||||||
|
.eachText()
|
||||||
|
.joinToString("\n\n")
|
||||||
|
.let(::append)
|
||||||
|
|
||||||
|
append("\n")
|
||||||
|
|
||||||
|
infos.select("ul.b_flex > li")
|
||||||
|
.eachText()
|
||||||
|
.forEach { append("\n$it") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Episodes ==============================
|
||||||
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||||
|
val doc = response.use { getRealDoc(it.asJsoup()) }
|
||||||
|
return doc.select(episodeListSelector()).map(::episodeFromElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun episodeListSelector() = "div.episode_list > div.item > a"
|
||||||
|
|
||||||
|
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
||||||
|
setUrlWithoutDomain(element.attr("href"))
|
||||||
|
element.selectFirst("span.episode")!!.text().let {
|
||||||
|
name = it
|
||||||
|
episode_number = it.substringAfterLast(" ").toFloatOrNull() ?: 0F
|
||||||
|
}
|
||||||
|
date_upload = element.selectFirst("div.data")?.text().orEmpty().toDate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================ Video Links =============================
|
||||||
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
|
val doc = response.use { it.asJsoup() }
|
||||||
|
val extractor = DonghuaNoSekaiExtractor(client, headers)
|
||||||
|
|
||||||
|
return doc.select("div.slideItem[data-video-url]").parallelMap {
|
||||||
|
runCatching {
|
||||||
|
client.newCall(GET(it.attr("data-video-url"), headers)).execute()
|
||||||
|
.use { it.asJsoup() }
|
||||||
|
.let(extractor::videosFromDocument)
|
||||||
|
}.getOrElse { emptyList() }
|
||||||
|
}.flatten()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun videoListSelector(): String {
|
||||||
|
throw UnsupportedOperationException("Not used.")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun videoFromElement(element: Element): Video {
|
||||||
|
throw UnsupportedOperationException("Not used.")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun videoUrlParse(document: Document): String {
|
||||||
|
throw UnsupportedOperationException("Not used.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================== Settings ==============================
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
ListPreference(screen.context).apply {
|
||||||
|
key = PREF_QUALITY_KEY
|
||||||
|
title = PREF_QUALITY_TITLE
|
||||||
|
entries = PREF_QUALITY_VALUES
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}.also(screen::addPreference)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================= Utilities ==============================
|
||||||
|
private inline fun <reified T> Response.parseAs(): T {
|
||||||
|
return use { it.body.string() }.let(json::decodeFromString)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRealDoc(document: Document): Document {
|
||||||
|
return document.selectFirst("div.controles li.list-ep > a")?.let { link ->
|
||||||
|
client.newCall(GET(link.attr("href")))
|
||||||
|
.execute()
|
||||||
|
.use { it.asJsoup() }
|
||||||
|
} ?: document
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String?.parseStatus() = when (this?.trim()?.lowercase()) {
|
||||||
|
"completo" -> SAnime.COMPLETED
|
||||||
|
"em lançamento" -> SAnime.ONGOING
|
||||||
|
"em pausa" -> SAnime.ON_HIATUS
|
||||||
|
else -> SAnime.UNKNOWN
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.toDate(): Long {
|
||||||
|
return runCatching { DATE_FORMATTER.parse(trim())?.time }
|
||||||
|
.getOrNull() ?: 0L
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <A, B> Iterable<A>.parallelMap(crossinline f: suspend (A) -> B): List<B> =
|
||||||
|
runBlocking {
|
||||||
|
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun List<Video>.sort(): List<Video> {
|
||||||
|
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
||||||
|
return sortedWith(
|
||||||
|
compareBy { it.quality.contains(quality) },
|
||||||
|
).reversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val PREFIX_SEARCH = "id:"
|
||||||
|
|
||||||
|
private val DATE_FORMATTER by lazy {
|
||||||
|
SimpleDateFormat("MMMM dd, yyyy", Locale("pt", "BR"))
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val PREF_QUALITY_KEY = "preferred_quality"
|
||||||
|
private const val PREF_QUALITY_TITLE = "Qualidade preferida"
|
||||||
|
private const val PREF_QUALITY_DEFAULT = "720p"
|
||||||
|
private val PREF_QUALITY_VALUES = arrayOf("480p", "720p", "1080p")
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,169 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.pt.donghuanosekai
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilter.TriState
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
|
|
||||||
|
object DonghuaNoSekaiFilters {
|
||||||
|
|
||||||
|
open class QueryPartFilter(
|
||||||
|
displayName: String,
|
||||||
|
val vals: Array<Pair<String, String>>,
|
||||||
|
) : AnimeFilter.Select<String>(
|
||||||
|
displayName,
|
||||||
|
vals.map { it.first }.toTypedArray(),
|
||||||
|
) {
|
||||||
|
fun toQueryPart() = vals[state].second
|
||||||
|
}
|
||||||
|
|
||||||
|
open class TriStateFilterList(name: String, values: List<TriFilterVal>) : AnimeFilter.Group<TriState>(name, values)
|
||||||
|
class TriFilterVal(name: String) : TriState(name)
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilterList.getFirst(): R {
|
||||||
|
return first { it is R } as R
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilterList.asQueryPart(): String {
|
||||||
|
return getFirst<R>().let {
|
||||||
|
(it as QueryPartFilter).toQueryPart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun <reified R> AnimeFilterList.parseTriFilter(
|
||||||
|
options: Array<Pair<String, String>>,
|
||||||
|
): List<List<String>> {
|
||||||
|
return (getFirst<R>() as TriStateFilterList).state
|
||||||
|
.filterNot { it.isIgnored() }
|
||||||
|
.map { filter -> filter.state to options.find { it.first == filter.name }!!.second }
|
||||||
|
.groupBy { it.first } // group by state
|
||||||
|
.let {
|
||||||
|
val included = it.get(TriState.STATE_INCLUDE)?.map { it.second } ?: emptyList<String>()
|
||||||
|
val excluded = it.get(TriState.STATE_EXCLUDE)?.map { it.second } ?: emptyList<String>()
|
||||||
|
listOf(included, excluded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LetterFilter : QueryPartFilter("Primeira letra", DonghuaNoSekaiFiltersData.LETTERS)
|
||||||
|
class OrderFilter : QueryPartFilter("Ordenar por", DonghuaNoSekaiFiltersData.ORDERS)
|
||||||
|
class StatusFilter : QueryPartFilter("Status", DonghuaNoSekaiFiltersData.STATUS)
|
||||||
|
class AnimationFilter : QueryPartFilter("Tipo de animação", DonghuaNoSekaiFiltersData.ANIMATIONS)
|
||||||
|
|
||||||
|
class GenresFilter : TriStateFilterList(
|
||||||
|
"Gêneros",
|
||||||
|
DonghuaNoSekaiFiltersData.GENRES.map { TriFilterVal(it.first) },
|
||||||
|
)
|
||||||
|
|
||||||
|
val FILTER_LIST get() = AnimeFilterList(
|
||||||
|
LetterFilter(),
|
||||||
|
OrderFilter(),
|
||||||
|
StatusFilter(),
|
||||||
|
AnimationFilter(),
|
||||||
|
AnimeFilter.Separator(),
|
||||||
|
GenresFilter(),
|
||||||
|
)
|
||||||
|
|
||||||
|
data class FilterSearchParams(
|
||||||
|
val letter: String = "0",
|
||||||
|
val orderBy: String = "name",
|
||||||
|
val status: String = "all",
|
||||||
|
val animation: String = "all",
|
||||||
|
val genres: List<String> = emptyList(),
|
||||||
|
val deleted_genres: List<String> = emptyList(),
|
||||||
|
)
|
||||||
|
|
||||||
|
internal fun getSearchParameters(filters: AnimeFilterList): FilterSearchParams {
|
||||||
|
if (filters.isEmpty()) return FilterSearchParams()
|
||||||
|
val (added, deleted) = filters.parseTriFilter<GenresFilter>(DonghuaNoSekaiFiltersData.GENRES)
|
||||||
|
|
||||||
|
return FilterSearchParams(
|
||||||
|
filters.asQueryPart<LetterFilter>(),
|
||||||
|
filters.asQueryPart<OrderFilter>(),
|
||||||
|
filters.asQueryPart<StatusFilter>(),
|
||||||
|
filters.asQueryPart<AnimationFilter>(),
|
||||||
|
added,
|
||||||
|
deleted,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private object DonghuaNoSekaiFiltersData {
|
||||||
|
val EVERY = Pair(" <Selecione> ", "all")
|
||||||
|
|
||||||
|
val LETTERS = arrayOf(Pair("Selecione", "0")) + ('A'..'Z').map {
|
||||||
|
Pair(it.toString(), it.toString().lowercase())
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
|
val ORDERS = arrayOf(
|
||||||
|
Pair("Nome", "name"),
|
||||||
|
Pair("Data", "new"),
|
||||||
|
)
|
||||||
|
|
||||||
|
val ANIMATIONS = arrayOf(
|
||||||
|
EVERY,
|
||||||
|
Pair("2d", "2d"),
|
||||||
|
Pair("3d", "3d"),
|
||||||
|
)
|
||||||
|
|
||||||
|
val STATUS = arrayOf(
|
||||||
|
EVERY,
|
||||||
|
Pair("Completo", "Completed"),
|
||||||
|
Pair("Em Breve", "Upcoming"),
|
||||||
|
Pair("Em Lançamento", "Ongoing"),
|
||||||
|
Pair("Em Pausado", "Hiatus"),
|
||||||
|
)
|
||||||
|
|
||||||
|
val GENRES = arrayOf(
|
||||||
|
Pair("Artes Marciais", "54"),
|
||||||
|
Pair("Aventura", "4"),
|
||||||
|
Pair("Ação", "2"),
|
||||||
|
Pair("Boys Love", "208"),
|
||||||
|
Pair("Carros", "408"),
|
||||||
|
Pair("Comédia", "16"),
|
||||||
|
Pair("Corrida", "406"),
|
||||||
|
Pair("Crime", "392"),
|
||||||
|
Pair("Cultivo", "5"),
|
||||||
|
Pair("Demônios", "52"),
|
||||||
|
Pair("Drama", "26"),
|
||||||
|
Pair("Ecchi", "104"),
|
||||||
|
Pair("Esporte", "407"),
|
||||||
|
Pair("Fantasia", "6"),
|
||||||
|
Pair("Ficção científica", "94"),
|
||||||
|
Pair("Guerra", "22"),
|
||||||
|
Pair("Harém Reverso", "364"),
|
||||||
|
Pair("Harém", "111"),
|
||||||
|
Pair("Histórico", "11"),
|
||||||
|
Pair("Horror", "404"),
|
||||||
|
Pair("Isekai", "105"),
|
||||||
|
Pair("Jogo", "98"),
|
||||||
|
Pair("Josei", "363"),
|
||||||
|
Pair("Magia", "17"),
|
||||||
|
Pair("Mecha", "93"),
|
||||||
|
Pair("Militar", "87"),
|
||||||
|
Pair("Mistério", "149"),
|
||||||
|
Pair("Mitologia", "438"),
|
||||||
|
Pair("Paródia", "443"),
|
||||||
|
Pair("Politica", "71"),
|
||||||
|
Pair("Polícia", "223"),
|
||||||
|
Pair("Psicológico", "285"),
|
||||||
|
Pair("Reencarnação", "249"),
|
||||||
|
Pair("Romance", "12"),
|
||||||
|
Pair("Seinen", "163"),
|
||||||
|
Pair("Shoujo", "203"),
|
||||||
|
Pair("Shounen Ai", "176"),
|
||||||
|
Pair("Shounen", "33"),
|
||||||
|
Pair("Slice of Life", "106"),
|
||||||
|
Pair("Sobrenatural", "101"),
|
||||||
|
Pair("Super Poder", "127"),
|
||||||
|
Pair("Supernatural", "30"),
|
||||||
|
Pair("Suspense", "283"),
|
||||||
|
Pair("Terror", "229"),
|
||||||
|
Pair("Thriller", "34"),
|
||||||
|
Pair("Tragédia", "165"),
|
||||||
|
Pair("Vampiro", "135"),
|
||||||
|
Pair("Vida Escolar", "18"),
|
||||||
|
Pair("Violência", "252"),
|
||||||
|
Pair("Wuxia", "254"),
|
||||||
|
Pair("Xuanhuan", "256"),
|
||||||
|
Pair("Yaoi", "173"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.pt.donghuanosekai
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Springboard that accepts https://donghuanosekai.com/<item> intents
|
||||||
|
* and redirects them to the main Aniyomi process.
|
||||||
|
*/
|
||||||
|
class DonghuaNoSekaiUrlActivity : Activity() {
|
||||||
|
|
||||||
|
private val tag = javaClass.simpleName
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val pathSegments = intent?.data?.pathSegments
|
||||||
|
if (pathSegments != null && pathSegments.size > 1) {
|
||||||
|
val item = pathSegments[1]
|
||||||
|
val mainIntent = Intent().apply {
|
||||||
|
action = "eu.kanade.tachiyomi.ANIMESEARCH"
|
||||||
|
putExtra("query", "${DonghuaNoSekai.PREFIX_SEARCH}$item")
|
||||||
|
putExtra("filter", packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
startActivity(mainIntent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Log.e(tag, e.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(tag, "could not parse uri from intent $intent")
|
||||||
|
}
|
||||||
|
|
||||||
|
finish()
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.pt.donghuanosekai.extractors
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.lib.streamsbextractor.StreamSBExtractor
|
||||||
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import okhttp3.Headers
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import org.jsoup.nodes.Document
|
||||||
|
|
||||||
|
class DonghuaNoSekaiExtractor(
|
||||||
|
private val client: OkHttpClient,
|
||||||
|
private val headers: Headers,
|
||||||
|
) {
|
||||||
|
fun videosFromDocument(document: Document): List<Video> {
|
||||||
|
val iframe = document.selectFirst("iframe")
|
||||||
|
val playerId = document.location().toHttpUrl()
|
||||||
|
.queryParameter("type")
|
||||||
|
?.toIntOrNull()?.plus(1) ?: 1
|
||||||
|
val playerName = "Player $playerId"
|
||||||
|
|
||||||
|
return when (iframe) {
|
||||||
|
null -> {
|
||||||
|
val source = document.selectFirst("video > source") ?: return emptyList()
|
||||||
|
val quality = source.attr("size") + "p"
|
||||||
|
val url = source.attr("src")
|
||||||
|
listOf(Video(url, "$playerName - $quality", url, headers))
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
val iframeUrl = iframe.attr("src")
|
||||||
|
when {
|
||||||
|
iframeUrl.contains("nativov2.php") || iframeUrl.contains("/embed2/") -> {
|
||||||
|
val url = iframeUrl.toHttpUrl().let {
|
||||||
|
it.queryParameter("id") ?: it.queryParameter("v")
|
||||||
|
} ?: return emptyList()
|
||||||
|
|
||||||
|
val quality = url.substringAfter("_").substringBefore("_")
|
||||||
|
listOf(Video(url, "$playerName - $quality", url, headers))
|
||||||
|
}
|
||||||
|
else -> getVideosFromIframeUrl(iframeUrl, playerName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getVideosFromIframeUrl(iframeUrl: String, playerName: String): List<Video> {
|
||||||
|
return when {
|
||||||
|
iframeUrl.contains("sbdnsk") || iframeUrl.contains("/e/") -> {
|
||||||
|
StreamSBExtractor(client).videosFromUrl(iframeUrl, headers, playerName)
|
||||||
|
}
|
||||||
|
iframeUrl.contains("playerB.php") -> {
|
||||||
|
client.newCall(GET(iframeUrl, headers)).execute().use {
|
||||||
|
it.body.string()
|
||||||
|
.substringAfter("sources:")
|
||||||
|
.substringBefore("]")
|
||||||
|
.split("{")
|
||||||
|
.drop(1)
|
||||||
|
.map {
|
||||||
|
val url = it.substringAfter("file: \"").substringBefore('"')
|
||||||
|
val quality = it.substringAfter("label: \"")
|
||||||
|
.substringBefore('"')
|
||||||
|
.let { label ->
|
||||||
|
when (label) {
|
||||||
|
"SD" -> "480p"
|
||||||
|
"HD" -> "720p"
|
||||||
|
"FHD", "FULLHD" -> "1080p"
|
||||||
|
else -> label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Video(url, "$playerName - $quality", url, headers)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user