From bc71ee0ee7e77803fa6a0b4b414cada6ca8c1864 Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:40:04 -0300 Subject: [PATCH 1/2] fix: Revert change to baseUrl & restore currentBaseUrl val; add runCatching block --- .../animeextension/en/uhdmovies/UHDMovies.kt | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/en/uhdmovies/src/eu/kanade/tachiyomi/animeextension/en/uhdmovies/UHDMovies.kt b/src/en/uhdmovies/src/eu/kanade/tachiyomi/animeextension/en/uhdmovies/UHDMovies.kt index e6a1e13e4f..dcc652dd09 100644 --- a/src/en/uhdmovies/src/eu/kanade/tachiyomi/animeextension/en/uhdmovies/UHDMovies.kt +++ b/src/en/uhdmovies/src/eu/kanade/tachiyomi/animeextension/en/uhdmovies/UHDMovies.kt @@ -38,24 +38,29 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() { override val name = "UHD Movies" override val baseUrl by lazy { - val url = preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! - runBlocking { - withContext(Dispatchers.Default) { - client.newBuilder() - .followRedirects(false) - .build() - .newCall(GET("$url/")).execute().use { resp -> - when (resp.code) { - 301 -> { - (resp.headers["location"]?.substringBeforeLast("/") ?: url).also { - preferences.edit().putString(PREF_DOMAIN_KEY, it).apply() + preferences.getString(PREF_DOMAIN_KEY, PREF_DOMAIN_DEFAULT)!! + } + + private val currentBaseUrl by lazy { + runCatching { + runBlocking { + withContext(Dispatchers.Default) { + client.newBuilder() + .followRedirects(false) + .build() + .newCall(GET("$baseUrl/")).execute().use { resp -> + when (resp.code) { + 301 -> { + (resp.headers["location"]?.substringBeforeLast("/") ?: baseUrl).also { + preferences.edit().putString(PREF_DOMAIN_KEY, it).apply() + } } + else -> baseUrl } - else -> url } - } + } } - } + }.getOrDefault(baseUrl) } override val lang = "en" @@ -71,7 +76,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() { } // ============================== Popular =============================== - override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/page/$page/") + override fun popularAnimeRequest(page: Int): Request = GET("$currentBaseUrl/page/$page/") override fun popularAnimeSelector(): String = "div#content div.gridlove-posts > div.layout-masonry" @@ -97,7 +102,7 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() { // =============================== Search =============================== override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request { val cleanQuery = query.replace(" ", "+").lowercase() - return GET("$baseUrl/page/$page/?s=$cleanQuery") + return GET("$currentBaseUrl/page/$page/?s=$cleanQuery") } override fun searchAnimeSelector(): String = popularAnimeSelector() @@ -116,6 +121,8 @@ class UHDMovies : ConfigurableAnimeSource, ParsedAnimeHttpSource() { } // ============================== Episodes ============================== + override fun episodeListRequest(anime: SAnime) = GET(currentBaseUrl + anime.url, headers) + private fun Regex.firstValue(text: String) = find(text)?.groupValues?.get(1)?.let { Pair(text, it) } From 21a58b72467f3dfa782a829ac5e340148e95e7da Mon Sep 17 00:00:00 2001 From: Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:40:19 -0300 Subject: [PATCH 2/2] chore: Bump version --- src/en/uhdmovies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/en/uhdmovies/build.gradle b/src/en/uhdmovies/build.gradle index a9e18db9c8..718450cf3b 100644 --- a/src/en/uhdmovies/build.gradle +++ b/src/en/uhdmovies/build.gradle @@ -8,7 +8,7 @@ ext { extName = 'UHD Movies' pkgNameSuffix = 'en.uhdmovies' extClass = '.UHDMovies' - extVersionCode = 18 + extVersionCode = 19 libVersion = '13' }