From c04984b89b3df17e64eb447705b4c55abbd027c2 Mon Sep 17 00:00:00 2001 From: nicki <72807749+curche@users.noreply.github.com> Date: Wed, 6 Oct 2021 15:36:37 +0530 Subject: [PATCH] [Komga] Fix link to WebView/Share (#9361) * use the correct link for viewing in browser api url on browser just provides a json. For viewing in browser, we need the normal url instead * just use `substringAfter` was trying out another way using `substringAfterLast` but dropped that. Now `substringAfterLast` isn't required and `substringAfter` suffices * make fetchMangaDetails not use mangaDetailsRequest internally, `fetchMangaDetails` uses `mangaDetailsRequest` to create a new call. However, since `mangaDetailsRequest` is now fixed to use a normal browser URL rather than the API URL, it no longer works for `fetchMangaDetails`. So, it needs to be manually overriden to make its own call * use hardcoded ID values instead of computing this was done because of the following: - IDs are same as before - no need to rely on calculation to be correct everytime - avoids unnecessary copy of base class code - sets it in the constructor itself * increment komga.extVersionCode also update CHANGELOG with list of changes * linting and remove unused imports * Revert "linting and remove unused imports" This reverts commit e13396badef53fced2700266182bbf53a67124cf. * Revert "use hardcoded ID values instead of computing" This reverts commit 44f063904d5969fb6d90c9ffad5c33aff50b995f. * refactor `mangaDetailsRequest` Do it in a simpler manner without having to create another variable Co-authored-by: Gauthier Co-authored-by: Gauthier --- src/all/komga/CHANGELOG.md | 21 +++++++++++++++++++ src/all/komga/build.gradle | 2 +- .../tachiyomi/extension/all/komga/Komga.kt | 12 ++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/all/komga/CHANGELOG.md b/src/all/komga/CHANGELOG.md index aa32fe8ab..b0c30f185 100644 --- a/src/all/komga/CHANGELOG.md +++ b/src/all/komga/CHANGELOG.md @@ -1,3 +1,24 @@ +## 1.2.33 + +Minimum Komga version required: `0.113.0` + +### Fix + +* Open in WebView and Share options now open regular browser link instead of showing JSON +* Note that Komga cannot be viewed using System WebView since there is no login prompt + However, opening in a regular browser works. + +## 1.2.32 + +Minimum Komga version required: `0.113.0` + +### Fix + +* Source language, conventionally set to "en", is now changed to "all" +* Downloaded files, if any, will have to be moved to new location + - `Komga (EN)` to `Komga (ALL)` + - `Komga (3) (EN)` to `Komga (3) (ALL)` + ## 1.2.31 Minimum Komga version required: `0.113.0` diff --git a/src/all/komga/build.gradle b/src/all/komga/build.gradle index 1cc7000b6..41805e14a 100644 --- a/src/all/komga/build.gradle +++ b/src/all/komga/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Komga' pkgNameSuffix = 'all.komga' extClass = '.KomgaFactory' - extVersionCode = 32 + extVersionCode = 33 } dependencies { diff --git a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt index d4df72492..e01414396 100644 --- a/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt +++ b/src/all/komga/src/eu/kanade/tachiyomi/extension/all/komga/Komga.kt @@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.extension.all.komga.dto.PageWrapperDto import eu.kanade.tachiyomi.extension.all.komga.dto.ReadListDto import eu.kanade.tachiyomi.extension.all.komga.dto.SeriesDto import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList @@ -33,6 +34,7 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import okhttp3.ResponseBody +import rx.Observable import rx.Single import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers @@ -175,8 +177,16 @@ open class Komga(suffix: String = "") : ConfigurableSource, HttpSource() { override fun searchMangaParse(response: Response): MangasPage = processSeriesPage(response) + override fun fetchMangaDetails(manga: SManga): Observable { + return client.newCall(GET(manga.url, headers)) + .asObservableSuccess() + .map { response -> + mangaDetailsParse(response).apply { initialized = true } + } + } + override fun mangaDetailsRequest(manga: SManga): Request = - GET(manga.url, headers) + GET(manga.url.replaceFirst("api/v1/", "", ignoreCase = true), headers) override fun mangaDetailsParse(response: Response): SManga { val responseBody = response.body