AllAnime: update url (#16948)

This commit is contained in:
AwkwardPeak7 2023-07-01 19:02:50 +05:00 committed by GitHub
parent 67c01b56aa
commit 9de0f461b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 26 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'AllAnime'
pkgNameSuffix = 'en.allanime'
extClass = '.AllAnime'
extVersionCode = 4
extVersionCode = 5
}
apply from: "$rootDir/common.gradle"

View File

@ -8,7 +8,7 @@ import androidx.preference.SwitchPreferenceCompat
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.network.interceptor.rateLimitHost
import eu.kanade.tachiyomi.network.interceptor.rateLimit
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
@ -20,7 +20,6 @@ import eu.kanade.tachiyomi.util.asJsoup
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
@ -50,11 +49,9 @@ class AllAnime : ConfigurableSource, HttpSource() {
private val preferences: SharedPreferences =
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
private val domain = preferences.domainPref
override val baseUrl = "https://allanime.ai"
override val baseUrl = "https://$domain"
private val apiUrl = "https://api.$domain/allanimeapi"
private val apiUrl = "https://api.allanime.day/api"
override val client: OkHttpClient = network.cloudflareClient.newBuilder()
.addInterceptor { chain ->
@ -75,7 +72,7 @@ class AllAnime : ConfigurableSource, HttpSource() {
.build(),
)
}
.rateLimitHost(apiUrl.toHttpUrl(), 1)
.rateLimit(1)
.build()
override fun headersBuilder() = super.headersBuilder()
@ -317,15 +314,6 @@ class AllAnime : ConfigurableSource, HttpSource() {
}
override fun setupPreferenceScreen(screen: PreferenceScreen) {
ListPreference(screen.context).apply {
key = DOMAIN_PREF
title = "Preferred domain"
entries = arrayOf("allanime.to", "allanime.co")
entryValues = arrayOf("allanime.to", "allanime.co")
setDefaultValue(DOMAIN_PREF_DEFAULT)
summary = "Requires App Restart"
}.let { screen.addPreference(it) }
ListPreference(screen.context).apply {
key = IMAGE_QUALITY_PREF
title = "Image Quality"
@ -351,9 +339,6 @@ class AllAnime : ConfigurableSource, HttpSource() {
}.let { screen.addPreference(it) }
}
private val SharedPreferences.domainPref
get() = getString(DOMAIN_PREF, DOMAIN_PREF_DEFAULT)!!
private val SharedPreferences.titlePref
get() = getString(TITLE_PREF, TITLE_PREF_DEFAULT)
@ -379,8 +364,6 @@ class AllAnime : ConfigurableSource, HttpSource() {
val titleSpecialCharactersRegex = Regex("[^a-z\\d]+")
private val imageUrlFromPageRegex = Regex("selectedPicturesServer:\\[\\{.*?url:\"(.*?)\".*?\\}\\]")
private const val DOMAIN_PREF = "pref_domain"
private const val DOMAIN_PREF_DEFAULT = "allanime.to"
private const val TITLE_PREF = "pref_title"
private const val TITLE_PREF_DEFAULT = "romaji"
private const val SHOW_ADULT_PREF = "pref_adult"

View File

@ -84,10 +84,13 @@ data class ApiMangaDetailsResponse(
thumbnail_url = thumbnail?.parseThumbnailUrl()
description = this@Manga.description?.parseDescription()
if (!altNames.isNullOrEmpty()) {
description += altNames.joinToString(
prefix = "\n\nAlternative Names:\n* ",
separator = "\n* ",
) { it.trim() }
if (description.isNullOrEmpty()) {
description = "Alternative Titles:\n"
} else {
description += "\n\nAlternative Titles:\n"
}
description += altNames.joinToString("\n") { "${it.trim()}" }
}
if (authors?.isNotEmpty() == true) {
author = authors.first().trim()