feat(multisrc): New theme: AnimeStream (#1653)
@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest />
|
@ -1,18 +0,0 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
|
||||
ext {
|
||||
extName = 'AnimeXin'
|
||||
pkgNameSuffix = 'all.animexin'
|
||||
extClass = '.AnimeXin'
|
||||
extVersionCode = 4
|
||||
libVersion = '13'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(':lib-okru-extractor'))
|
||||
implementation "dev.datlag.jsunpacker:jsunpacker:1.0.1"
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
Before Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 164 KiB |
@ -1,339 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Base64
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.DailymotionExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.DoodExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.FembedExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.GdrivePlayerExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.StreamSBExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.VidstreamingExtractor
|
||||
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.YouTubeExtractor
|
||||
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.lib.okruextractor.OkruExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
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 okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
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 java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class AnimeXin : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
|
||||
override val name = "AnimeXin"
|
||||
|
||||
override val baseUrl by lazy { preferences.getString("preferred_domain", "https://animexin.vip")!! }
|
||||
|
||||
override val lang = "all"
|
||||
|
||||
override val id = 4620219025406449669
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
override val client: OkHttpClient = network.cloudflareClient
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DATE_FORMATTER by lazy {
|
||||
SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Popular ===============================
|
||||
|
||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/")
|
||||
|
||||
override fun popularAnimeSelector(): String = "div.wpop-weekly > ul > li"
|
||||
|
||||
override fun popularAnimeNextPageSelector(): String? = null
|
||||
|
||||
override fun popularAnimeFromElement(element: Element): SAnime {
|
||||
return SAnime.create().apply {
|
||||
setUrlWithoutDomain(element.selectFirst("a.series")!!.attr("href").toHttpUrl().encodedPath)
|
||||
thumbnail_url = element.selectFirst("img")!!.attr("src").substringBefore("?resize")
|
||||
title = element.selectFirst("a.series:not(:has(img))")!!.text()
|
||||
}
|
||||
}
|
||||
|
||||
// =============================== Latest ===============================
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/anime/?page=$page&status=&type=&order=update")
|
||||
|
||||
override fun latestUpdatesSelector(): String = searchAnimeSelector()
|
||||
|
||||
override fun latestUpdatesNextPageSelector(): String = searchAnimeNextPageSelector()
|
||||
|
||||
override fun latestUpdatesFromElement(element: Element): SAnime = searchAnimeFromElement(element)
|
||||
|
||||
// =============================== Search ===============================
|
||||
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = throw Exception("Not used")
|
||||
|
||||
override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage> {
|
||||
val params = AnimeXinFilters.getSearchParameters(filters)
|
||||
return client.newCall(searchAnimeRequest(page, query, params))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
searchAnimeParse(response)
|
||||
}
|
||||
}
|
||||
|
||||
private fun searchAnimeRequest(page: Int, query: String, filters: AnimeXinFilters.FilterSearchParams): Request {
|
||||
return if (query.isNotEmpty()) {
|
||||
GET("$baseUrl/page/$page/?s=$query")
|
||||
} else {
|
||||
val multiChoose = mutableListOf<String>()
|
||||
if (filters.genres.isNotEmpty()) multiChoose.add(filters.genres)
|
||||
if (filters.SEASONS.isNotEmpty()) multiChoose.add(filters.SEASONS)
|
||||
if (filters.studios.isNotEmpty()) multiChoose.add(filters.studios)
|
||||
val multiString = if (multiChoose.isEmpty()) "" else multiChoose.joinToString("&") + "&"
|
||||
GET("$baseUrl/anime/?page=$page&${multiString}status=${filters.status}&type=${filters.type}&sub=${filters.sub}&order=${filters.order}")
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchAnimeSelector(): String = "div.listupd > article"
|
||||
|
||||
override fun searchAnimeNextPageSelector(): String = "div.hpage > a:contains(Next)"
|
||||
|
||||
override fun searchAnimeFromElement(element: Element): SAnime {
|
||||
return SAnime.create().apply {
|
||||
setUrlWithoutDomain(element.selectFirst("a")!!.attr("href").toHttpUrl().encodedPath)
|
||||
thumbnail_url = element.selectFirst("img")!!.attr("src").substringBefore("?resize")
|
||||
title = element.selectFirst("div.tt")!!.text()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFilterList(): AnimeFilterList = AnimeXinFilters.FILTER_LIST
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
|
||||
override fun animeDetailsParse(document: Document): SAnime {
|
||||
return SAnime.create().apply {
|
||||
title = document.selectFirst("h1.entry-title")!!.text()
|
||||
thumbnail_url = document.selectFirst("div.thumb > img")!!.attr("src").substringBefore("?resize")
|
||||
status = SAnime.COMPLETED
|
||||
description = document.select("div[itemprop=description] p")?.let {
|
||||
it.joinToString("\n\n") { t -> t.text() } +
|
||||
"\n\n" +
|
||||
document.select("div.info-content > div > span").joinToString("\n") { info ->
|
||||
info.text().replace(":", ": ")
|
||||
}
|
||||
} ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Episodes ==============================
|
||||
|
||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||
val document = response.asJsoup()
|
||||
|
||||
return document.select("div.eplister > ul > li").map { episodeElement ->
|
||||
val numberText = episodeElement.selectFirst("div.epl-num")!!.text()
|
||||
val numberString = numberText.substringBefore(" ")
|
||||
val episodeNumber = if (numberText.contains("part 2", true)) {
|
||||
numberString.toFloatOrNull()?.plus(0.5F) ?: 0F
|
||||
} else {
|
||||
numberString.toFloatOrNull() ?: 0F
|
||||
}
|
||||
|
||||
SEpisode.create().apply {
|
||||
episode_number = episodeNumber
|
||||
name = numberText
|
||||
date_upload = parseDate(episodeElement.selectFirst("div.epl-date")?.text() ?: "")
|
||||
setUrlWithoutDomain(episodeElement.selectFirst("a")!!.attr("href").toHttpUrl().encodedPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun episodeListSelector(): String = throw Exception("Not Used")
|
||||
|
||||
override fun episodeFromElement(element: Element): SEpisode = throw Exception("Not Used")
|
||||
|
||||
// ============================ Video Links =============================
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val document = response.asJsoup()
|
||||
val videoList = mutableListOf<Video>()
|
||||
|
||||
videoList.addAll(
|
||||
document.select("select.mirror > option[value~=.]").parallelMap { source ->
|
||||
runCatching {
|
||||
var decoded = Jsoup.parse(
|
||||
String(Base64.decode(source.attr("value"), Base64.DEFAULT)),
|
||||
).select("iframe[src~=.]").attr("src")
|
||||
if (!decoded.startsWith("http")) decoded = "https:$decoded"
|
||||
val prefix = "${source.text()} - "
|
||||
|
||||
when {
|
||||
decoded.contains("ok.ru") -> {
|
||||
OkruExtractor(client).videosFromUrl(decoded, prefix = prefix)
|
||||
}
|
||||
decoded.contains("sbhight") || decoded.contains("sbrity") || decoded.contains("sbembed.com") || decoded.contains("sbembed1.com") || decoded.contains("sbplay.org") ||
|
||||
decoded.contains("sbvideo.net") || decoded.contains("streamsb.net") || decoded.contains("sbplay.one") ||
|
||||
decoded.contains("cloudemb.com") || decoded.contains("playersb.com") || decoded.contains("tubesb.com") ||
|
||||
decoded.contains("sbplay1.com") || decoded.contains("embedsb.com") || decoded.contains("watchsb.com") ||
|
||||
decoded.contains("sbplay2.com") || decoded.contains("japopav.tv") || decoded.contains("viewsb.com") ||
|
||||
decoded.contains("sbfast") || decoded.contains("sbfull.com") || decoded.contains("javplaya.com") ||
|
||||
decoded.contains("ssbstream.net") || decoded.contains("p1ayerjavseen.com") || decoded.contains("sbthe.com") ||
|
||||
decoded.contains("vidmovie.xyz") || decoded.contains("sbspeed.com") || decoded.contains("streamsss.net") ||
|
||||
decoded.contains("sblanh.com") || decoded.contains("tvmshow.com") || decoded.contains("sbanh.com") ||
|
||||
decoded.contains("streamovies.xyz") -> {
|
||||
StreamSBExtractor(client).videosFromUrl(decoded, headers, prefix = prefix)
|
||||
}
|
||||
decoded.contains("dailymotion") -> {
|
||||
DailymotionExtractor(client).videosFromUrl(decoded, prefix = prefix)
|
||||
}
|
||||
decoded.contains("https://dood") -> {
|
||||
DoodExtractor(client).videosFromUrl(decoded, quality = source.text())
|
||||
}
|
||||
decoded.contains("fembed") ||
|
||||
decoded.contains("anime789.com") || decoded.contains("24hd.club") || decoded.contains("fembad.org") ||
|
||||
decoded.contains("vcdn.io") || decoded.contains("sharinglink.club") || decoded.contains("moviemaniac.org") ||
|
||||
decoded.contains("votrefiles.club") || decoded.contains("femoload.xyz") || decoded.contains("albavido.xyz") ||
|
||||
decoded.contains("feurl.com") || decoded.contains("dailyplanet.pw") || decoded.contains("ncdnstm.com") ||
|
||||
decoded.contains("jplayer.net") || decoded.contains("xstreamcdn.com") || decoded.contains("fembed-hd.com") ||
|
||||
decoded.contains("gcloud.live") || decoded.contains("vcdnplay.com") || decoded.contains("superplayxyz.club") ||
|
||||
decoded.contains("vidohd.com") || decoded.contains("vidsource.me") || decoded.contains("cinegrabber.com") ||
|
||||
decoded.contains("votrefile.xyz") || decoded.contains("zidiplay.com") || decoded.contains("ndrama.xyz") ||
|
||||
decoded.contains("fcdn.stream") || decoded.contains("mediashore.org") || decoded.contains("suzihaza.com") ||
|
||||
decoded.contains("there.to") || decoded.contains("femax20.com") || decoded.contains("javstream.top") ||
|
||||
decoded.contains("viplayer.cc") || decoded.contains("sexhd.co") || decoded.contains("fembed.net") ||
|
||||
decoded.contains("mrdhan.com") || decoded.contains("votrefilms.xyz") || // decoded.contains("") ||
|
||||
decoded.contains("embedsito.com") || decoded.contains("dutrag.com") || // decoded.contains("") ||
|
||||
decoded.contains("youvideos.ru") || decoded.contains("streamm4u.club") || // decoded.contains("") ||
|
||||
decoded.contains("moviepl.xyz") || decoded.contains("asianclub.tv") || // decoded.contains("") ||
|
||||
decoded.contains("vidcloud.fun") || decoded.contains("fplayer.info") || // decoded.contains("") ||
|
||||
decoded.contains("diasfem.com") || decoded.contains("javpoll.com") || decoded.contains("reeoov.tube") ||
|
||||
decoded.contains("suzihaza.com") || decoded.contains("ezsubz.com") || decoded.contains("vidsrc.xyz") ||
|
||||
decoded.contains("diampokusy.com") || decoded.contains("diampokusy.com") || decoded.contains("i18n.pw") ||
|
||||
decoded.contains("vanfem.com") || decoded.contains("fembed9hd.com") || decoded.contains("votrefilms.xyz") || decoded.contains("watchjavnow.xyz")
|
||||
-> {
|
||||
val newUrl = decoded.replace("https://www.fembed.com", "https://vanfem.com")
|
||||
FembedExtractor(client).videosFromUrl(newUrl, prefix = prefix)
|
||||
}
|
||||
decoded.contains("gdriveplayer") -> {
|
||||
GdrivePlayerExtractor(client).videosFromUrl(decoded, name = source.text())
|
||||
}
|
||||
decoded.contains("youtube.com") -> {
|
||||
YouTubeExtractor(client).videosFromUrl(decoded, prefix = prefix)
|
||||
}
|
||||
decoded.contains("vidstreaming") -> {
|
||||
VidstreamingExtractor(client).videosFromUrl(decoded, prefix = prefix)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}.getOrNull()
|
||||
}.filterNotNull().flatten(),
|
||||
)
|
||||
|
||||
return videoList.sort()
|
||||
}
|
||||
|
||||
override fun videoFromElement(element: Element): Video = throw Exception("Not Used")
|
||||
|
||||
override fun videoListSelector(): String = throw Exception("Not Used")
|
||||
|
||||
override fun videoUrlParse(document: Document): String = throw Exception("Not Used")
|
||||
|
||||
// ============================= Utilities ==============================
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val quality = preferences.getString("preferred_quality", "1080")!!
|
||||
val language = preferences.getString("preferred_language", "All Sub")!!
|
||||
|
||||
return this.sortedWith(
|
||||
compareBy(
|
||||
{ it.quality.contains(quality) },
|
||||
{ it.quality.contains(language, true) },
|
||||
),
|
||||
).reversed()
|
||||
}
|
||||
|
||||
private fun parseDate(dateStr: String): Long {
|
||||
return runCatching { DATE_FORMATTER.parse(dateStr)?.time }
|
||||
.getOrNull() ?: 0L
|
||||
}
|
||||
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val domainPref = ListPreference(screen.context).apply {
|
||||
key = "preferred_domain"
|
||||
title = "Preferred domain (requires app restart)"
|
||||
entries = arrayOf("animexin.vip")
|
||||
entryValues = arrayOf("https://animexin.vip")
|
||||
setDefaultValue("https://animexin.vip")
|
||||
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()
|
||||
}
|
||||
}
|
||||
val videoQualityPref = ListPreference(screen.context).apply {
|
||||
key = "preferred_quality"
|
||||
title = "Preferred quality"
|
||||
entries = arrayOf("1080p", "720p", "480p", "360p")
|
||||
entryValues = arrayOf("1080", "720", "480", "360")
|
||||
setDefaultValue("1080")
|
||||
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()
|
||||
}
|
||||
}
|
||||
val videoLangPref = ListPreference(screen.context).apply {
|
||||
key = "preferred_language"
|
||||
title = "Preferred Video Language"
|
||||
entries = arrayOf("All Sub", "English", "Spanish", "Arabic", "German", "Indonesia", "Italian", "Polish", "Portuguese", "Thai", "Turkish")
|
||||
entryValues = arrayOf("All Sub", "English", "Spanish", "Arabic", "German", "Indonesia", "Italian", "Polish", "Portuguese", "Thai", "Turkish")
|
||||
setDefaultValue("All Sub")
|
||||
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(domainPref)
|
||||
screen.addPreference(videoQualityPref)
|
||||
screen.addPreference(videoLangPref)
|
||||
}
|
||||
|
||||
// From Dopebox
|
||||
private fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> =
|
||||
runBlocking {
|
||||
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
||||
}
|
||||
}
|
@ -1,226 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
|
||||
object AnimeXinFilters {
|
||||
|
||||
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 CheckBoxFilterList(name: String, values: List<CheckBox>) : AnimeFilter.Group<AnimeFilter.CheckBox>(name, values)
|
||||
|
||||
private class CheckBoxVal(name: String, state: Boolean = false) : AnimeFilter.CheckBox(name, state)
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.asQueryPart(): String {
|
||||
return (this.getFirst<R>() as QueryPartFilter).toQueryPart()
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.getFirst(): R {
|
||||
return this.filterIsInstance<R>().first()
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.parseCheckbox(
|
||||
options: Array<Pair<String, String>>,
|
||||
name: String,
|
||||
): String {
|
||||
return (this.getFirst<R>() as CheckBoxFilterList).state
|
||||
.mapNotNull { checkbox ->
|
||||
if (checkbox.state) {
|
||||
options.find { it.first == checkbox.name }!!.second
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}.joinToString("&$name[]=").let {
|
||||
if (it.isBlank()) {
|
||||
""
|
||||
} else {
|
||||
"$name[]=$it"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GenresFilter : CheckBoxFilterList(
|
||||
"Genres",
|
||||
AnimeXinFiltersData.GENRES.map { CheckBoxVal(it.first, false) },
|
||||
)
|
||||
|
||||
class SeasonsFilter : CheckBoxFilterList(
|
||||
"Seasons",
|
||||
AnimeXinFiltersData.SEASONS.map { CheckBoxVal(it.first, false) },
|
||||
)
|
||||
|
||||
class StudiosFilter : CheckBoxFilterList(
|
||||
"Studios",
|
||||
AnimeXinFiltersData.STUDIOS.map { CheckBoxVal(it.first, false) },
|
||||
)
|
||||
|
||||
class StatusFilter : QueryPartFilter("Status", AnimeXinFiltersData.STATUS)
|
||||
class TypeFilter : QueryPartFilter("Type", AnimeXinFiltersData.TYPE)
|
||||
class SubFilter : QueryPartFilter("Sub", AnimeXinFiltersData.SUB)
|
||||
class OrderFilter : QueryPartFilter("Order", AnimeXinFiltersData.ORDER)
|
||||
|
||||
val FILTER_LIST = AnimeFilterList(
|
||||
GenresFilter(),
|
||||
SeasonsFilter(),
|
||||
StudiosFilter(),
|
||||
AnimeFilter.Separator(),
|
||||
StatusFilter(),
|
||||
TypeFilter(),
|
||||
SubFilter(),
|
||||
OrderFilter(),
|
||||
)
|
||||
|
||||
data class FilterSearchParams(
|
||||
val genres: String = "",
|
||||
val SEASONS: String = "",
|
||||
val studios: String = "",
|
||||
val status: String = "",
|
||||
val type: String = "",
|
||||
val sub: String = "",
|
||||
val order: String = "",
|
||||
)
|
||||
|
||||
internal fun getSearchParameters(filters: AnimeFilterList): FilterSearchParams {
|
||||
if (filters.isEmpty()) return FilterSearchParams()
|
||||
|
||||
return FilterSearchParams(
|
||||
filters.parseCheckbox<GenresFilter>(AnimeXinFiltersData.GENRES, "genre"),
|
||||
filters.parseCheckbox<SeasonsFilter>(AnimeXinFiltersData.SEASONS, "season"),
|
||||
filters.parseCheckbox<StudiosFilter>(AnimeXinFiltersData.STUDIOS, "studio"),
|
||||
filters.asQueryPart<StatusFilter>(),
|
||||
filters.asQueryPart<TypeFilter>(),
|
||||
filters.asQueryPart<SubFilter>(),
|
||||
filters.asQueryPart<OrderFilter>(),
|
||||
)
|
||||
}
|
||||
|
||||
private object AnimeXinFiltersData {
|
||||
val ALL = Pair("All", "")
|
||||
|
||||
val GENRES = arrayOf(
|
||||
Pair("Action", "action"),
|
||||
Pair("Adventure", "adventure"),
|
||||
Pair("Comedy", "comedy"),
|
||||
Pair("Demon", "demon"),
|
||||
Pair("Drama", "drama"),
|
||||
Pair("Fantasy", "fantasy"),
|
||||
Pair("Game", "game"),
|
||||
Pair("Historical", "historical"),
|
||||
Pair("Isekai", "isekai"),
|
||||
Pair("Magic", "magic"),
|
||||
Pair("Martial Arts", "martial-arts"),
|
||||
Pair("Mystery", "mystery"),
|
||||
Pair("Over Power", "over-power"),
|
||||
Pair("Reincarnation", "reincarnation"),
|
||||
Pair("Romance", "romance"),
|
||||
Pair("School", "school"),
|
||||
Pair("Sci-fi", "sci-fi"),
|
||||
Pair("Supernatural", "supernatural"),
|
||||
Pair("War", "war"),
|
||||
)
|
||||
|
||||
val SEASONS = arrayOf(
|
||||
Pair("4", "4"),
|
||||
Pair("OVA", "ova"),
|
||||
Pair("Season 1", "season-1"),
|
||||
Pair("Season 2", "season-2"),
|
||||
Pair("Season 3", "season-3"),
|
||||
Pair("Season 4", "season-4"),
|
||||
Pair("Season 5", "season-5"),
|
||||
Pair("Season 7", "season-7"),
|
||||
Pair("Season 8", "season-8"),
|
||||
Pair("season1", "season1"),
|
||||
Pair("Winter 2023", "winter-2023"),
|
||||
)
|
||||
|
||||
val STUDIOS = arrayOf(
|
||||
Pair("2:10 Animatión", "210-animation"),
|
||||
Pair("ASK Animation Studio", "ask-animation-studio"),
|
||||
Pair("Axis Studios", "axis-studios"),
|
||||
Pair("Azure Sea Studios", "azure-sea-studios"),
|
||||
Pair("B.C May Pictures", "b-c-may-pictures"),
|
||||
Pair("B.CMAY PICTURES", "b-cmay-pictures"),
|
||||
Pair("BigFireBird Animation", "bigfirebird-animation"),
|
||||
Pair("Bili Bili", "bili-bili"),
|
||||
Pair("Bilibili", "bilibili"),
|
||||
Pair("Build Dream", "build-dream"),
|
||||
Pair("BYMENT", "byment"),
|
||||
Pair("CG Year", "cg-year"),
|
||||
Pair("CHOSEN", "chosen"),
|
||||
Pair("Cloud Art", "cloud-art"),
|
||||
Pair("Colored Pencil Animation", "colored-pencil-animation"),
|
||||
Pair("D.ROCK-ART", "d-rock-art"),
|
||||
Pair("Djinn Power", "djinn-power"),
|
||||
Pair("Green Monster Team", "green-monster-team"),
|
||||
Pair("Haoliners Animation", "haoliners-animation"),
|
||||
Pair("He Zhou Culture", "he-zhou-culture"),
|
||||
Pair("L²Studio", "l%c2%b2studio"),
|
||||
Pair("Lingsanwu Animation", "lingsanwu-animation"),
|
||||
Pair("Mili Pictures", "mili-pictures"),
|
||||
Pair("Nice Boat Animation", "nice-boat-animation"),
|
||||
Pair("Original Force", "original-force"),
|
||||
Pair("Pb Animation Co. Ltd.", "pb-animation-co-ltd"),
|
||||
Pair("Qing Xiang", "qing-xiang"),
|
||||
Pair("Ruo Hong Culture", "ruo-hong-culture"),
|
||||
Pair("Samsara Animation Studio", "samsara-animation-studio"),
|
||||
Pair("Shanghai Foch Film Culture Investment", "shanghai-foch-film-culture-investment"),
|
||||
Pair("Shanghai Motion Magic", "shanghai-motion-magic"),
|
||||
Pair("Shenman Entertainment", "shenman-entertainment"),
|
||||
Pair("Soyep", "soyep"),
|
||||
Pair("soyep.cn", "soyep-cn"),
|
||||
Pair("Sparkly Key Animation Studio", "sparkly-key-animation-studio"),
|
||||
Pair("Tencent Penguin Pictures.", "tencent-penguin-pictures"),
|
||||
Pair("Wan Wei Mao Donghua", "wan-wei-mao-donghua"),
|
||||
Pair("Wawayu Animation", "wawayu-animation"),
|
||||
Pair("Wonder Cat Animation", "wonder-cat-animation"),
|
||||
Pair("Xing Yi Kai Chen", "xing-yi-kai-chen"),
|
||||
Pair("Xuan Yuan", "xuan-yuan"),
|
||||
Pair("Year Young Culture", "year-young-culture"),
|
||||
)
|
||||
|
||||
val STATUS = arrayOf(
|
||||
ALL,
|
||||
Pair("Ongoing", "ongoing"),
|
||||
Pair("Completed", "completed"),
|
||||
Pair("Upcoming", "upcoming"),
|
||||
Pair("Hiatus", "hiatus"),
|
||||
)
|
||||
|
||||
val TYPE = arrayOf(
|
||||
ALL,
|
||||
Pair("TV Series", "tv"),
|
||||
Pair("OVA", "ova"),
|
||||
Pair("Movie", "movie"),
|
||||
Pair("Live Action", "live action"),
|
||||
Pair("Special", "special"),
|
||||
Pair("BD", "bd"),
|
||||
Pair("ONA", "ona"),
|
||||
Pair("Music", "music"),
|
||||
)
|
||||
|
||||
val SUB = arrayOf(
|
||||
ALL,
|
||||
Pair("Sub", "sub"),
|
||||
Pair("Dub", "dub"),
|
||||
Pair("RAW", "raw"),
|
||||
)
|
||||
|
||||
val ORDER = arrayOf(
|
||||
Pair("Default", ""),
|
||||
Pair("A-Z", "title"),
|
||||
Pair("Z-A", "titlereverse"),
|
||||
Pair("Latest Update", "update"),
|
||||
Pair("Latest Added", "latest"),
|
||||
Pair("Popular", "popular"),
|
||||
Pair("Rating", "rating"),
|
||||
)
|
||||
}
|
||||
}
|
@ -1,91 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@Serializable
|
||||
data class DailyQuality(
|
||||
val qualities: Auto,
|
||||
val subtitles: Subtitle? = null,
|
||||
) {
|
||||
@Serializable
|
||||
data class Auto(
|
||||
val auto: List<Item>,
|
||||
) {
|
||||
@Serializable
|
||||
data class Item(
|
||||
val type: String,
|
||||
val url: String,
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Subtitle(
|
||||
val data: Map<String, SubtitleObject>,
|
||||
) {
|
||||
@Serializable
|
||||
data class SubtitleObject(
|
||||
val label: String,
|
||||
val urls: List<String>,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class DailymotionExtractor(private val client: OkHttpClient) {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
fun videosFromUrl(url: String, prefix: String): List<Video> {
|
||||
val videoList = mutableListOf<Video>()
|
||||
val htmlString = client.newCall(GET(url)).execute().body.string()
|
||||
|
||||
val internalData = htmlString.substringAfter("\"dmInternalData\":").substringBefore("</script>")
|
||||
val ts = internalData.substringAfter("\"ts\":").substringBefore(",")
|
||||
val v1st = internalData.substringAfter("\"v1st\":\"").substringBefore("\",")
|
||||
|
||||
val jsonUrl = "https://www.dailymotion.com/player/metadata/video/${url.toHttpUrl().encodedPath}?locale=en-US&dmV1st=$v1st&dmTs=$ts&is_native_app=0"
|
||||
val parsed = json.decodeFromString<DailyQuality>(
|
||||
client.newCall(GET(jsonUrl))
|
||||
.execute().body.string(),
|
||||
)
|
||||
|
||||
val subtitleList = mutableListOf<Track>()
|
||||
if (parsed.subtitles != null) {
|
||||
try {
|
||||
subtitleList.addAll(
|
||||
parsed.subtitles.data.map { k ->
|
||||
Track(
|
||||
k.value.urls.first(),
|
||||
k.value.label,
|
||||
)
|
||||
},
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
}
|
||||
|
||||
val masterUrl = parsed.qualities.auto.first().url
|
||||
|
||||
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body.string()
|
||||
|
||||
val separator = "#EXT-X-STREAM-INF"
|
||||
masterPlaylist.substringAfter(separator).split(separator).map {
|
||||
val quality = it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",NAME") + "p"
|
||||
var videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
|
||||
try {
|
||||
videoList.add(Video(videoUrl, prefix + quality, videoUrl, subtitleTracks = subtitleList))
|
||||
} catch (a: Exception) {
|
||||
videoList.add(Video(videoUrl, prefix + quality, videoUrl))
|
||||
}
|
||||
}
|
||||
|
||||
return videoList
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class DoodExtractor(private val client: OkHttpClient) {
|
||||
|
||||
fun videoFromUrl(
|
||||
url: String,
|
||||
quality: String? = null,
|
||||
redirect: Boolean = true,
|
||||
): Video? {
|
||||
val newQuality = quality ?: "Doodstream" + if (redirect) " mirror" else ""
|
||||
|
||||
return try {
|
||||
val response = client.newCall(GET(url)).execute()
|
||||
val newUrl = if (redirect) response.request.url.toString() else url
|
||||
|
||||
val doodTld = newUrl.substringAfter("https://dood.").substringBefore("/")
|
||||
val content = response.body.string()
|
||||
|
||||
val subtitleList = mutableListOf<Track>()
|
||||
val subtitleRegex = """src:'//(srt[^']*?)',\s*label:'([^']*?)'""".toRegex()
|
||||
try {
|
||||
subtitleList.addAll(
|
||||
subtitleRegex.findAll(content).map {
|
||||
Track(
|
||||
"https://" + it.groupValues[1],
|
||||
it.groupValues[2],
|
||||
)
|
||||
},
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
|
||||
if (!content.contains("'/pass_md5/")) return null
|
||||
val md5 = content.substringAfter("'/pass_md5/").substringBefore("',")
|
||||
val token = md5.substringAfterLast("/")
|
||||
val randomString = getRandomString()
|
||||
val expiry = System.currentTimeMillis()
|
||||
val videoUrlStart = client.newCall(
|
||||
GET(
|
||||
"https://dood.$doodTld/pass_md5/$md5",
|
||||
Headers.headersOf("referer", newUrl),
|
||||
),
|
||||
).execute().body.string()
|
||||
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
||||
try {
|
||||
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodTld), subtitleTracks = subtitleList)
|
||||
} catch (a: Exception) {
|
||||
Video(newUrl, newQuality, videoUrl, headers = doodHeaders(doodTld))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun videosFromUrl(
|
||||
url: String,
|
||||
quality: String? = null,
|
||||
redirect: Boolean = true,
|
||||
): List<Video> {
|
||||
val video = videoFromUrl(url, quality, redirect)
|
||||
return video?.let { listOf(it) } ?: emptyList<Video>()
|
||||
}
|
||||
|
||||
private fun getRandomString(length: Int = 10): String {
|
||||
val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9')
|
||||
return (1..length)
|
||||
.map { allowedChars.random() }
|
||||
.joinToString("")
|
||||
}
|
||||
|
||||
private fun doodHeaders(tld: String) = Headers.Builder().apply {
|
||||
add("User-Agent", "Aniyomi")
|
||||
add("Referer", "https://dood.$tld/")
|
||||
}.build()
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
@Serializable
|
||||
data class FembedResponse(
|
||||
val success: Boolean,
|
||||
val data: List<FembedVideo> = emptyList(),
|
||||
val captions: List<Caption> = emptyList(),
|
||||
) {
|
||||
@Serializable
|
||||
data class FembedVideo(
|
||||
val file: String,
|
||||
val label: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Caption(
|
||||
val id: String,
|
||||
val hash: String,
|
||||
val language: String,
|
||||
val extension: String,
|
||||
)
|
||||
}
|
||||
|
||||
class FembedExtractor(private val client: OkHttpClient) {
|
||||
fun videosFromUrl(url: String, prefix: String = "", redirect: Boolean = false): List<Video> {
|
||||
val videoApi = if (redirect) {
|
||||
(
|
||||
runCatching {
|
||||
client.newCall(GET(url)).execute().request.url.toString()
|
||||
.replace("/v/", "/api/source/")
|
||||
}.getOrNull() ?: return emptyList<Video>()
|
||||
)
|
||||
} else {
|
||||
url.replace("/v/", "/api/source/")
|
||||
}
|
||||
val body = runCatching {
|
||||
client.newCall(POST(videoApi)).execute().body.string()
|
||||
}.getOrNull() ?: return emptyList()
|
||||
|
||||
val userId = client.newCall(GET(url)).execute().asJsoup()
|
||||
.selectFirst("script:containsData(USER_ID)")!!
|
||||
.data()
|
||||
.substringAfter("USER_ID")
|
||||
.substringAfter("'")
|
||||
.substringBefore("'")
|
||||
|
||||
val jsonResponse = try { Json { ignoreUnknownKeys = true }.decodeFromString<FembedResponse>(body) } catch (e: Exception) { FembedResponse(false, emptyList(), emptyList()) }
|
||||
|
||||
return if (jsonResponse.success) {
|
||||
val subtitleList = mutableListOf<Track>()
|
||||
try {
|
||||
subtitleList.addAll(
|
||||
jsonResponse.captions.map {
|
||||
Track(
|
||||
"https://${url.toHttpUrl().host}/asset/userdata/$userId/caption/${it.hash}/${it.id}.${it.extension}",
|
||||
it.language,
|
||||
)
|
||||
},
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
|
||||
jsonResponse.data.map {
|
||||
val quality = ("Fembed:${it.label}").let {
|
||||
if (prefix.isNotBlank()) {
|
||||
"$prefix $it"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
try {
|
||||
Video(it.file, quality, it.file, subtitleTracks = subtitleList)
|
||||
} catch (a: Exception) {
|
||||
Video(it.file, quality, it.file)
|
||||
}
|
||||
}
|
||||
} else { emptyList<Video>() }
|
||||
}
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import android.util.Base64
|
||||
import dev.datlag.jsunpacker.JsUnpacker
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import org.jsoup.Jsoup
|
||||
import java.security.DigestException
|
||||
import java.security.MessageDigest
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
class GdrivePlayerExtractor(private val client: OkHttpClient) {
|
||||
|
||||
fun videosFromUrl(url: String, name: String): List<Video> {
|
||||
val headers = Headers.headersOf(
|
||||
"Accept",
|
||||
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
||||
"Host",
|
||||
"gdriveplayer.to",
|
||||
"Referer",
|
||||
"https://animexin.vip/",
|
||||
"User-Agent",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0",
|
||||
)
|
||||
|
||||
val body = client.newCall(GET(url.replace(".me", ".to"), headers = headers)).execute()
|
||||
.body.string()
|
||||
|
||||
val subtitleUrl = Jsoup.parse(body).selectFirst("div:contains(\\.srt)")
|
||||
val subtitleList = mutableListOf<Track>()
|
||||
if (subtitleUrl != null) {
|
||||
try {
|
||||
subtitleList.add(
|
||||
Track(
|
||||
"https://gdriveplayer.to/?subtitle=" + subtitleUrl.text(),
|
||||
"Subtitles",
|
||||
),
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
}
|
||||
|
||||
val eval = JsUnpacker.unpackAndCombine(body)!!.replace("\\", "")
|
||||
val json = Json.decodeFromString<JsonObject>(REGEX_DATAJSON.getFirst(eval))
|
||||
val sojson = REGEX_SOJSON.getFirst(eval)
|
||||
.split(Regex("\\D+"))
|
||||
.joinToString("") {
|
||||
Char(it.toInt()).toString()
|
||||
}
|
||||
val password = REGEX_PASSWORD.getFirst(sojson).toByteArray()
|
||||
val decrypted = decryptAES(password, json)!!
|
||||
val secondEval = JsUnpacker.unpackAndCombine(decrypted)!!.replace("\\", "")
|
||||
return REGEX_VIDEOURL.findAll(secondEval)
|
||||
.distinctBy { it.groupValues[2] } // remove duplicates by quality
|
||||
.map {
|
||||
val qualityStr = it.groupValues[2]
|
||||
val quality = "$PLAYER_NAME ${qualityStr}p - $name"
|
||||
val videoUrl = "https:" + it.groupValues[1] + "&res=$qualityStr"
|
||||
try {
|
||||
Video(videoUrl, quality, videoUrl, subtitleTracks = subtitleList)
|
||||
} catch (a: Exception) {
|
||||
Video(videoUrl, quality, videoUrl)
|
||||
}
|
||||
}.toList()
|
||||
}
|
||||
|
||||
private fun decryptAES(password: ByteArray, json: JsonObject): String? {
|
||||
val salt = json["s"]!!.jsonPrimitive.content
|
||||
val encodedCiphetext = json["ct"]!!.jsonPrimitive.content
|
||||
val ciphertext = Base64.decode(encodedCiphetext, Base64.DEFAULT)
|
||||
val (key, iv) = generateKeyAndIv(password, salt.decodeHex())
|
||||
?: return null
|
||||
val keySpec = SecretKeySpec(key, "AES")
|
||||
val ivSpec = IvParameterSpec(iv)
|
||||
val cipher = Cipher.getInstance("AES/CBC/NoPadding")
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec)
|
||||
val decryptedData = String(cipher.doFinal(ciphertext))
|
||||
return decryptedData
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/41434590/8166854
|
||||
private fun generateKeyAndIv(
|
||||
password: ByteArray,
|
||||
salt: ByteArray,
|
||||
hashAlgorithm: String = "MD5",
|
||||
keyLength: Int = 32,
|
||||
ivLength: Int = 16,
|
||||
iterations: Int = 1,
|
||||
): List<ByteArray>? {
|
||||
val md = MessageDigest.getInstance(hashAlgorithm)
|
||||
val digestLength = md.getDigestLength()
|
||||
val targetKeySize = keyLength + ivLength
|
||||
val requiredLength = (targetKeySize + digestLength - 1) / digestLength * digestLength
|
||||
var generatedData = ByteArray(requiredLength)
|
||||
var generatedLength = 0
|
||||
|
||||
try {
|
||||
md.reset()
|
||||
|
||||
while (generatedLength < targetKeySize) {
|
||||
if (generatedLength > 0) {
|
||||
md.update(
|
||||
generatedData,
|
||||
generatedLength - digestLength,
|
||||
digestLength,
|
||||
)
|
||||
}
|
||||
|
||||
md.update(password)
|
||||
md.update(salt, 0, 8)
|
||||
md.digest(generatedData, generatedLength, digestLength)
|
||||
|
||||
for (i in 1 until iterations) {
|
||||
md.update(generatedData, generatedLength, digestLength)
|
||||
md.digest(generatedData, generatedLength, digestLength)
|
||||
}
|
||||
|
||||
generatedLength += digestLength
|
||||
}
|
||||
val result = listOf(
|
||||
generatedData.copyOfRange(0, keyLength),
|
||||
generatedData.copyOfRange(keyLength, targetKeySize),
|
||||
)
|
||||
return result
|
||||
} catch (e: DigestException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun Regex.getFirst(item: String): String {
|
||||
return find(item)?.groups?.elementAt(1)?.value!!
|
||||
}
|
||||
|
||||
// Stolen from AnimixPlay(EN) / GogoCdnExtractor
|
||||
private fun String.decodeHex(): ByteArray {
|
||||
check(length % 2 == 0) { "Must have an even length" }
|
||||
return chunked(2)
|
||||
.map { it.toInt(16).toByte() }
|
||||
.toByteArray()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val PLAYER_NAME = "GDRIVE"
|
||||
|
||||
private val REGEX_DATAJSON = Regex("data='(\\S+?)'")
|
||||
private val REGEX_PASSWORD = Regex("var pass = \"(\\S+?)\"")
|
||||
private val REGEX_SOJSON = Regex("null,['|\"](\\w+)['|\"]")
|
||||
private val REGEX_VIDEOURL = Regex("file\":\"(\\S+?)\".*?res=(\\d+)")
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class StreamSBExtractor(private val client: OkHttpClient) {
|
||||
|
||||
protected fun bytesToHex(bytes: ByteArray): String {
|
||||
val hexArray = "0123456789ABCDEF".toCharArray()
|
||||
val hexChars = CharArray(bytes.size * 2)
|
||||
for (j in bytes.indices) {
|
||||
val v = bytes[j].toInt() and 0xFF
|
||||
|
||||
hexChars[j * 2] = hexArray[v ushr 4]
|
||||
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
|
||||
}
|
||||
return String(hexChars)
|
||||
}
|
||||
|
||||
// animension, asianload and dramacool uses "common = false"
|
||||
private fun fixUrl(url: String, common: Boolean): String {
|
||||
val sbUrl = url.substringBefore("/e/")
|
||||
val id = url.substringAfter("/e/")
|
||||
.substringBefore("?")
|
||||
.substringBefore(".html")
|
||||
return if (common) {
|
||||
val hexBytes = bytesToHex(id.toByteArray())
|
||||
"$sbUrl/sources50/625a364258615242766475327c7c${hexBytes}7c7c4761574550654f7461566d347c7c73747265616d7362"
|
||||
} else {
|
||||
"$sbUrl/sources50/${bytesToHex("||$id||||streamsb".toByteArray())}/"
|
||||
}
|
||||
}
|
||||
|
||||
fun videosFromUrl(url: String, headers: Headers, prefix: String = "", suffix: String = "", common: Boolean = true): List<Video> {
|
||||
val newHeaders = headers.newBuilder()
|
||||
.set("referer", url)
|
||||
.set("watchsb", "sbstream")
|
||||
.set("authority", "embedsb.com")
|
||||
.build()
|
||||
return try {
|
||||
val master = fixUrl(url, common)
|
||||
val json = Json.decodeFromString<JsonObject>(
|
||||
client.newCall(GET(master, newHeaders))
|
||||
.execute().body.string(),
|
||||
)
|
||||
val subtitleList = mutableListOf<Track>()
|
||||
val subsList = json["stream_data"]!!.jsonObject["subs"]
|
||||
if (subsList != null) {
|
||||
try {
|
||||
subtitleList.addAll(
|
||||
subsList.jsonArray.map {
|
||||
Track(
|
||||
it.jsonObject["file"]!!.jsonPrimitive.content,
|
||||
it.jsonObject["label"]!!.jsonPrimitive.content,
|
||||
)
|
||||
},
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
}
|
||||
|
||||
val masterUrl = json["stream_data"]!!.jsonObject["file"].toString().trim('"')
|
||||
val masterPlaylist = client.newCall(GET(masterUrl, newHeaders))
|
||||
.execute()
|
||||
.body.string()
|
||||
val separator = "#EXT-X-STREAM-INF"
|
||||
masterPlaylist.substringAfter(separator).split(separator).map {
|
||||
val resolution = it.substringAfter("RESOLUTION=")
|
||||
.substringBefore("\n")
|
||||
.substringAfter("x")
|
||||
.substringBefore(",") + "p"
|
||||
val quality = ("StreamSB:" + resolution).let {
|
||||
if (prefix.isNotBlank()) {
|
||||
"$prefix $it"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.let {
|
||||
if (suffix.isNotBlank()) {
|
||||
"$it $suffix"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
val videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
try {
|
||||
Video(videoUrl, quality, videoUrl, headers = newHeaders, subtitleTracks = subtitleList)
|
||||
} catch (a: Exception) {
|
||||
Video(videoUrl, quality, videoUrl, headers = newHeaders)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
emptyList<Video>()
|
||||
}
|
||||
}
|
||||
|
||||
fun videosFromDecryptedUrl(realUrl: String, headers: Headers, prefix: String = "", suffix: String = ""): List<Video> {
|
||||
return try {
|
||||
val json = Json.decodeFromString<JsonObject>(client.newCall(GET(realUrl, headers)).execute().body.string())
|
||||
val masterUrl = json["stream_data"]!!.jsonObject["file"].toString().trim('"')
|
||||
val masterPlaylist = client.newCall(GET(masterUrl, headers)).execute().body.string()
|
||||
val separator = "#EXT-X-STREAM-INF"
|
||||
masterPlaylist.substringAfter(separator).split(separator).map {
|
||||
val resolution = it.substringAfter("RESOLUTION=")
|
||||
.substringBefore("\n")
|
||||
.substringAfter("x")
|
||||
.substringBefore(",") + "p"
|
||||
val quality = ("StreamSB:$resolution").let {
|
||||
if (prefix.isNotBlank()) {
|
||||
"$prefix $it"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.let {
|
||||
if (suffix.isNotBlank()) {
|
||||
"$it $suffix"
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
val videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
Video(videoUrl, quality, videoUrl, headers = headers)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import android.util.Base64
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.lang.Exception
|
||||
import java.util.Locale
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
@ExperimentalSerializationApi
|
||||
class VidstreamingExtractor(private val client: OkHttpClient) {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
fun videosFromUrl(serverUrl: String, prefix: String): List<Video> {
|
||||
try {
|
||||
val document = client.newCall(GET(serverUrl)).execute().asJsoup()
|
||||
val iv = document.select("div.wrapper")
|
||||
.attr("class").substringAfter("container-")
|
||||
.filter { it.isDigit() }.toByteArray()
|
||||
val secretKey = document.select("body[class]")
|
||||
.attr("class").substringAfter("container-")
|
||||
.filter { it.isDigit() }.toByteArray()
|
||||
val decryptionKey = document.select("div.videocontent")
|
||||
.attr("class").substringAfter("videocontent-")
|
||||
.filter { it.isDigit() }.toByteArray()
|
||||
val encryptAjaxParams = cryptoHandler(
|
||||
document.select("script[data-value]")
|
||||
.attr("data-value"),
|
||||
iv,
|
||||
secretKey,
|
||||
false,
|
||||
).substringAfter("&")
|
||||
|
||||
val httpUrl = serverUrl.toHttpUrl()
|
||||
val host = "https://" + httpUrl.host + "/"
|
||||
val id = httpUrl.queryParameter("id") ?: throw Exception("error getting id")
|
||||
val encryptedId = cryptoHandler(id, iv, secretKey)
|
||||
val token = httpUrl.queryParameter("token")
|
||||
val qualitySuffix = if (token != null) " (Vid-mp4 - Gogostream)" else " (Vid-mp4 - Vidstreaming)"
|
||||
|
||||
val jsonResponse = client.newCall(
|
||||
GET(
|
||||
"${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id",
|
||||
Headers.headersOf(
|
||||
"X-Requested-With",
|
||||
"XMLHttpRequest",
|
||||
),
|
||||
),
|
||||
).execute().body.string()
|
||||
val data = json.decodeFromString<JsonObject>(jsonResponse)["data"]!!.jsonPrimitive.content
|
||||
val decryptedData = cryptoHandler(data, iv, decryptionKey, false)
|
||||
val videoList = mutableListOf<Video>()
|
||||
val autoList = mutableListOf<Video>()
|
||||
val array = json.decodeFromString<JsonObject>(decryptedData)["source"]!!.jsonArray
|
||||
if (array.size == 1 && array[0].jsonObject["type"]!!.jsonPrimitive.content == "hls") {
|
||||
val fileURL = array[0].jsonObject["file"].toString().trim('"')
|
||||
val masterPlaylist = client.newCall(GET(fileURL)).execute().body.string()
|
||||
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:")
|
||||
.split("#EXT-X-STREAM-INF:").forEach {
|
||||
val quality = it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",").substringBefore("\n") + "p"
|
||||
var videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
if (!videoUrl.startsWith("http")) {
|
||||
videoUrl = fileURL.substringBeforeLast("/") + "/$videoUrl"
|
||||
}
|
||||
videoList.add(Video(videoUrl, prefix + quality + qualitySuffix, videoUrl))
|
||||
}
|
||||
} else {
|
||||
array.forEach {
|
||||
val label = it.jsonObject["label"].toString().lowercase(Locale.ROOT)
|
||||
.trim('"').replace(" ", "")
|
||||
val fileURL = it.jsonObject["file"].toString().trim('"')
|
||||
val videoHeaders = Headers.headersOf("Referer", serverUrl)
|
||||
if (label == "auto") {
|
||||
autoList.add(
|
||||
Video(
|
||||
fileURL,
|
||||
label + qualitySuffix,
|
||||
fileURL,
|
||||
headers = videoHeaders,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
videoList.add(Video(fileURL, label + qualitySuffix, fileURL, headers = videoHeaders))
|
||||
}
|
||||
}
|
||||
}
|
||||
return videoList.sortedByDescending {
|
||||
it.quality.substringBefore(qualitySuffix).substringBefore("p").toIntOrNull() ?: -1
|
||||
} + autoList
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun cryptoHandler(
|
||||
string: String,
|
||||
iv: ByteArray,
|
||||
secretKeyString: ByteArray,
|
||||
encrypt: Boolean = true,
|
||||
): String {
|
||||
val ivParameterSpec = IvParameterSpec(iv)
|
||||
val secretKey = SecretKeySpec(secretKeyString, "AES")
|
||||
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
|
||||
return if (!encrypt) {
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, ivParameterSpec)
|
||||
String(cipher.doFinal(Base64.decode(string, Base64.DEFAULT)))
|
||||
} else {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParameterSpec)
|
||||
Base64.encodeToString(cipher.doFinal(string.toByteArray()), Base64.NO_WRAP)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.animexin.extractors
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import kotlinx.serialization.json.long
|
||||
import okhttp3.Headers
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.CharacterIterator
|
||||
import java.text.StringCharacterIterator
|
||||
|
||||
class YouTubeExtractor(private val client: OkHttpClient) {
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
fun videosFromUrl(url: String, prefix: String): List<Video> {
|
||||
// Ported from https://github.com/dermasmid/scrapetube/blob/master/scrapetube/scrapetube.py
|
||||
// TODO: Make code prettier
|
||||
// GET KEY
|
||||
|
||||
var ytcfgString = ""
|
||||
val videoId = url.substringAfter("/embed/")
|
||||
|
||||
val document = client.newCall(
|
||||
GET(url.replace("/embed/", "/watch?v=")),
|
||||
).execute().asJsoup()
|
||||
|
||||
for (element in document.select("script")) {
|
||||
val scriptData = element.data()
|
||||
if (scriptData.startsWith("(function() {window.ytplayer={};")) {
|
||||
ytcfgString = scriptData
|
||||
}
|
||||
}
|
||||
|
||||
val apiKey = getKey(ytcfgString, "innertubeApiKey")
|
||||
|
||||
val playerUrl = "https://www.youtube.com/youtubei/v1/player?key=$apiKey&prettyPrint=false"
|
||||
|
||||
val body = """
|
||||
{
|
||||
"context":{
|
||||
"client":{
|
||||
"clientName":"ANDROID",
|
||||
"clientVersion":"17.31.35",
|
||||
"androidSdkVersion":30,
|
||||
"userAgent":"com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip",
|
||||
"hl":"en",
|
||||
"timeZone":"UTC",
|
||||
"utcOffsetMinutes":0
|
||||
}
|
||||
},
|
||||
"videoId":"$videoId",
|
||||
"params":"8AEB",
|
||||
"playbackContext":{
|
||||
"contentPlaybackContext":{
|
||||
"html5Preference":"HTML5_PREF_WANTS"
|
||||
}
|
||||
},
|
||||
"contentCheckOk":true,
|
||||
"racyCheckOk":true
|
||||
}
|
||||
""".trimIndent().toRequestBody("application/json".toMediaType())
|
||||
|
||||
val headers = Headers.headersOf(
|
||||
"X-YouTube-Client-Name", "3",
|
||||
"X-YouTube-Client-Version", "17.31.35",
|
||||
"Origin", "https://www.youtube.com",
|
||||
"User-Agent", "com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip",
|
||||
"content-type", "application/json",
|
||||
)
|
||||
|
||||
val postResponse = client.newCall(
|
||||
POST(playerUrl, headers = headers, body = body),
|
||||
).execute()
|
||||
|
||||
val responseObject = json.decodeFromString<JsonObject>(postResponse.body.string())
|
||||
val videoList = mutableListOf<Video>()
|
||||
|
||||
val formats = responseObject["streamingData"]!!
|
||||
.jsonObject["adaptiveFormats"]!!
|
||||
.jsonArray
|
||||
|
||||
val audioTracks = mutableListOf<Track>()
|
||||
val subtitleTracks = mutableListOf<Track>()
|
||||
|
||||
// Get Audio
|
||||
for (format in formats) {
|
||||
if (format.jsonObject["mimeType"]!!.jsonPrimitive.content.startsWith("audio/webm")) {
|
||||
try {
|
||||
audioTracks.add(
|
||||
Track(
|
||||
format.jsonObject["url"]!!.jsonPrimitive.content,
|
||||
format.jsonObject["audioQuality"]!!.jsonPrimitive.content +
|
||||
" (${formatBits(format.jsonObject["averageBitrate"]!!.jsonPrimitive.long)}ps)",
|
||||
),
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
// Get Subtitles
|
||||
if (responseObject.containsKey("captions")) {
|
||||
val captionTracks = responseObject["captions"]!!
|
||||
.jsonObject["playerCaptionsTracklistRenderer"]!!
|
||||
.jsonObject["captionTracks"]!!
|
||||
.jsonArray
|
||||
|
||||
for (caption in captionTracks) {
|
||||
val captionJson = caption.jsonObject
|
||||
try {
|
||||
subtitleTracks.add(
|
||||
Track(
|
||||
// TODO: Would replacing srv3 with vtt work for every video?
|
||||
captionJson["baseUrl"]!!.jsonPrimitive.content.replace("srv3", "vtt"),
|
||||
captionJson["name"]!!.jsonObject["runs"]!!.jsonArray[0].jsonObject["text"]!!.jsonPrimitive.content,
|
||||
),
|
||||
)
|
||||
} catch (a: Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
// List formats
|
||||
for (format in formats) {
|
||||
val mimeType = format.jsonObject["mimeType"]!!.jsonPrimitive.content
|
||||
if (mimeType.startsWith("video/mp4")) {
|
||||
videoList.add(
|
||||
try {
|
||||
Video(
|
||||
format.jsonObject["url"]!!.jsonPrimitive.content,
|
||||
prefix + format.jsonObject["qualityLabel"]!!.jsonPrimitive.content +
|
||||
" (${mimeType.substringAfter("codecs=\"").substringBefore("\"")})",
|
||||
format.jsonObject["url"]!!.jsonPrimitive.content,
|
||||
audioTracks = audioTracks,
|
||||
subtitleTracks = subtitleTracks,
|
||||
)
|
||||
} catch (a: Exception) {
|
||||
Video(
|
||||
format.jsonObject["url"]!!.jsonPrimitive.content,
|
||||
prefix + format.jsonObject["qualityLabel"]!!.jsonPrimitive.content +
|
||||
" (${mimeType.substringAfter("codecs=\"").substringBefore("\"")})",
|
||||
format.jsonObject["url"]!!.jsonPrimitive.content,
|
||||
)
|
||||
},
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return videoList
|
||||
}
|
||||
|
||||
fun getKey(string: String, key: String): String {
|
||||
var pattern = Regex("\"$key\":\"(.*?)\"")
|
||||
return pattern.find(string)?.groupValues?.get(1) ?: ""
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
fun formatBits(bits: Long): String? {
|
||||
var bits = bits
|
||||
if (-1000 < bits && bits < 1000) {
|
||||
return "${bits}b"
|
||||
}
|
||||
val ci: CharacterIterator = StringCharacterIterator("kMGTPE")
|
||||
while (bits <= -999950 || bits >= 999950) {
|
||||
bits /= 1000
|
||||
ci.next()
|
||||
}
|
||||
return java.lang.String.format("%.0f%cb", bits / 1000.0, ci.current())
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".all.lmanime.LMAnimeUrlActivity"
|
||||
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="lmanime.com"
|
||||
android:pathPattern="/..*/"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
@ -1,19 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
}
|
||||
|
||||
ext {
|
||||
extName = 'LMAnime'
|
||||
pkgNameSuffix = 'all.lmanime'
|
||||
extClass = '.LMAnime'
|
||||
extVersionCode = 2
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib-fembed-extractor"))
|
||||
implementation(project(":lib-okru-extractor"))
|
||||
}
|
||||
|
||||
apply from: "$rootDir/common.gradle"
|
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 13 KiB |
@ -1,344 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.lmanime
|
||||
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.util.Base64
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.MultiSelectListPreference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.animeextension.all.lmanime.extractors.DailymotionExtractor
|
||||
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.lib.fembedextractor.FembedExtractor
|
||||
import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
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 okhttp3.Request
|
||||
import okhttp3.Response
|
||||
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 java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class LMAnime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||
|
||||
override val name = "LMAnime"
|
||||
|
||||
override val baseUrl = "https://lmanime.com"
|
||||
|
||||
override val lang = "all"
|
||||
|
||||
override val supportsLatest = true
|
||||
|
||||
private val preferences: SharedPreferences by lazy {
|
||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||
}
|
||||
|
||||
// ============================== Popular ===============================
|
||||
override fun popularAnimeFromElement(element: Element): SAnime {
|
||||
return SAnime.create().apply {
|
||||
val ahref = element.selectFirst("h4 > a.series")!!
|
||||
setUrlWithoutDomain(ahref.attr("href"))
|
||||
title = ahref.text()
|
||||
thumbnail_url = element.selectFirst("img")!!.attr("src")
|
||||
}
|
||||
}
|
||||
|
||||
override fun popularAnimeNextPageSelector() = null
|
||||
|
||||
override fun popularAnimeRequest(page: Int) = GET(baseUrl)
|
||||
|
||||
override fun popularAnimeSelector() = "div.serieslist.wpop-alltime li"
|
||||
|
||||
// ============================== Episodes ==============================
|
||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||
val doc = getRealDoc(response.asJsoup())
|
||||
return doc.select(episodeListSelector()).map(::episodeFromElement)
|
||||
}
|
||||
|
||||
override fun episodeFromElement(element: Element): SEpisode {
|
||||
return SEpisode.create().apply {
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
element.selectFirst("div.epl-title")!!.text().let {
|
||||
name = it
|
||||
episode_number = it.substringBefore(" (")
|
||||
.substringAfterLast(" ")
|
||||
.toFloatOrNull() ?: 0F
|
||||
}
|
||||
|
||||
date_upload = element.selectFirst("div.epl-date")?.text().toDate()
|
||||
}
|
||||
}
|
||||
|
||||
override fun episodeListSelector() = "div.eplister > ul > li > a"
|
||||
|
||||
// =========================== Anime Details ============================
|
||||
override fun animeDetailsParse(document: Document): SAnime {
|
||||
val doc = getRealDoc(document)
|
||||
return SAnime.create().apply {
|
||||
setUrlWithoutDomain(doc.location())
|
||||
title = doc.selectFirst("h1.entry-title")!!.text()
|
||||
thumbnail_url = doc.selectFirst("div.thumb > img")!!.attr("src")
|
||||
|
||||
val infos = doc.selectFirst("div.info-content")!!
|
||||
genre = infos.select("div.genxed > a").eachText().joinToString()
|
||||
status = parseStatus(infos.getInfo("Status"))
|
||||
artist = infos.getInfo("Studio")
|
||||
author = infos.getInfo("Fansub")
|
||||
|
||||
description = buildString {
|
||||
doc.selectFirst("div.entry-content")?.text()?.let {
|
||||
append("$it\n\n")
|
||||
}
|
||||
|
||||
infos.select("div.spe > span").eachText().forEach {
|
||||
append("$it\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================ Video Links =============================
|
||||
override fun videoListSelector() = "select.mirror > option[data-index]"
|
||||
|
||||
override fun videoListParse(response: Response): List<Video> {
|
||||
val items = response.asJsoup().select(videoListSelector())
|
||||
val allowed = preferences.getStringSet(PREF_ALLOWED_LANGS_KEY, PREF_ALLOWED_LANGS_DEFAULT)!!
|
||||
return items
|
||||
.filter { element ->
|
||||
val text = element.text()
|
||||
allowed.any { it in text }
|
||||
}.parallelMap {
|
||||
val language = it.text().substringBefore(" ")
|
||||
val url = getHosterUrl(it.attr("value"))
|
||||
getVideoList(url, language)
|
||||
}.flatten()
|
||||
}
|
||||
|
||||
private fun getHosterUrl(encodedStr: String): String {
|
||||
return Base64.decode(encodedStr, Base64.DEFAULT)
|
||||
.let(::String) // bytearray -> string
|
||||
.substringAfter("iframe")
|
||||
.substringAfter("src=\"")
|
||||
.substringBefore('"')
|
||||
.let {
|
||||
// sometimes the url doesnt specify its protocol
|
||||
if (it.startsWith("http")) {
|
||||
it
|
||||
} else {
|
||||
"https:$it"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getVideoList(url: String, language: String): List<Video> {
|
||||
return runCatching {
|
||||
when {
|
||||
"ok.ru" in url ->
|
||||
OkruExtractor(client).videosFromUrl(url, "$language -")
|
||||
"fembed" in url ->
|
||||
FembedExtractor(client).videosFromUrl(url, "$language -")
|
||||
"dailymotion.com" in url ->
|
||||
DailymotionExtractor(client).videosFromUrl(url, "Dailymotion ($language)")
|
||||
else -> null
|
||||
}
|
||||
}.getOrNull() ?: emptyList()
|
||||
}
|
||||
|
||||
override fun videoFromElement(element: Element): Video {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun videoUrlParse(document: Document): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
// =============================== Search ===============================
|
||||
override fun searchAnimeFromElement(element: Element) = latestUpdatesFromElement(element)
|
||||
|
||||
override fun searchAnimeNextPageSelector() = "div.pagination a.next"
|
||||
|
||||
override fun getFilterList() = LMAnimeFilters.FILTER_LIST
|
||||
|
||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
||||
return if (query.isNotBlank()) {
|
||||
GET("$baseUrl/page/$page/?s=$query")
|
||||
} else {
|
||||
val genre = LMAnimeFilters.getGenre(filters)
|
||||
GET("$baseUrl/genres/$genre/page/$page")
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchAnimeSelector() = "div.listupd article a.tip"
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// =============================== Latest ===============================
|
||||
override fun latestUpdatesFromElement(element: Element): SAnime {
|
||||
return SAnime.create().apply {
|
||||
setUrlWithoutDomain(element.attr("href"))
|
||||
title = element.selectFirst("div.tt")!!.ownText()
|
||||
thumbnail_url = element.selectFirst("img")!!.attr("src")
|
||||
}
|
||||
}
|
||||
|
||||
override fun latestUpdatesNextPageSelector() = "div.hpage a:contains(Next)"
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/page/$page")
|
||||
|
||||
override fun latestUpdatesSelector() = "div.listupd.normal article a.tip"
|
||||
|
||||
// ============================== Settings ==============================
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||
val videoQualityPref = ListPreference(screen.context).apply {
|
||||
key = PREF_QUALITY_KEY
|
||||
title = PREF_QUALITY_TITLE
|
||||
entries = PREF_QUALITY_ENTRIES
|
||||
entryValues = PREF_QUALITY_ENTRIES
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
val langPref = ListPreference(screen.context).apply {
|
||||
key = PREF_LANG_KEY
|
||||
title = PREF_LANG_TITLE
|
||||
entries = PREF_LANG_ENTRIES
|
||||
entryValues = PREF_LANG_ENTRIES
|
||||
setDefaultValue(PREF_LANG_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()
|
||||
}
|
||||
}
|
||||
|
||||
val allowedPref = MultiSelectListPreference(screen.context).apply {
|
||||
key = PREF_ALLOWED_LANGS_KEY
|
||||
title = PREF_ALLOWED_LANGS_TITLE
|
||||
entries = PREF_ALLOWED_LANGS_ENTRIES
|
||||
entryValues = PREF_ALLOWED_LANGS_ENTRIES
|
||||
setDefaultValue(PREF_ALLOWED_LANGS_DEFAULT)
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
preferences.edit().putStringSet(key, newValue as Set<String>).commit()
|
||||
}
|
||||
}
|
||||
|
||||
screen.addPreference(videoQualityPref)
|
||||
screen.addPreference(langPref)
|
||||
screen.addPreference(allowedPref)
|
||||
}
|
||||
|
||||
// ============================= Utilities ==============================
|
||||
private fun getRealDoc(document: Document): Document {
|
||||
return document.selectFirst("div.naveps a:contains(All episodes)")?.let { link ->
|
||||
client.newCall(GET(link.attr("href")))
|
||||
.execute()
|
||||
.asJsoup()
|
||||
} ?: document
|
||||
}
|
||||
|
||||
private fun parseStatus(statusString: String?): Int {
|
||||
return when (statusString?.trim()) {
|
||||
"Completed" -> SAnime.COMPLETED
|
||||
"Ongoing" -> SAnime.ONGOING
|
||||
else -> SAnime.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element.getInfo(text: String): String? {
|
||||
return selectFirst("span:contains($text)")
|
||||
?.run {
|
||||
selectFirst("a")?.text() ?: ownText()
|
||||
}
|
||||
}
|
||||
|
||||
private fun String?.toDate(): Long {
|
||||
return this?.let {
|
||||
runCatching {
|
||||
DATE_FORMATTER.parse(this)?.time
|
||||
}.getOrNull()
|
||||
} ?: 0L
|
||||
}
|
||||
|
||||
override fun List<Video>.sort(): List<Video> {
|
||||
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
||||
val lang = preferences.getString(PREF_LANG_KEY, PREF_LANG_DEFAULT)!!
|
||||
return sortedWith(
|
||||
compareBy(
|
||||
{ it.quality.contains(quality) },
|
||||
{ it.quality.contains(lang) },
|
||||
),
|
||||
).reversed()
|
||||
}
|
||||
|
||||
private fun <A, B> Iterable<A>.parallelMap(f: suspend (A) -> B): List<B> =
|
||||
runBlocking {
|
||||
map { async(Dispatchers.Default) { f(it) } }.awaitAll()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("MMMM d, yyyy", Locale.ENGLISH) }
|
||||
|
||||
const val PREFIX_SEARCH = "id:"
|
||||
|
||||
private const val PREF_QUALITY_KEY = "pref_quality"
|
||||
private const val PREF_QUALITY_TITLE = "Preferred quality"
|
||||
private const val PREF_QUALITY_DEFAULT = "720p"
|
||||
private val PREF_QUALITY_ENTRIES = arrayOf("144p", "288p", "480p", "720p", "1080p")
|
||||
|
||||
private const val PREF_LANG_KEY = "pref_language"
|
||||
private const val PREF_LANG_TITLE = "Preferred language"
|
||||
private const val PREF_LANG_DEFAULT = "English"
|
||||
private val PREF_LANG_ENTRIES = arrayOf(
|
||||
"English",
|
||||
"Español",
|
||||
"Indonesian",
|
||||
"Portugués",
|
||||
"Türkçe",
|
||||
"العَرَبِيَّة",
|
||||
"ไทย",
|
||||
)
|
||||
|
||||
private const val PREF_ALLOWED_LANGS_KEY = "pref_allowed_languages"
|
||||
private const val PREF_ALLOWED_LANGS_TITLE = "Allowed languages to fetch videos"
|
||||
private val PREF_ALLOWED_LANGS_ENTRIES = PREF_LANG_ENTRIES
|
||||
private val PREF_ALLOWED_LANGS_DEFAULT = PREF_ALLOWED_LANGS_ENTRIES.toSet()
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.lmanime
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilter
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
|
||||
object LMAnimeFilters {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
private inline fun <reified R> AnimeFilterList.asQueryPart(): String {
|
||||
return this.first { it is R }.let {
|
||||
(it as QueryPartFilter).toQueryPart()
|
||||
}
|
||||
}
|
||||
|
||||
class GenreFilter : QueryPartFilter("Genre", LMAnimeFiltersData.GENRES)
|
||||
|
||||
val FILTER_LIST = AnimeFilterList(
|
||||
AnimeFilter.Header(LMAnimeFiltersData.IGNORE_SEARCH_MSG),
|
||||
GenreFilter(),
|
||||
)
|
||||
|
||||
fun getGenre(filters: AnimeFilterList) = filters.asQueryPart<GenreFilter>()
|
||||
|
||||
private object LMAnimeFiltersData {
|
||||
const val IGNORE_SEARCH_MSG = "NOTE: Ignored if using text search."
|
||||
|
||||
val GENRES = arrayOf(
|
||||
Pair("Action", "action"),
|
||||
Pair("Adventure", "adventure"),
|
||||
Pair("Angel", "angel"),
|
||||
Pair("cats", "cats"),
|
||||
Pair("Comedy", "comedy"),
|
||||
Pair("Crime", "crime"),
|
||||
Pair("Cultivation", "cultivation"),
|
||||
Pair("cure", "cure"),
|
||||
Pair("Demon", "demon"),
|
||||
Pair("Drama", "drama"),
|
||||
Pair("Fantasy", "fantasy"),
|
||||
Pair("fight", "fight"),
|
||||
Pair("god", "god"),
|
||||
Pair("growth", "growth"),
|
||||
Pair("Harem", "harem"),
|
||||
Pair("Historical", "historical"),
|
||||
Pair("Horror", "horror"),
|
||||
Pair("inspirational", "inspirational"),
|
||||
Pair("isekei", "isekei"),
|
||||
Pair("Magic", "magic"),
|
||||
Pair("Martial Arts", "martial-arts"),
|
||||
Pair("Mecha", "mecha"),
|
||||
Pair("Military", "military"),
|
||||
Pair("Mystery", "mystery"),
|
||||
Pair("Mythology", "mythology"),
|
||||
Pair("Original", "original"),
|
||||
Pair("Poetry", "poetry"),
|
||||
Pair("Psychological", "psychological"),
|
||||
Pair("Romance", "romance"),
|
||||
Pair("school", "school"),
|
||||
Pair("Sci-Fi", "sci-fi"),
|
||||
Pair("Shounen", "shounen"),
|
||||
Pair("Slice of Life", "slice-of-life"),
|
||||
Pair("Space", "space"),
|
||||
Pair("Spirit", "spirit"),
|
||||
Pair("Super Power", "super-power"),
|
||||
Pair("Supernatural", "supernatural"),
|
||||
Pair("Suspense", "suspense"),
|
||||
Pair("Thriller", "thriller"),
|
||||
Pair("War", "war"),
|
||||
)
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.lmanime
|
||||
|
||||
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://lmanime.com/<item> intents
|
||||
* and redirects them to the main Aniyomi process.
|
||||
*/
|
||||
class LMAnimeUrlActivity : Activity() {
|
||||
|
||||
private val tag = javaClass.simpleName
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
if (pathSegments != null && pathSegments.size > 0) {
|
||||
val item = pathSegments[0]
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.ANIMESEARCH"
|
||||
putExtra("query", "${LMAnime.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)
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package eu.kanade.tachiyomi.animeextension.all.lmanime.extractors
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.OkHttpClient
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@Serializable
|
||||
data class DailyQuality(
|
||||
val qualities: Auto,
|
||||
) {
|
||||
@Serializable
|
||||
data class Auto(
|
||||
val auto: List<Video>,
|
||||
) {
|
||||
@Serializable
|
||||
data class Video(
|
||||
val type: String,
|
||||
val url: String,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class DailymotionExtractor(private val client: OkHttpClient) {
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
fun videosFromUrl(url: String, prefix: String): List<Video> {
|
||||
val id = url.substringBefore("?").substringAfterLast("/")
|
||||
val jsonUrl = "https://www.dailymotion.com/player/metadata/video/$id"
|
||||
val jsonRequest = client.newCall(GET(jsonUrl)).execute().body.string()
|
||||
val parsed = json.decodeFromString<DailyQuality>(jsonRequest)
|
||||
|
||||
val masterUrl = parsed.qualities.auto.first().url
|
||||
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body.string()
|
||||
|
||||
val separator = "#EXT-X-STREAM-INF"
|
||||
return masterPlaylist.substringAfter(separator).split(separator).map {
|
||||
val resolution = it.substringAfter("RESOLUTION=")
|
||||
.substringAfter("x")
|
||||
.substringBefore(",NAME") + "p"
|
||||
val quality = "$prefix $resolution"
|
||||
val videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||
|
||||
Video(videoUrl, quality, videoUrl)
|
||||
}
|
||||
}
|
||||
}
|