chore(src/pt): Remove AnimesVision (#3222)
This commit is contained in:
parent
470f6f7ef7
commit
7dc9a5a6e3
@ -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=".pt.animesvision.AVUrlActivity"
|
|
||||||
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="animes.vision"
|
|
||||||
android:pathPattern="/..*/..*"
|
|
||||||
android:scheme="https" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
@ -1,7 +0,0 @@
|
|||||||
ext {
|
|
||||||
extName = 'AnimesVision'
|
|
||||||
extClass = '.AnimesVision'
|
|
||||||
extVersionCode = 25
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB |
File diff suppressed because it is too large
Load Diff
@ -1,43 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.animesvision
|
|
||||||
|
|
||||||
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://animes.vision/<type>/<item> intents
|
|
||||||
* and redirects them to the main Aniyomi process.
|
|
||||||
*/
|
|
||||||
class AVUrlActivity : Activity() {
|
|
||||||
|
|
||||||
private val tag = "AVUrlActivity"
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
val pathSegments = intent?.data?.pathSegments
|
|
||||||
if (pathSegments != null && pathSegments.size > 1) {
|
|
||||||
val type = pathSegments[0]
|
|
||||||
val item = pathSegments[1]
|
|
||||||
val searchQuery = "$type/$item"
|
|
||||||
val mainIntent = Intent().apply {
|
|
||||||
action = "eu.kanade.tachiyomi.ANIMESEARCH"
|
|
||||||
putExtra("query", "${AnimesVision.PREFIX_SEARCH}$searchQuery")
|
|
||||||
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,281 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.animesvision
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.preference.ListPreference
|
|
||||||
import androidx.preference.PreferenceScreen
|
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.AnimesVisionExtractor
|
|
||||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
|
||||||
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
|
||||||
import eu.kanade.tachiyomi.network.GET
|
|
||||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
|
||||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
|
||||||
import okhttp3.Interceptor
|
|
||||||
import okhttp3.Request
|
|
||||||
import okhttp3.Response
|
|
||||||
import org.jsoup.nodes.Document
|
|
||||||
import org.jsoup.nodes.Element
|
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|
||||||
|
|
||||||
override val name = "AnimesVision"
|
|
||||||
|
|
||||||
override val baseUrl = "https://animes.vision"
|
|
||||||
|
|
||||||
override val lang = "pt-BR"
|
|
||||||
|
|
||||||
override val supportsLatest = true
|
|
||||||
|
|
||||||
override val client = network.client.newBuilder()
|
|
||||||
.addInterceptor(::loginInterceptor)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
private val preferences by lazy {
|
|
||||||
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun headersBuilder() = super.headersBuilder()
|
|
||||||
.add("Referer", baseUrl)
|
|
||||||
.add("Accept-Language", ACCEPT_LANGUAGE)
|
|
||||||
|
|
||||||
// ============================== Popular ===============================
|
|
||||||
private fun nextPageSelector() = "ul.pagination li.page-item:contains(›):not(.disabled)"
|
|
||||||
override fun popularAnimeRequest(page: Int) = GET(baseUrl, headers)
|
|
||||||
override fun popularAnimeSelector() = "div#anime-trending div.item > a.film-poster"
|
|
||||||
|
|
||||||
override fun popularAnimeFromElement(element: Element) = SAnime.create().apply {
|
|
||||||
val img = element.selectFirst("img")!!
|
|
||||||
setUrlWithoutDomain(element.attr("href"))
|
|
||||||
title = img.attr("title")
|
|
||||||
thumbnail_url = img.attr("src")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun popularAnimeNextPageSelector() = null
|
|
||||||
|
|
||||||
// =============================== Latest ===============================
|
|
||||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/lancamentos?page=$page")
|
|
||||||
override fun latestUpdatesSelector() = episodeListSelector()
|
|
||||||
|
|
||||||
override fun latestUpdatesFromElement(element: Element) = SAnime.create().apply {
|
|
||||||
setUrlWithoutDomain(element.selectFirst("a")!!.attr("href"))
|
|
||||||
title = element.selectFirst("h3")!!.text()
|
|
||||||
thumbnail_url = element.selectFirst("img")?.attr("src")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun latestUpdatesNextPageSelector() = nextPageSelector()
|
|
||||||
|
|
||||||
// =============================== Search ===============================
|
|
||||||
override suspend fun getSearchAnime(page: Int, query: String, filters: AnimeFilterList): AnimesPage {
|
|
||||||
return if (query.startsWith(PREFIX_SEARCH)) {
|
|
||||||
val path = query.removePrefix(PREFIX_SEARCH)
|
|
||||||
client.newCall(GET("$baseUrl/$path"))
|
|
||||||
.awaitSuccess()
|
|
||||||
.use(::searchAnimeByPathParse)
|
|
||||||
} else {
|
|
||||||
super.getSearchAnime(page, query, filters)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun searchAnimeByPathParse(response: Response): AnimesPage {
|
|
||||||
val details = animeDetailsParse(response)
|
|
||||||
return AnimesPage(listOf(details), false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request {
|
|
||||||
val params = AVFilters.getSearchParameters(filters)
|
|
||||||
val url = "$baseUrl/search-anime".toHttpUrl().newBuilder()
|
|
||||||
.addQueryParameter("page", page.toString())
|
|
||||||
.addQueryParameter("nome", query)
|
|
||||||
.addQueryParameter("tipo", params.type)
|
|
||||||
.addQueryParameter("idioma", params.language)
|
|
||||||
.addQueryParameter("ordenar", params.sort)
|
|
||||||
.addQueryParameter("ano_inicial", params.initial_year)
|
|
||||||
.addQueryParameter("ano_final", params.last_year)
|
|
||||||
.addQueryParameter("fansub", params.fansub)
|
|
||||||
.addQueryParameter("status", params.status)
|
|
||||||
.addQueryParameter("temporada", params.season)
|
|
||||||
.addQueryParameter("estudios", params.studio)
|
|
||||||
.addQueryParameter("produtores", params.producer)
|
|
||||||
.addQueryParameter("generos", params.genres)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
return GET(url, headers)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchAnimeSelector() = "div.film_list-wrap div.film-poster"
|
|
||||||
|
|
||||||
override fun searchAnimeFromElement(element: Element) = SAnime.create().apply {
|
|
||||||
val elementA = element.selectFirst("a")!!
|
|
||||||
title = elementA.attr("title")
|
|
||||||
setUrlWithoutDomain(elementA.attr("href"))
|
|
||||||
thumbnail_url = element.selectFirst("img")?.attr("data-src")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchAnimeNextPageSelector() = nextPageSelector()
|
|
||||||
|
|
||||||
// =========================== Anime Details ============================
|
|
||||||
override fun animeDetailsParse(document: Document) = SAnime.create().apply {
|
|
||||||
val doc = getRealDoc(document)
|
|
||||||
setUrlWithoutDomain(doc.location())
|
|
||||||
|
|
||||||
val content = doc.selectFirst("div#ani_detail div.anis-content")!!
|
|
||||||
val detail = content.selectFirst("div.anisc-detail")!!
|
|
||||||
val infos = content.selectFirst("div.anisc-info")!!
|
|
||||||
|
|
||||||
thumbnail_url = content.selectFirst("img")?.attr("src")
|
|
||||||
title = detail.selectFirst("h2.film-name")!!.text()
|
|
||||||
genre = infos.getInfo("Gêneros")
|
|
||||||
author = infos.getInfo("Produtores")
|
|
||||||
artist = infos.getInfo("Estúdios")
|
|
||||||
status = parseStatus(infos.getInfo("Status"))
|
|
||||||
|
|
||||||
description = buildString {
|
|
||||||
appendLine(infos.getInfo("Sinopse"))
|
|
||||||
infos.getInfo("Inglês")?.also { append("\nTítulo em inglês: ", it) }
|
|
||||||
infos.getInfo("Japonês")?.also { append("\nTítulo em japonês: ", it) }
|
|
||||||
infos.getInfo("Foi ao ar em")?.also { append("\nFoi ao ar em: ", it) }
|
|
||||||
infos.getInfo("Temporada")?.also { append("\nTemporada: ", it) }
|
|
||||||
infos.getInfo("Duração")?.also { append("\nDuração: ", it) }
|
|
||||||
infos.getInfo("Fansub")?.also { append("\nFansub: ", it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================== Episodes ==============================
|
|
||||||
override fun episodeListSelector() = "div.container div.screen-items > div.item"
|
|
||||||
|
|
||||||
override fun episodeListParse(response: Response): List<SEpisode> {
|
|
||||||
var doc = getRealDoc(response.asJsoup())
|
|
||||||
|
|
||||||
return buildList {
|
|
||||||
do {
|
|
||||||
if (isNotEmpty()) {
|
|
||||||
val nextUrl = doc.selectFirst(nextPageSelector())!!
|
|
||||||
.selectFirst("a")!!
|
|
||||||
.attr("href")
|
|
||||||
doc = client.newCall(GET(nextUrl)).execute().asJsoup()
|
|
||||||
}
|
|
||||||
doc.select(episodeListSelector())
|
|
||||||
.map(::episodeFromElement)
|
|
||||||
.also(::addAll)
|
|
||||||
} while (doc.selectFirst(nextPageSelector()) != null)
|
|
||||||
reverse()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun episodeFromElement(element: Element) = SEpisode.create().apply {
|
|
||||||
setUrlWithoutDomain(element.selectFirst("a")!!.attr("href"))
|
|
||||||
val epName = element.selectFirst("h3")!!.text().trim()
|
|
||||||
name = epName
|
|
||||||
episode_number = epName.substringAfterLast(" ").toFloatOrNull() ?: 0F
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================ Video Links =============================
|
|
||||||
override fun videoListParse(response: Response): List<Video> {
|
|
||||||
val doc = response.asJsoup()
|
|
||||||
val encodedScript = doc.selectFirst("div.player-frame div#playerglobalapi ~ script")?.data()
|
|
||||||
// "ERROR: Script not found."
|
|
||||||
?: throw Exception("ERRO: Script não encontrado.")
|
|
||||||
return AnimesVisionExtractor.videoListFromScript(encodedScript)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun videoListSelector() = throw UnsupportedOperationException()
|
|
||||||
override fun videoFromElement(element: Element) = throw UnsupportedOperationException()
|
|
||||||
override fun videoUrlParse(document: Document) = throw UnsupportedOperationException()
|
|
||||||
|
|
||||||
// ============================== Settings ==============================
|
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
|
||||||
ListPreference(screen.context).apply {
|
|
||||||
key = PREF_QUALITY_KEY
|
|
||||||
title = PREF_QUALITY_TITLE
|
|
||||||
entries = PREF_QUALITY_VALUES
|
|
||||||
entryValues = PREF_QUALITY_VALUES
|
|
||||||
setDefaultValue(PREF_QUALITY_DEFAULT)
|
|
||||||
summary = "%s"
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
val selected = newValue as String
|
|
||||||
val index = findIndexOfValue(selected)
|
|
||||||
val entry = entryValues[index] as String
|
|
||||||
preferences.edit().putString(key, entry).commit()
|
|
||||||
}
|
|
||||||
}.also(screen::addPreference)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getFilterList() = AVFilters.FILTER_LIST
|
|
||||||
|
|
||||||
// ============================= Utilities ==============================
|
|
||||||
// i'll leave this here just in case the source starts requiring logins again
|
|
||||||
private fun loginInterceptor(chain: Interceptor.Chain): Response {
|
|
||||||
val response = chain.proceed(chain.request())
|
|
||||||
|
|
||||||
if ("/login" in response.request.url.toString()) {
|
|
||||||
response.close()
|
|
||||||
throw IOException(ERROR_LOGIN_MISSING)
|
|
||||||
}
|
|
||||||
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getRealDoc(document: Document): Document {
|
|
||||||
val originalUrl = document.location()
|
|
||||||
if ("/episodio-" in originalUrl || "/filme-" in originalUrl) {
|
|
||||||
val url = document.selectFirst("h2.film-name > a")!!.attr("href")
|
|
||||||
val req = client.newCall(GET(url)).execute()
|
|
||||||
return req.asJsoup()
|
|
||||||
}
|
|
||||||
return document
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun parseStatus(statusString: String?): Int {
|
|
||||||
return when (statusString?.trim()) {
|
|
||||||
"Fim da exibição" -> SAnime.COMPLETED
|
|
||||||
"Atualmente sendo exibido" -> SAnime.ONGOING
|
|
||||||
else -> SAnime.UNKNOWN
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun Element.getInfo(key: String): String? {
|
|
||||||
val div = selectFirst("div.item:contains($key)")
|
|
||||||
?: return null
|
|
||||||
|
|
||||||
val elementsA = div.select("a[href]")
|
|
||||||
val text = if (elementsA.isEmpty()) {
|
|
||||||
val selector = when {
|
|
||||||
div.hasClass("w-hide") -> "div.text"
|
|
||||||
else -> "span.name"
|
|
||||||
}
|
|
||||||
div.selectFirst(selector)!!.text().trim()
|
|
||||||
} else {
|
|
||||||
elementsA.joinToString { it.text().trim() }
|
|
||||||
}
|
|
||||||
|
|
||||||
return text.takeIf(String::isNotBlank)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun List<Video>.sort(): List<Video> {
|
|
||||||
val quality = preferences.getString(PREF_QUALITY_KEY, PREF_QUALITY_DEFAULT)!!
|
|
||||||
return sortedWith(
|
|
||||||
compareByDescending { it.quality.contains(quality) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val PREFIX_SEARCH = "path:"
|
|
||||||
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7"
|
|
||||||
|
|
||||||
private const val ERROR_LOGIN_MISSING = "Login necessário. " +
|
|
||||||
"Abra a WebView, insira os dados de sua conta e realize o login."
|
|
||||||
|
|
||||||
private const val PREF_QUALITY_KEY = "preferred_quality"
|
|
||||||
private const val PREF_QUALITY_TITLE = "Qualidade preferida"
|
|
||||||
private const val PREF_QUALITY_DEFAULT = "720p"
|
|
||||||
private val PREF_QUALITY_VALUES = arrayOf("480p", "720p", "1080p", "4K")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.animesvision.dto
|
|
||||||
|
|
||||||
import kotlinx.serialization.EncodeDefault
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PayloadItem(
|
|
||||||
val payload: PayloadData,
|
|
||||||
@EncodeDefault
|
|
||||||
val type: String = "callMethod",
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PayloadData(
|
|
||||||
val params: List<Int>,
|
|
||||||
@EncodeDefault
|
|
||||||
val method: String = "mudarPlayer",
|
|
||||||
@EncodeDefault
|
|
||||||
val id: String = "",
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AVResponseDto(
|
|
||||||
val effects: AVResponseEffects? = null,
|
|
||||||
val serverMemo: AVResponseMemo? = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AVResponseEffects(
|
|
||||||
val html: String? = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AVResponseMemo(
|
|
||||||
val data: AVResponseData? = null,
|
|
||||||
)
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AVResponseData(
|
|
||||||
val framePlay: String? = null,
|
|
||||||
)
|
|
@ -1,16 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors
|
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
|
||||||
|
|
||||||
object AnimesVisionExtractor {
|
|
||||||
private val REGEX_URL = Regex(""""file":"(\S+?)",.*?"label":"(.*?)"""")
|
|
||||||
|
|
||||||
fun videoListFromScript(encodedScript: String): List<Video> {
|
|
||||||
val decodedScript = JsDecoder.decodeScript(encodedScript)
|
|
||||||
return REGEX_URL.findAll(decodedScript).map {
|
|
||||||
val videoUrl = it.groupValues[1].replace("\\", "")
|
|
||||||
val qualityName = it.groupValues[2]
|
|
||||||
Video(videoUrl, "PlayerVision $qualityName", videoUrl)
|
|
||||||
}.toList()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors
|
|
||||||
|
|
||||||
import kotlin.math.pow
|
|
||||||
|
|
||||||
// From pt/goanimes, but without b64-decoding.
|
|
||||||
object JsDecoder {
|
|
||||||
private fun convertToNum(thing: String, limit: Float): Int {
|
|
||||||
return thing.split("")
|
|
||||||
.reversed()
|
|
||||||
.map { it.toIntOrNull() ?: 0 }
|
|
||||||
.reduceIndexed { index: Int, acc, num ->
|
|
||||||
acc + (num * limit.pow(index - 1)).toInt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun decodeScript(encodedString: String, magicStr: String, offset: Int, limit: Int): String {
|
|
||||||
val regex = "\\w".toRegex()
|
|
||||||
return encodedString
|
|
||||||
.split(magicStr[limit])
|
|
||||||
.dropLast(1)
|
|
||||||
.map { str ->
|
|
||||||
val replaced = regex.replace(str) { magicStr.indexOf(it.value).toString() }
|
|
||||||
val charInt = convertToNum(replaced, limit.toFloat()) - offset
|
|
||||||
Char(charInt)
|
|
||||||
}.joinToString("")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun decodeScript(script: String): String {
|
|
||||||
val regex = """\}\("(\w+)",.*?"(\w+)",(\d+),(\d+),.*?\)""".toRegex()
|
|
||||||
return regex.find(script)
|
|
||||||
?.run {
|
|
||||||
decodeScript(
|
|
||||||
groupValues[1], // encoded data
|
|
||||||
groupValues[2], // magic string
|
|
||||||
groupValues[3].toIntOrNull() ?: 0, // offset
|
|
||||||
groupValues[4].toIntOrNull() ?: 0, // limit
|
|
||||||
)
|
|
||||||
} ?: ""
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user