AnimesVision: Fix GlobalVision extractor and add URL intent handler (#666)
* AnimesVision: Add VoeExtractor * AnimesVision: fix GlobalVision extractor * AnimesVision: Bump version * AnimesVision: Remove 'useless' config and reimplement video sorter * AnimesVision: Add URL Intent handler
This commit is contained in:
@ -1,2 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest package="eu.kanade.tachiyomi.animeextension"/>
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="eu.kanade.tachiyomi.animeextension">
|
||||||
|
|
||||||
|
<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>
|
||||||
|
@ -6,12 +6,13 @@ ext {
|
|||||||
extName = 'AnimesVision'
|
extName = 'AnimesVision'
|
||||||
pkgNameSuffix = 'pt.animesvision'
|
pkgNameSuffix = 'pt.animesvision'
|
||||||
extClass = '.AnimesVision'
|
extClass = '.AnimesVision'
|
||||||
extVersionCode = 4
|
extVersionCode = 5
|
||||||
libVersion = '12'
|
libVersion = '12'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
|
compileOnly 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.animeextension.pt.animesvision.dto.PayloadItem
|
|||||||
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.DoodExtractor
|
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.DoodExtractor
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.GlobalVisionExtractor
|
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.GlobalVisionExtractor
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.StreamTapeExtractor
|
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.StreamTapeExtractor
|
||||||
|
import eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors.VoeExtractor
|
||||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
import eu.kanade.tachiyomi.animesource.model.AnimesPage
|
||||||
@ -146,12 +147,14 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
val hosts_ids = mutableListOf<Int>()
|
val hosts_ids = mutableListOf<Int>()
|
||||||
|
|
||||||
val ignoredHosts = preferences.getStringSet(IGNORED_HOSTS, null)
|
val ignoredHosts = preferences.getStringSet(IGNORED_HOSTS, null)
|
||||||
val ignoreDO = ignoredHosts?.contains(HOSTS_NAMES.elementAt(1)) ?: false
|
val ignoreDO = ignoredHosts?.contains(HOSTS_NAMES.elementAt(0)) ?: false
|
||||||
val ignoreST = ignoredHosts?.contains(HOSTS_NAMES.elementAt(2)) ?: false
|
val ignoreST = ignoredHosts?.contains(HOSTS_NAMES.elementAt(1)) ?: false
|
||||||
|
val ignoreVO = ignoredHosts?.contains(HOSTS_NAMES.elementAt(2)) ?: false
|
||||||
|
|
||||||
if (!ignoreST && "Streamtape" in players)
|
if (!ignoreST && "Streamtape" in players)
|
||||||
hosts_ids.add(5)
|
hosts_ids.add(5)
|
||||||
|
if (!ignoreVO && "Voe CDN" in players)
|
||||||
|
hosts_ids.add(7)
|
||||||
if (!ignoreDO && "DOOD" in players)
|
if (!ignoreDO && "DOOD" in players)
|
||||||
hosts_ids.add(8)
|
hosts_ids.add(8)
|
||||||
|
|
||||||
@ -174,15 +177,19 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
it.text()
|
it.text()
|
||||||
}
|
}
|
||||||
val videoList = GlobalVisionExtractor()
|
val videoList = GlobalVisionExtractor()
|
||||||
.videoListFromHtml(doc.html(), players)
|
.videoListFromHtml(doc.html())
|
||||||
.toMutableList()
|
.toMutableList()
|
||||||
|
|
||||||
getPlayersUrl(doc, players).forEach {
|
getPlayersUrl(doc, players).forEach {
|
||||||
val video = if (it.contains("streamtape")) {
|
val video = when {
|
||||||
StreamTapeExtractor(client).videoFromUrl(it)
|
"streamtape" in it ->
|
||||||
} else if (it.contains("dood")) {
|
StreamTapeExtractor(client).videoFromUrl(it)
|
||||||
DoodExtractor(client).videoFromUrl(it)
|
"dood" in it ->
|
||||||
} else { null }
|
DoodExtractor(client).videoFromUrl(it)
|
||||||
|
"voe.sx" in it ->
|
||||||
|
VoeExtractor(client).videoFromUrl(it)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
if (video != null)
|
if (video != null)
|
||||||
videoList.add(video)
|
videoList.add(video)
|
||||||
}
|
}
|
||||||
@ -208,12 +215,27 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
override fun searchAnimeSelector(): String = "div.film_list-wrap div.film-poster"
|
override fun searchAnimeSelector(): String = "div.film_list-wrap div.film-poster"
|
||||||
|
|
||||||
override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage> {
|
override fun fetchSearchAnime(page: Int, query: String, filters: AnimeFilterList): Observable<AnimesPage> {
|
||||||
val params = AVFilters.getSearchParameters(filters)
|
return if (query.startsWith(PREFIX_SEARCH)) {
|
||||||
return client.newCall(searchAnimeRequest(page, query, params))
|
val path = query.removePrefix(PREFIX_SEARCH)
|
||||||
.asObservableSuccess()
|
client.newCall(GET("$baseUrl/$path"))
|
||||||
.map { response ->
|
.asObservableSuccess()
|
||||||
searchAnimeParse(response)
|
.map { response ->
|
||||||
}
|
searchAnimeByPathParse(response, path)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val params = AVFilters.getSearchParameters(filters)
|
||||||
|
client.newCall(searchAnimeRequest(page, query, params))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map { response ->
|
||||||
|
searchAnimeParse(response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchAnimeByPathParse(response: Response, path: String): AnimesPage {
|
||||||
|
val details = animeDetailsParse(response)
|
||||||
|
details.url = "/$path"
|
||||||
|
return AnimesPage(listOf(details), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = throw Exception("not used")
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = throw Exception("not used")
|
||||||
@ -281,23 +303,6 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
// ============================== Settings ==============================
|
// ============================== Settings ==============================
|
||||||
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
|
||||||
val videoServerPref = ListPreference(screen.context).apply {
|
|
||||||
key = PREFERRED_HOST
|
|
||||||
title = "Host preferido"
|
|
||||||
entries = HOSTS_NAMES
|
|
||||||
entryValues = HOSTS_URLS
|
|
||||||
setDefaultValue(HOSTS_URLS.first())
|
|
||||||
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 {
|
val videoQualityPref = ListPreference(screen.context).apply {
|
||||||
key = PREFERRED_QUALITY
|
key = PREFERRED_QUALITY
|
||||||
title = "Qualidade preferida (Válido apenas no GlobalVision)"
|
title = "Qualidade preferida (Válido apenas no GlobalVision)"
|
||||||
@ -314,11 +319,10 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val ignoredHosts = MultiSelectListPreference(screen.context).apply {
|
val ignoredHosts = MultiSelectListPreference(screen.context).apply {
|
||||||
val values = HOSTS_NAMES.drop(1).toTypedArray()
|
|
||||||
key = IGNORED_HOSTS
|
key = IGNORED_HOSTS
|
||||||
title = "Hosts ignorados ao carregar"
|
title = "Hosts ignorados ao carregar"
|
||||||
entries = values
|
entries = HOSTS_NAMES
|
||||||
entryValues = values
|
entryValues = HOSTS_NAMES
|
||||||
setDefaultValue(emptySet<String>())
|
setDefaultValue(emptySet<String>())
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
preferences.edit()
|
preferences.edit()
|
||||||
@ -327,7 +331,6 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
screen.addPreference(videoServerPref)
|
|
||||||
screen.addPreference(videoQualityPref)
|
screen.addPreference(videoQualityPref)
|
||||||
screen.addPreference(ignoredHosts)
|
screen.addPreference(ignoredHosts)
|
||||||
}
|
}
|
||||||
@ -375,29 +378,19 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun List<Video>.sort(): List<Video> {
|
override fun List<Video>.sort(): List<Video> {
|
||||||
val host = preferences.getString(PREFERRED_HOST, null)
|
|
||||||
val quality = preferences.getString(PREFERRED_QUALITY, null)
|
val quality = preferences.getString(PREFERRED_QUALITY, null)
|
||||||
if (host != null) {
|
if (quality != null) {
|
||||||
var preferred = 0
|
|
||||||
val newList = mutableListOf<Video>()
|
val newList = mutableListOf<Video>()
|
||||||
|
var preferred = 0
|
||||||
for (video in this) {
|
for (video in this) {
|
||||||
if (video.url.contains(host)) {
|
if (quality in video.quality) {
|
||||||
if (host == HOSTS_URLS.first() && quality != null) {
|
newList.add(preferred, video)
|
||||||
val contains: Boolean = video.quality.contains(quality)
|
preferred++
|
||||||
if (contains) {
|
|
||||||
newList.add(preferred, video)
|
|
||||||
preferred++
|
|
||||||
} else {
|
|
||||||
newList.add(video)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newList.add(preferred, video)
|
|
||||||
preferred++
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
newList.add(video)
|
newList.add(video)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return newList
|
return newList
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
@ -405,11 +398,10 @@ class AnimesVision : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7"
|
private const val ACCEPT_LANGUAGE = "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7"
|
||||||
private const val PREFERRED_HOST = "preferred_host"
|
|
||||||
private const val PREFERRED_QUALITY = "preferred_quality"
|
private const val PREFERRED_QUALITY = "preferred_quality"
|
||||||
private const val IGNORED_HOSTS = "ignored_hosts"
|
private const val IGNORED_HOSTS = "ignored_hosts"
|
||||||
private val HOSTS_NAMES = arrayOf("GlobalVision", "DoodStream", "StreamTape")
|
private val HOSTS_NAMES = arrayOf("DoodStream", "StreamTape", "VoeCDN")
|
||||||
private val HOSTS_URLS = arrayOf("animes.vision", "https://dood", "https://streamtape")
|
private val QUALITY_LIST = arrayOf("480p", "720p", "1080p", "4K")
|
||||||
private val QUALITY_LIST = arrayOf("SD", "HD", "FULLHD")
|
const val PREFIX_SEARCH = "path:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class DoodExtractor(private val client: OkHttpClient) {
|
|||||||
)
|
)
|
||||||
).execute().body!!.string()
|
).execute().body!!.string()
|
||||||
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
val videoUrl = "$videoUrlStart$randomString?token=$token&expiry=$expiry"
|
||||||
val newQuality = "Doodstream mirror"
|
val newQuality = "DoodStream mirror"
|
||||||
|
|
||||||
return Video(url, newQuality, videoUrl, null, doodHeaders(doodTld))
|
return Video(url, newQuality, videoUrl, null, doodHeaders(doodTld))
|
||||||
}
|
}
|
||||||
|
@ -3,23 +3,14 @@ package eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors
|
|||||||
import eu.kanade.tachiyomi.animesource.model.Video
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
class GlobalVisionExtractor {
|
class GlobalVisionExtractor {
|
||||||
|
|
||||||
private val REGEX_URL = Regex("""file: "(\S+?)",""")
|
private val REGEX_URL = Regex(""""file":"(\S+?)",.*?"label":"(.*?)"""")
|
||||||
private val PREFIX = "GlobalVision"
|
private val PREFIX = "GlobalVision"
|
||||||
|
|
||||||
fun videoListFromHtml(html: String, players: String): List<Video> {
|
fun videoListFromHtml(html: String): List<Video> {
|
||||||
val matches = REGEX_URL.find(html)
|
return REGEX_URL.findAll(html).map {
|
||||||
if (matches == null)
|
val videoUrl = it.groupValues[1].replace("\\", "")
|
||||||
return emptyList<Video>()
|
val qualityName = it.groupValues[2]
|
||||||
val url = matches.groupValues[1]
|
Video(videoUrl, "$PREFIX $qualityName", videoUrl, null)
|
||||||
val qualities = mapOf("SD" to "480p", "HD" to "720p", "FULLHD" to "1080p")
|
}.toList()
|
||||||
return qualities.mapNotNull { (qualityName, qualityStr) ->
|
|
||||||
if (qualityName in players) {
|
|
||||||
val videoUrl = when {
|
|
||||||
qualityName == "SD" -> url
|
|
||||||
else -> url.replace("480p", qualityStr)
|
|
||||||
}
|
|
||||||
Video(videoUrl, "$PREFIX $qualityName", videoUrl, null)
|
|
||||||
} else { null }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.pt.animesvision.extractors
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
|
||||||
|
class VoeExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
|
fun videoFromUrl(url: String): Video? {
|
||||||
|
val document = client.newCall(GET(url)).execute().asJsoup()
|
||||||
|
val script = document.selectFirst("script:containsData(const sources)")
|
||||||
|
?.data()
|
||||||
|
?: return null
|
||||||
|
val videoUrl = script.substringAfter("hls\": \"").substringBefore("\"")
|
||||||
|
val quality = script.substringAfter("video_height\": ")
|
||||||
|
.substringBefore(",")
|
||||||
|
val qualityStr = "VoeCDN(${quality}p)"
|
||||||
|
return Video(videoUrl, qualityStr, videoUrl, null)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user