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 {
|
ext {
|
||||||
extName = 'OgladajAnime'
|
extName = 'OgladajAnime'
|
||||||
extClass = '.OgladajAnime'
|
extClass = '.OgladajAnime'
|
||||||
extVersionCode = 3
|
extVersionCode = 4
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
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.SEpisode
|
||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
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.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
|
||||||
import eu.kanade.tachiyomi.util.parallelCatchingFlatMapBlocking
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import okhttp3.FormBody
|
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
|
@ -57,7 +49,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
// ============================== Popular ===============================
|
// ============================== Popular ===============================
|
||||||
override fun popularAnimeRequest(page: Int): Request {
|
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"
|
override fun popularAnimeSelector(): String = "div#anime_main div.card.bg-white"
|
||||||
|
|
||||||
|
@ -72,7 +64,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
// =============================== Latest ===============================
|
// =============================== 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()
|
override fun latestUpdatesSelector(): String = popularAnimeSelector()
|
||||||
|
|
||||||
|
@ -82,7 +74,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
// =============================== Search ===============================
|
// =============================== 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)
|
override fun searchAnimeFromElement(element: Element): SAnime = popularAnimeFromElement(element)
|
||||||
|
|
||||||
|
@ -90,8 +82,6 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
override fun searchAnimeNextPageSelector(): String? = null
|
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 ============================
|
// =========================== Anime Details ============================
|
||||||
override fun animeDetailsParse(document: Document): SAnime {
|
override fun animeDetailsParse(document: Document): SAnime {
|
||||||
return SAnime.create().apply {
|
return SAnime.create().apply {
|
||||||
|
@ -148,89 +138,25 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
// ============================ Video Links =============================
|
// ============================ 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 {
|
override fun videoListRequest(episode: SEpisode): Request {
|
||||||
val body = FormBody.Builder()
|
return GET("$baseUrl:8443/Player/${episode.url}", apiHeaders)
|
||||||
.add("action", "get_player_list")
|
|
||||||
.add("id", episode.url)
|
|
||||||
.build()
|
|
||||||
return POST("$baseUrl/manager.php", apiHeaders, body)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
val jsonResponse = json.decodeFromString<ApiResponse>(response.body.string())
|
val players = json.decodeFromString<List<ApiPlayer>>(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 subGroup = if (sub == player.sub_group?.uppercase()) "" else player.sub_group
|
return players.map { player ->
|
||||||
val subGroupPart = if (subGroup?.isNotEmpty() == true) " $subGroup - " else " "
|
val host = Regex("""https?://(?:www\.)?([^/]+)""")
|
||||||
|
.find(player.mainUrl)
|
||||||
val prefix = if (player.ismy > 0) {
|
?.groupValues
|
||||||
if (player.sub == "pl" && player.sub_group?.isNotEmpty() == true) {
|
?.get(1)
|
||||||
"[Odwrócone Kolory] $subGroup - "
|
?: "unknown-host"
|
||||||
} else {
|
Video(
|
||||||
"[$sub/Odwrócone Kolory]$subGroupPart"
|
url = player.mainUrl,
|
||||||
}
|
quality = if (player.extra == "inv") "[Odwrócone Kolory] $host - ${player.res}p" else "$host - ${player.res}p",
|
||||||
} else {
|
videoUrl = player.src,
|
||||||
if (player.sub == "pl" && player.sub_group?.isNotEmpty() == true) {
|
headers = null,
|
||||||
"$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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,32 +170,23 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ApiPlayer(
|
data class ApiPlayer(
|
||||||
val id: String,
|
val mainUrl: String,
|
||||||
val audio: String? = null,
|
val label: String,
|
||||||
val sub: String,
|
val res: Int,
|
||||||
val url: String,
|
val src: String,
|
||||||
val sub_group: String? = null,
|
val type: String,
|
||||||
val ismy: Int,
|
val extra: String,
|
||||||
)
|
val startTime: Int,
|
||||||
|
val endTime: Int,
|
||||||
@Serializable
|
val ageValidation: Boolean,
|
||||||
data class ApiData(
|
val youtube: String? = null,
|
||||||
val players: List<ApiPlayer>,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ApiResponse(
|
|
||||||
val data: String,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun List<Video>.sort(): List<Video> {
|
override fun List<Video>.sort(): List<Video> {
|
||||||
val quality = preferences.getString("preferred_quality", "1080")!!
|
val quality = preferences.getString("preferred_quality", "1080")!!
|
||||||
val server = preferences.getString("preferred_server", "cda.pl")!!
|
|
||||||
|
|
||||||
return this.sortedWith(
|
return this.sortedWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ it.quality.contains(quality) },
|
{ it.quality.contains(quality) },
|
||||||
{ it.quality.contains(server, true) },
|
|
||||||
),
|
),
|
||||||
).reversed()
|
).reversed()
|
||||||
}
|
}
|
||||||
|
@ -290,23 +207,7 @@ class OgladajAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
preferences.edit().putString(key, entry).commit()
|
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(videoQualityPref)
|
||||||
screen.addPreference(videoServerPref)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue