feat(multisrc/sr): New source: AnimeBalkan (#2632)
This commit is contained in:
parent
3c08ce6c2f
commit
a70b066a82
@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation(project(":lib-okru-extractor"))
|
||||
implementation(project(":lib-googledrive-extractor"))
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,65 @@
|
||||
package eu.kanade.tachiyomi.animeextension.sr.animebalkan
|
||||
|
||||
import eu.kanade.tachiyomi.animeextension.sr.animebalkan.extractors.MailRuExtractor
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.lib.googledriveextractor.GoogleDriveExtractor
|
||||
import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor
|
||||
import eu.kanade.tachiyomi.multisrc.animestream.AnimeStream
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import org.jsoup.nodes.Element
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class AnimeBalkan : AnimeStream(
|
||||
"sr",
|
||||
"AnimeBalkan",
|
||||
"https://animebalkan.org",
|
||||
) {
|
||||
override val animeListUrl = "$baseUrl/animesaprevodom"
|
||||
|
||||
override val dateFormatter by lazy {
|
||||
SimpleDateFormat("MMMM d, yyyy", Locale("bs")) // YES, Bosnian
|
||||
}
|
||||
|
||||
// ============================ Video Links =============================
|
||||
override fun getHosterUrl(element: Element): String {
|
||||
if (element.text().contains("Server AB")) {
|
||||
return element.attr("value")
|
||||
}
|
||||
|
||||
return super.getHosterUrl(element)
|
||||
}
|
||||
|
||||
private val gdriveExtractor by lazy { GoogleDriveExtractor(client, headers) }
|
||||
private val mailruExtractor by lazy { MailRuExtractor(client, headers) }
|
||||
private val okruExtractor by lazy { OkruExtractor(client) }
|
||||
|
||||
override fun getVideoList(url: String, name: String): List<Video> {
|
||||
return when {
|
||||
"Server OK" in name || "ok.ru" in url -> okruExtractor.videosFromUrl(url)
|
||||
"Server Ru" in name || "mail.ru" in url -> mailruExtractor.videosFromUrl(url)
|
||||
"Server GD" in name || "google.com" in url -> {
|
||||
// We need to do that bc the googledrive extractor is garbage.
|
||||
val newUrl = when {
|
||||
url.contains("uc?id=") -> url
|
||||
else -> {
|
||||
val id = url.substringAfter("/d/").substringBefore("/")
|
||||
"https://drive.google.com/uc?id=$id"
|
||||
}
|
||||
}
|
||||
gdriveExtractor.videosFromUrl(newUrl)
|
||||
}
|
||||
"Server AB" in name && baseUrl in url -> {
|
||||
val doc = client.newCall(GET(url)).execute().use { it.asJsoup() }
|
||||
val videoUrl = doc.selectFirst("source")?.attr("src")
|
||||
?: return emptyList()
|
||||
listOf(Video(videoUrl, "Server AB - Default", videoUrl))
|
||||
}
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
override val prefQualityValues = arrayOf("1080p", "720p", "480p", "360p", "240p")
|
||||
override val prefQualityEntries = prefQualityValues
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package eu.kanade.tachiyomi.animeextension.sr.animebalkan.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
class MailRuExtractor(private val client: OkHttpClient, private val headers: Headers) {
|
||||
private val json: Json by injectLazy()
|
||||
private val urlRegex by lazy { "^//".toRegex() }
|
||||
|
||||
fun videosFromUrl(url: String): List<Video> {
|
||||
val document = client.newCall(GET(url, headers)).execute()
|
||||
.use { it.asJsoup() }
|
||||
|
||||
val metaUrl = document.selectFirst("script:containsData(metadataUrl)")
|
||||
?.data()
|
||||
?.run {
|
||||
substringAfter("metadataUrl\":\"")
|
||||
.substringBefore("\"")
|
||||
.replace(urlRegex, "https://") // Fix URLs
|
||||
} ?: return emptyList()
|
||||
|
||||
val metaHeaders = headers.newBuilder()
|
||||
.set("Referer", url)
|
||||
.set("Origin", "https://${url.toHttpUrl().host}")
|
||||
.build()
|
||||
|
||||
val metaResponse = client.newCall(GET(metaUrl, metaHeaders)).execute()
|
||||
|
||||
val metaJson = json.decodeFromString<MetaResponse>(
|
||||
metaResponse.use { it.body.string() },
|
||||
)
|
||||
|
||||
val videoKey = metaResponse.headers.firstOrNull {
|
||||
it.first.equals("set-cookie", true) && it.second.startsWith("video_key", true)
|
||||
}?.second?.substringBefore(";") ?: ""
|
||||
|
||||
val videoHeaders = metaHeaders.newBuilder()
|
||||
.set("Cookie", videoKey)
|
||||
.build()
|
||||
|
||||
return metaJson.videos.map {
|
||||
val videoUrl = it.url
|
||||
.replace(urlRegex, "https://")
|
||||
.replace(".mp4", ".mp4/stream.mpd")
|
||||
|
||||
Video(videoUrl, "Mail.ru ${it.key}", videoUrl, videoHeaders)
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class MetaResponse(val videos: List<VideoObject>)
|
||||
|
||||
@Serializable
|
||||
data class VideoObject(val url: String, val key: String)
|
||||
}
|
@ -11,6 +11,7 @@ class AnimeStreamGenerator : ThemeSourceGenerator {
|
||||
override val baseVersionCode = 2
|
||||
|
||||
override val sources = listOf(
|
||||
SingleLang("AnimeBalkan", "https://animebalkan.org", "sr", isNsfw = false),
|
||||
SingleLang("AnimeIndo", "https://animeindo.quest", "id", isNsfw = false, overrideVersionCode = 6),
|
||||
SingleLang("AnimeKhor", "https://animekhor.xyz", "en", isNsfw = false, overrideVersionCode = 2),
|
||||
SingleLang("Animenosub", "https://animenosub.com", "en", isNsfw = true, overrideVersionCode = 3),
|
||||
|
Loading…
x
Reference in New Issue
Block a user