forked from AlmightyHak/extensions-source
fix(pt/Anitube): Added option to disable File4Go mirror (#309)
This commit is contained in:
parent
694a8b4aba
commit
2eac326793
3 changed files with 45 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
ext {
|
ext {
|
||||||
extName = 'Anitube'
|
extName = 'Anitube'
|
||||||
extClass = '.Anitube'
|
extClass = '.Anitube'
|
||||||
extVersionCode = 19
|
extVersionCode = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: "$rootDir/common.gradle"
|
apply from: "$rootDir/common.gradle"
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Application
|
||||||
import androidx.preference.EditTextPreference
|
import androidx.preference.EditTextPreference
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.anitube.extractors.AnitubeDownloadExtractor
|
import eu.kanade.tachiyomi.animeextension.pt.anitube.extractors.AnitubeDownloadExtractor
|
||||||
import eu.kanade.tachiyomi.animeextension.pt.anitube.extractors.AnitubeExtractor
|
import eu.kanade.tachiyomi.animeextension.pt.anitube.extractors.AnitubeExtractor
|
||||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
|
@ -199,8 +200,10 @@ class Anitube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
val links = mutableListOf(document.location())
|
val links = mutableListOf(document.location())
|
||||||
|
|
||||||
document.selectFirst("div.abaItemDown > a")?.attr("href")?.let {
|
if (preferences.getBoolean(PREF_FILE4GO_KEY, PREF_FILE4GO_DEFAULT)!!) {
|
||||||
links.add(it)
|
document.selectFirst("div.abaItemDown > a")?.attr("href")?.let {
|
||||||
|
links.add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val epName = document.selectFirst("meta[itemprop=name]")!!.attr("content")
|
val epName = document.selectFirst("meta[itemprop=name]")!!.attr("content")
|
||||||
|
@ -235,6 +238,16 @@ class Anitube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
}
|
}
|
||||||
}.also(screen::addPreference)
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
|
SwitchPreferenceCompat(screen.context).apply {
|
||||||
|
key = PREF_FILE4GO_KEY
|
||||||
|
title = "Usar File4Go como mirror"
|
||||||
|
setDefaultValue(PREF_FILE4GO_DEFAULT)
|
||||||
|
summary = PREF_FILE4GO_SUMMARY
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
preferences.edit().putBoolean(key, newValue as Boolean).commit()
|
||||||
|
}
|
||||||
|
}.also(screen::addPreference)
|
||||||
|
|
||||||
// Auth Code
|
// Auth Code
|
||||||
EditTextPreference(screen.context).apply {
|
EditTextPreference(screen.context).apply {
|
||||||
key = PREF_AUTHCODE_KEY
|
key = PREF_AUTHCODE_KEY
|
||||||
|
@ -308,6 +321,9 @@ class Anitube : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
private const val PREF_AUTHCODE_KEY = "authcode"
|
private const val PREF_AUTHCODE_KEY = "authcode"
|
||||||
private const val PREF_AUTHCODE_SUMMARY = "Código de Autenticação"
|
private const val PREF_AUTHCODE_SUMMARY = "Código de Autenticação"
|
||||||
private const val PREF_AUTHCODE_DEFAULT = ""
|
private const val PREF_AUTHCODE_DEFAULT = ""
|
||||||
|
private const val PREF_FILE4GO_KEY = "file4go"
|
||||||
|
private const val PREF_FILE4GO_SUMMARY = "Usar File4Go como mirror"
|
||||||
|
private const val PREF_FILE4GO_DEFAULT = false
|
||||||
private const val PREF_QUALITY_KEY = "preferred_quality"
|
private const val PREF_QUALITY_KEY = "preferred_quality"
|
||||||
private const val PREF_QUALITY_TITLE = "Qualidade preferida"
|
private const val PREF_QUALITY_TITLE = "Qualidade preferida"
|
||||||
private const val PREF_QUALITY_DEFAULT = "HD"
|
private const val PREF_QUALITY_DEFAULT = "HD"
|
||||||
|
|
|
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import eu.kanade.tachiyomi.util.parallelMapNotNullBlocking
|
import eu.kanade.tachiyomi.util.parallelMapNotNullBlocking
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
|
|
||||||
class AnitubeDownloadExtractor(
|
class AnitubeDownloadExtractor(
|
||||||
|
@ -20,23 +21,33 @@ class AnitubeDownloadExtractor(
|
||||||
|
|
||||||
private fun videosFromFile4Go(url: String, quality: String): Video? {
|
private fun videosFromFile4Go(url: String, quality: String): Video? {
|
||||||
Log.d(tag, "Checking download for $url")
|
Log.d(tag, "Checking download for $url")
|
||||||
val docDownload = client.newCall(GET(url)).execute().asJsoup()
|
|
||||||
|
|
||||||
val form =
|
val newHeaders = headers.newBuilder()
|
||||||
docDownload.selectFirst("button.download")?.closest("form")
|
.set("Referer", "https://${url.toHttpUrl().host}/")
|
||||||
|
.add("Accept", "*/*")
|
||||||
|
.add("Cache-Control", "no-cache")
|
||||||
|
.add("Pragma", "no-cache")
|
||||||
|
.add("Connection", "keep-alive")
|
||||||
|
.add("Sec-Fetch-Dest", "empty")
|
||||||
|
.add("Sec-Fetch-Mode", "cors")
|
||||||
|
.add("Sec-Fetch-Site", "same-site")
|
||||||
|
.build()
|
||||||
|
|
||||||
if (form == null) {
|
val id = url.split('/').last()
|
||||||
Log.d(tag, "Download form not found for $url")
|
val idusuario =
|
||||||
return null
|
client.newCall(GET("$ADS_URL/file4go.php", headers = newHeaders))
|
||||||
}
|
.execute()
|
||||||
|
.body.string()
|
||||||
|
.substringAfter("\"publicidade\"")
|
||||||
|
.substringAfter('"')
|
||||||
|
.substringBefore('"')
|
||||||
|
|
||||||
val body = FormBody.Builder().apply {
|
val body = FormBody.Builder().apply {
|
||||||
form.select("input[name]").forEach {
|
add("id", id)
|
||||||
add(it.attr("name"), it.attr("value"))
|
add("idusuario", idusuario)
|
||||||
}
|
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
val postUrl = form.attr("action")
|
val postUrl = "https://www.file4go.net/getdownload_new_anitube.php"
|
||||||
|
|
||||||
val postHeaders = headers.newBuilder()
|
val postHeaders = headers.newBuilder()
|
||||||
.set("Referer", url)
|
.set("Referer", url)
|
||||||
|
@ -95,4 +106,8 @@ class AnitubeDownloadExtractor(
|
||||||
|
|
||||||
return videosFromDownloadPage(url, epName)
|
return videosFromDownloadPage(url, epName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val ADS_URL = "https://ads.anitube.vip"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue