From 9de0f461b9510ba02ac2bf608b48e614c89c844b Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Sat, 1 Jul 2023 19:02:50 +0500 Subject: [PATCH] AllAnime: update url (#16948) --- src/en/allanime/build.gradle | 2 +- .../extension/en/allanime/AllAnime.kt | 25 +++---------------- .../extension/en/allanime/AllAnimeDto.kt | 11 +++++--- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/en/allanime/build.gradle b/src/en/allanime/build.gradle index ff7f3a4cc..c3a5b0e58 100644 --- a/src/en/allanime/build.gradle +++ b/src/en/allanime/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'AllAnime' pkgNameSuffix = 'en.allanime' extClass = '.AllAnime' - extVersionCode = 4 + extVersionCode = 5 } apply from: "$rootDir/common.gradle" diff --git a/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnime.kt b/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnime.kt index 6b111c979..b13786d0b 100644 --- a/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnime.kt +++ b/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnime.kt @@ -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().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" diff --git a/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnimeDto.kt b/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnimeDto.kt index d60d22919..db5dabcef 100644 --- a/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnimeDto.kt +++ b/src/en/allanime/src/eu/kanade/tachiyomi/extension/en/allanime/AllAnimeDto.kt @@ -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()