fix(pl/ogladajanime): big change
This commit is contained in:
parent
3eaaf47808
commit
1118a289e6
2 changed files with 28 additions and 135 deletions
|
@ -1,17 +1,9 @@
|
|||
ext {
|
||||
extName = 'OgladajAnime'
|
||||
extClass = '.OgladajAnime'
|
||||
extVersionCode = 3
|
||||
extVersionCode = 4
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
||||
|
||||
dependencies {
|
||||
implementation(project(':lib:dailymotion-extractor'))
|
||||
implementation(project(':lib:mp4upload-extractor'))
|
||||
implementation(project(':lib:sibnet-extractor'))
|
||||
implementation(project(':lib:vk-extractor'))
|
||||
implementation(project(':lib:googledrive-extractor'))
|
||||
implementation(project(':lib:cda-extractor'))
|
||||
}
|
||||
|
|
|
@ -10,17 +10,9 @@ 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.cdaextractor.CdaPlExtractor
|
||||
import eu.kanade.tachiyomi.lib.dailymotionextractor.DailymotionExtractor
|
||||
import eu.kanade.tachiyomi.lib.mp4uploadextractor.Mp4uploadExtractor
|
||||
import eu.kanade.tachiyomi.lib.sibnetextractor.SibnetExtractor
|
||||
import eu.kanade.tachiyomi.lib.vkextractor.VkExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.FormBody
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.Request
|
||||
|
@ -57,7 +49,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
// ============================== Popular ===============================
|
||||
override fun popularAnimeRequest(page: Int): Request {
|
||||
return GET("$baseUrl/search/page/$page", headers)
|
||||
return GET("$baseUrl/search/page/$page", apiHeaders)
|
||||
}
|
||||
override fun popularAnimeSelector(): String = "div#anime_main div.card.bg-white"
|
||||
|
||||
|
@ -72,7 +64,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
// =============================== Latest ===============================
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/search/new/$page", headers)
|
||||
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/search/new/$page", apiHeaders)
|
||||
|
||||
override fun latestUpdatesSelector(): String = popularAnimeSelector()
|
||||
|
||||
|
@ -82,7 +74,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
// =============================== Search ===============================
|
||||
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/search/name/$query", headers)
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/search/name/$query", apiHeaders)
|
||||
|
||||
override fun searchAnimeFromElement(element: Element): SAnime = popularAnimeFromElement(element)
|
||||
|
||||
|
@ -90,8 +82,6 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
override fun searchAnimeNextPageSelector(): String? = null
|
||||
|
||||
// prosta bez filtrów jak na razie :) są dziury ale to kiedyś sie naprawi hihi. Wystarczy dobrze wyszukać animca i powinno wyszukać.
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
override fun animeDetailsParse(document: Document): SAnime {
|
||||
return SAnime.create().apply {
|
||||
|
@ -148,89 +138,25 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
// ============================ Video Links =============================
|
||||
|
||||
private fun getPlayerUrl(id: String): String {
|
||||
val body = FormBody.Builder()
|
||||
.add("action", "change_player_url")
|
||||
.add("id", id)
|
||||
.build()
|
||||
return client.newCall(POST("$baseUrl/manager.php", apiHeaders, body))
|
||||
.execute()
|
||||
.use { response ->
|
||||
response.body.string()
|
||||
.substringAfter("\"data\":\"")
|
||||
.substringBefore("\",")
|
||||
.replace("\\", "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun videoListRequest(episode: SEpisode): Request {
|
||||
val body = FormBody.Builder()
|
||||
.add("action", "get_player_list")
|
||||
.add("id", episode.url)
|
||||
.build()
|
||||
return POST("$baseUrl/manager.php", apiHeaders, body)
|
||||
return GET("$baseUrl:8443/Player/${episode.url}", apiHeaders)
|
||||
}
|
||||
|
||||
private val vkExtractor by lazy { VkExtractor(client, headers) }
|
||||
private val cdaExtractor by lazy { CdaPlExtractor(client) }
|
||||
private val mp4uploadExtractor by lazy { Mp4uploadExtractor(client) }
|
||||
private val dailymotionExtractor by lazy { DailymotionExtractor(client, headers) }
|
||||
private val sibnetExtractor by lazy { SibnetExtractor(client) }
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val jsonResponse = json.decodeFromString<ApiResponse>(response.body.string())
|
||||
val dataObject = json.decodeFromString<ApiData>(jsonResponse.data)
|
||||
val serverList = dataObject.players.mapNotNull { player ->
|
||||
var sub = player.sub.uppercase()
|
||||
if (player.audio == "pl") {
|
||||
sub = "Lektor"
|
||||
} else if (player.sub.isEmpty() && sub != "Lektor") {
|
||||
sub = "Dub " + player.sub.uppercase()
|
||||
}
|
||||
val players = json.decodeFromString<List<ApiPlayer>>(response.body.string())
|
||||
|
||||
val subGroup = if (sub == player.sub_group?.uppercase()) "" else player.sub_group
|
||||
val subGroupPart = if (subGroup?.isNotEmpty() == true) " $subGroup - " else " "
|
||||
|
||||
val prefix = if (player.ismy > 0) {
|
||||
if (player.sub == "pl" && player.sub_group?.isNotEmpty() == true) {
|
||||
"[Odwrócone Kolory] $subGroup - "
|
||||
} else {
|
||||
"[$sub/Odwrócone Kolory]$subGroupPart"
|
||||
}
|
||||
} else {
|
||||
if (player.sub == "pl" && player.sub_group?.isNotEmpty() == true) {
|
||||
"$subGroup - "
|
||||
} else {
|
||||
"[$sub]$subGroupPart"
|
||||
}
|
||||
}
|
||||
|
||||
if (player.url !in listOf("vk", "cda", "mp4upload", "sibnet", "dailymotion")) {
|
||||
return@mapNotNull null
|
||||
}
|
||||
val url = getPlayerUrl(player.id)
|
||||
Pair(url, prefix)
|
||||
}
|
||||
// Jeśli dodadzą opcje z mozliwością edytowania mpv to zrobić tak ze jak bedą odwrócone kolory to ustawia dane do mkv <3
|
||||
return serverList.parallelCatchingFlatMapBlocking { (serverUrl, prefix) ->
|
||||
when {
|
||||
serverUrl.contains("vk.com") -> {
|
||||
vkExtractor.videosFromUrl(serverUrl, prefix)
|
||||
}
|
||||
serverUrl.contains("mp4upload") -> {
|
||||
mp4uploadExtractor.videosFromUrl(serverUrl, headers, prefix)
|
||||
}
|
||||
serverUrl.contains("cda.pl") -> {
|
||||
cdaExtractor.getVideosFromUrl(serverUrl, headers, prefix)
|
||||
}
|
||||
serverUrl.contains("dailymotion") -> {
|
||||
dailymotionExtractor.videosFromUrl(serverUrl, "$prefix Dailymotion -")
|
||||
}
|
||||
serverUrl.contains("sibnet.ru") -> {
|
||||
sibnetExtractor.videosFromUrl(serverUrl, prefix)
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
return players.map { player ->
|
||||
val host = Regex("""https?://(?:www\.)?([^/]+)""")
|
||||
.find(player.mainUrl)
|
||||
?.groupValues
|
||||
?.get(1)
|
||||
?: "unknown-host"
|
||||
Video(
|
||||
url = player.mainUrl,
|
||||
quality = if (player.extra == "inv") "[Odwrócone Kolory] $host - ${player.res}p" else "$host - ${player.res}p",
|
||||
videoUrl = player.src,
|
||||
headers = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,32 +170,23 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
|
||||
@Serializable
|
||||
data class ApiPlayer(
|
||||
val id: String,
|
||||
val audio: String? = null,
|
||||
val sub: String,
|
||||
val url: String,
|
||||
val sub_group: String? = null,
|
||||
val ismy: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ApiData(
|
||||
val players: List<ApiPlayer>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ApiResponse(
|
||||
val data: String,
|
||||
val mainUrl: String,
|
||||
val label: String,
|
||||
val res: Int,
|
||||
val src: String,
|
||||
val type: String,
|
||||
val extra: String,
|
||||
val startTime: Int,
|
||||
val endTime: Int,
|
||||
val ageValidation: Boolean,
|
||||
val youtube: String? = null,
|
||||
)
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val quality = preferences.getString("preferred_quality", "1080")!!
|
||||
val server = preferences.getString("preferred_server", "cda.pl")!!
|
||||
|
||||
return this.sortedWith(
|
||||
compareBy(
|
||||
{ it.quality.contains(quality) },
|
||||
{ it.quality.contains(server, true) },
|
||||
),
|
||||
).reversed()
|
||||
}
|
||||
|
@ -290,23 +207,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||
preferences.edit().putString(key, entry).commit()
|
||||
}
|
||||
}
|
||||
val videoServerPref = ListPreference(screen.context).apply {
|
||||
key = "preferred_server"
|
||||
title = "Preferowany serwer"
|
||||
entries = arrayOf("cda.pl", "Dailymotion", "Mp4upload", "Sibnet", "vk.com")
|
||||
entryValues = arrayOf("cda.pl", "Dailymotion", "Mp4upload", "Sibnet", "vk.com")
|
||||
setDefaultValue("cda.pl")
|
||||
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(videoQualityPref)
|
||||
screen.addPreference(videoServerPref)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue