parent
b78a30cd62
commit
4ba9118ce3
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Tapas'
|
extName = 'Tapas'
|
||||||
pkgNameSuffix = 'en.tapastic'
|
pkgNameSuffix = 'en.tapastic'
|
||||||
extClass = '.Tapastic'
|
extClass = '.Tapastic'
|
||||||
extVersionCode = 12
|
extVersionCode = 13
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.extension.en.tapastic
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.webkit.CookieManager
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
@ -88,26 +89,45 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
|
|
||||||
override val client: OkHttpClient = super.client.newBuilder()
|
override val client: OkHttpClient = super.client.newBuilder()
|
||||||
.cookieJar(
|
.cookieJar(
|
||||||
|
// Syncs okhttp with webview cookies, allowing logged-in users do logged-in stuff
|
||||||
object : CookieJar {
|
object : CookieJar {
|
||||||
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {}
|
private val webviewCookieManager = CookieManager.getInstance()
|
||||||
|
|
||||||
|
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||||
|
for (cookie in cookies) {
|
||||||
|
webviewCookieManager.setCookie(url.toString(), cookie.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun loadForRequest(url: HttpUrl): MutableList<Cookie> {
|
override fun loadForRequest(url: HttpUrl): MutableList<Cookie> {
|
||||||
return ArrayList<Cookie>().apply {
|
val cookiesString = webviewCookieManager.getCookie(url.toString())
|
||||||
add(
|
|
||||||
Cookie.Builder()
|
if (cookiesString != null && cookiesString.isNotEmpty()) {
|
||||||
.domain("tapas.io")
|
val cookieHeaders = cookiesString.split("; ").toList()
|
||||||
.path("/")
|
val cookies = mutableListOf<Cookie>()
|
||||||
.name("birthDate")
|
for (header in cookieHeaders) {
|
||||||
.value("1994-01-01")
|
cookies.add(Cookie.parse(url, header)!!)
|
||||||
.build()
|
}
|
||||||
)
|
// Adds age verification cookies to access mature comics
|
||||||
add(
|
return cookies.apply {
|
||||||
Cookie.Builder()
|
add(
|
||||||
.domain("tapas.io")
|
Cookie.Builder()
|
||||||
.path("/")
|
.domain("tapas.io")
|
||||||
.name("adjustedBirthDate")
|
.path("/")
|
||||||
.value("1994-01-01")
|
.name("birthDate")
|
||||||
.build()
|
.value("1994-01-01")
|
||||||
)
|
.build()
|
||||||
|
)
|
||||||
|
add(
|
||||||
|
Cookie.Builder()
|
||||||
|
.domain("tapas.io")
|
||||||
|
.path("/")
|
||||||
|
.name("adjustedBirthDate")
|
||||||
|
.value("1994-01-01")
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mutableListOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,6 +189,11 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Append sort if category = ALL
|
||||||
|
if (url.toString().contains("b=ALL")) {
|
||||||
|
val sortFilter = filterList.find { it is SortFilter } as SortFilter
|
||||||
|
sortFilter.addToUri(url)
|
||||||
|
}
|
||||||
// Append page number
|
// Append page number
|
||||||
url.addQueryParameter("pageNumber", page.toString())
|
url.addQueryParameter("pageNumber", page.toString())
|
||||||
return GET(url.toString())
|
return GET(url.toString())
|
||||||
|
@ -272,18 +297,17 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
// Tapastic does not support genre filtering and text search at the same time
|
// Tapastic does not support genre filtering and text search at the same time
|
||||||
Filter.Header("NOTE: All filters ignored if using text search!"),
|
Filter.Header("NOTE: All filters ignored if using text search!"),
|
||||||
Filter.Separator(),
|
Filter.Separator(),
|
||||||
|
Filter.Header("Sort: Only applied when category is All"),
|
||||||
|
SortFilter(),
|
||||||
|
Filter.Separator(),
|
||||||
CategoryFilter(),
|
CategoryFilter(),
|
||||||
GenreFilter(),
|
GenreFilter(),
|
||||||
StatusFilter(),
|
StatusFilter(),
|
||||||
Filter.Header("Sort is ignored when category filter is active!"),
|
|
||||||
SortFilter(),
|
|
||||||
Filter.Separator(),
|
Filter.Separator(),
|
||||||
Filter.Header("Mature filters"),
|
Filter.Header("Mature filters"),
|
||||||
MatureFilter("Show Mature Results Only"),
|
MatureFilter("Show Mature Results Only"),
|
||||||
MatureCategoryFilter(),
|
MatureCategoryFilter(),
|
||||||
MatureGenreFilter(),
|
MatureGenreFilter()
|
||||||
Filter.Header("Sort is ignored when category filter is active!"),
|
|
||||||
MatureSortFilter(),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private class CategoryFilter : UriSelectFilter(
|
private class CategoryFilter : UriSelectFilter(
|
||||||
|
@ -298,7 +322,6 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
Pair("BINGE", "Binge"),
|
Pair("BINGE", "Binge"),
|
||||||
Pair("ORIGINAL", "Tapas Originals")
|
Pair("ORIGINAL", "Tapas Originals")
|
||||||
),
|
),
|
||||||
firstIsUnspecified = false,
|
|
||||||
defaultValue = 1
|
defaultValue = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -335,17 +358,6 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
private class SortFilter : UriSelectFilter(
|
|
||||||
"Sort",
|
|
||||||
false,
|
|
||||||
"s",
|
|
||||||
arrayOf(
|
|
||||||
Pair("DATE", "Date"),
|
|
||||||
Pair("LIKE", "Likes"),
|
|
||||||
Pair("SUBSCRIBE", "Subscribers")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
private class MatureFilter(name: String) : Filter.CheckBox(name)
|
private class MatureFilter(name: String) : Filter.CheckBox(name)
|
||||||
|
|
||||||
private class MatureCategoryFilter : UriSelectFilter(
|
private class MatureCategoryFilter : UriSelectFilter(
|
||||||
|
@ -357,13 +369,12 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
Pair("POPULAR", "Popular"),
|
Pair("POPULAR", "Popular"),
|
||||||
Pair("FRESH", "Fresh"),
|
Pair("FRESH", "Fresh"),
|
||||||
),
|
),
|
||||||
firstIsUnspecified = false,
|
|
||||||
defaultValue = 1
|
defaultValue = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
private class MatureGenreFilter : UriSelectFilter(
|
private class MatureGenreFilter : UriSelectFilter(
|
||||||
"Genre",
|
"Genre",
|
||||||
false,
|
true,
|
||||||
"g",
|
"g",
|
||||||
arrayOf(
|
arrayOf(
|
||||||
Pair("0", "Any"),
|
Pair("0", "Any"),
|
||||||
|
@ -376,16 +387,19 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
private class MatureSortFilter : UriSelectFilter(
|
private class SortFilter(
|
||||||
"Sort",
|
name: String = "Sort by",
|
||||||
true,
|
var vals: Array<Pair<String, String>> = arrayOf(
|
||||||
"s",
|
|
||||||
arrayOf(
|
|
||||||
Pair("DATE", "Date"),
|
Pair("DATE", "Date"),
|
||||||
Pair("LIKE", "Likes"),
|
Pair("LIKE", "Likes"),
|
||||||
Pair("SUBSCRIBE", "Subscribers")
|
Pair("SUBSCRIBE", "Subscribers")
|
||||||
)
|
),
|
||||||
)
|
defaultValue: Int = 0
|
||||||
|
) : Filter.Select<String>(name, vals.map { it.second }.toTypedArray(), defaultValue) {
|
||||||
|
fun addToUri(uri: HttpUrl.Builder) {
|
||||||
|
uri.addQueryParameter("s", vals[state].first)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
* Class that creates a select filter. Each entry in the dropdown has a name and a display name.
|
||||||
|
@ -398,7 +412,7 @@ class Tapastic : ConfigurableSource, ParsedHttpSource() {
|
||||||
override val isMature: Boolean,
|
override val isMature: Boolean,
|
||||||
val uriParam: String,
|
val uriParam: String,
|
||||||
val vals: Array<Pair<String, String>>,
|
val vals: Array<Pair<String, String>>,
|
||||||
val firstIsUnspecified: Boolean = true,
|
val firstIsUnspecified: Boolean = false,
|
||||||
defaultValue: Int = 0
|
defaultValue: Int = 0
|
||||||
) :
|
) :
|
||||||
Filter.Select<String>(displayName, vals.map { it.second }.toTypedArray(), defaultValue),
|
Filter.Select<String>(displayName, vals.map { it.second }.toTypedArray(), defaultValue),
|
||||||
|
|
Loading…
Reference in New Issue