From 5093e6a5fac3858a13eb2cc62715a788464698ee Mon Sep 17 00:00:00 2001 From: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:44:48 -0300 Subject: [PATCH] Update to extensions-lib 1.4 (#15298) * Update to extensions-lib 1.4. * Fix a syntax error in NM. * Add UpdateStrategy to Nana as well. --- CONTRIBUTING.md | 4 +- common.gradle | 2 +- gradle/libs.versions.toml | 2 +- .../tachiyomi/multisrc/bilibili/Bilibili.kt | 24 +++++------- .../tachiyomi/multisrc/heancms/HeanCms.kt | 20 +++------- .../extension/all/ehentai/EHentai.kt | 2 + .../extension/all/mangadex/MangaDex.kt | 20 +++------- .../extension/all/mangadex/MangaDexHelper.kt | 6 +-- .../extension/all/mangaplus/MangaPlus.kt | 37 ++++++++----------- .../extension/all/mangaup/MangaUp.kt | 22 +++++------ .../extension/all/nhentai/NHentai.kt | 2 + .../tachiyomi/extension/en/nana/Nana.kt | 2 + .../extension/pt/argosscan/ArgosScan.kt | 16 +++----- .../tachiyomi/extension/pt/hqnow/HQNow.kt | 16 ++------ .../extension/pt/mangavibe/MangaVibe.kt | 12 +----- .../extension/pt/nixmangas/NixMangas.kt | 18 +++------ .../extension/pt/saikaiscan/SaikaiScan.kt | 14 ++----- .../tachiyomi/extension/pt/taosect/TaoSect.kt | 18 ++++----- 18 files changed, 86 insertions(+), 151 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 08cfcd5c2..478755965 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -236,10 +236,10 @@ apply from: "$rootDir/common.gradle" | `pkgNameSuffix` | A unique suffix added to `eu.kanade.tachiyomi.extension`. The language and the site name should be enough. Remember your extension code implementation must be placed in this package. | | `extClass` | Points to the class that implements `Source`. You can use a relative path starting with a dot (the package name is the base path). This is used to find and instantiate the source(s). | | `extVersionCode` | The extension version code. This must be a positive integer and incremented with any change to the code. | -| `libVersion` | (Optional, defaults to `1.3`) The version of the [extensions library](https://github.com/tachiyomiorg/extensions-lib) used. | +| `libVersion` | (Optional, defaults to `1.4`) The version of the [extensions library](https://github.com/tachiyomiorg/extensions-lib) used. | | `isNsfw` | (Optional, defaults to `false`) Flag to indicate that a source contains NSFW content. | -The extension's version name is generated automatically by concatenating `libVersion` and `extVersionCode`. With the example used above, the version would be `1.3.1`. +The extension's version name is generated automatically by concatenating `libVersion` and `extVersionCode`. With the example used above, the version would be `1.4.1`. ### Core dependencies diff --git a/common.gradle b/common.gradle index 10f4c7cb8..b4b4e061d 100644 --- a/common.gradle +++ b/common.gradle @@ -22,7 +22,7 @@ android { targetSdkVersion AndroidConfig.targetSdk applicationIdSuffix pkgNameSuffix versionCode extVersionCode - versionName project.ext.properties.getOrDefault("libVersion", "1.3") + ".$extVersionCode" + versionName project.ext.properties.getOrDefault("libVersion", "1.4") + ".$extVersionCode" setProperty("archivesBaseName", "tachiyomi-$pkgNameSuffix-v$versionName") def readmes = project.projectDir.listFiles({ File file -> file.name == "README.md" || file.name == "CHANGELOG.md" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d84641ed3..0e910b91e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version. gradle-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_version" } gradle-kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version = "3.6.0" } -tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "1.3.2" } +tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "1.4.0" } kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin_version" } kotlin-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization_version" } diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt index ceb755e6e..9589afa47 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/bilibili/Bilibili.kt @@ -5,7 +5,6 @@ import android.content.SharedPreferences import androidx.preference.ListPreference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.network.POST -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.FilterList @@ -29,7 +28,6 @@ import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response import org.jsoup.Jsoup -import rx.Observable import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy @@ -98,7 +96,8 @@ abstract class Bilibili( override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { ID_SEARCH_PATTERN.matchEntire(query)?.let { val (id) = it.destructured - return mangaDetailsApiRequest("/detail/mc$id") + val temporaryManga = SManga.create().apply { url = "/detail/mc$id" } + return mangaDetailsRequest(temporaryManga) } val price = filters.firstInstanceOrNull()?.state ?: 0 @@ -177,23 +176,16 @@ abstract class Bilibili( url = "/detail/mc$comicId" } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga.url)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(mangaUrl: String): Request { - val comicId = mangaUrl.substringAfterLast("/mc").toInt() + override fun mangaDetailsRequest(manga: SManga): Request { + val comicId = manga.url.substringAfterLast("/mc").toInt() val jsonPayload = buildJsonObject { put("comic_id", comicId) } val requestBody = jsonPayload.toString().toRequestBody(JSON_MEDIA_TYPE) val newHeaders = headersBuilder() - .set("Referer", baseUrl + mangaUrl) + .set("Referer", baseUrl + manga.url) .build() val apiUrl = "$baseUrl/$API_COMIC_V1_COMIC_ENDPOINT/ComicDetail".toHttpUrl() @@ -233,7 +225,7 @@ abstract class Bilibili( } // Chapters are available in the same url of the manga details. - override fun chapterListRequest(manga: SManga): Request = mangaDetailsApiRequest(manga.url) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga) override fun chapterListParse(response: Response): List { val result = response.parseAs() @@ -253,6 +245,8 @@ abstract class Bilibili( url = "/mc$comicId/${episode.id}" } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request = imageIndexRequest(chapter.url, "") override fun pageListParse(response: Response): List = imageIndexParse(response) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt index dd23fe088..f04909192 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/heancms/HeanCms.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.multisrc.heancms import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.source.model.Filter import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -184,26 +183,17 @@ abstract class HeanCms( return MangasPage(mangaList, hasNextPage = false) } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(seriesDetailsRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } - - override fun mangaDetailsRequest(manga: SManga): Request { + override fun getMangaUrl(manga: SManga): String { val seriesSlug = manga.url .substringAfterLast("/") .replace(TIMESTAMP_REGEX, "") val currentSlug = seriesSlugMap?.get(seriesSlug)?.slug ?: seriesSlug - return GET("$baseUrl/series/$currentSlug", headers) + return "$baseUrl/series/$currentSlug" } - private fun seriesDetailsRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { val seriesSlug = manga.url .substringAfterLast("/") .replace(TIMESTAMP_REGEX, "") @@ -231,7 +221,7 @@ abstract class HeanCms( } } - override fun chapterListRequest(manga: SManga): Request = seriesDetailsRequest(manga) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga) override fun chapterListParse(response: Response): List { val result = response.parseAs() @@ -244,6 +234,8 @@ abstract class HeanCms( .reversed() } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { val chapterId = chapter.url.substringAfterLast("#") diff --git a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt index 26f9668a1..c5e6f6788 100644 --- a/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt +++ b/src/all/ehentai/src/eu/kanade/tachiyomi/extension/all/ehentai/EHentai.kt @@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.asJsoup import okhttp3.CacheControl @@ -302,6 +303,7 @@ abstract class EHentai( // Copy metadata to manga SManga.create().apply { copyTo(this) + update_strategy = UpdateStrategy.ONLY_FETCH_ONCE } } } diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt index 9a5e8c80a..0ddf9c080 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDex.kt @@ -367,22 +367,12 @@ abstract class MangaDex(final override val lang: String, private val dexLang: St // Manga Details section - // Workaround to allow "Open in WebView" to show a webpage instead of JSON. - // TODO: Replace with getMangaUrl when the repository is using extensions-lib 1.4 - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(apiMangaDetailsRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } - - override fun mangaDetailsRequest(manga: SManga): Request { + override fun getMangaUrl(manga: SManga): String { // TODO: Remove once redirect for /manga is fixed. val title = manga.title val url = "${baseUrl}${manga.url.replace("manga", "title")}" - val shareUrl = "$url/" + helper.titleToSlug(title) - return GET(shareUrl, headers) + + return "$url/" + helper.titleToSlug(title) } /** @@ -390,7 +380,7 @@ abstract class MangaDex(final override val lang: String, private val dexLang: St * * @throws Exception if the url is the old format so people migrate */ - private fun apiMangaDetailsRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { if (!helper.containsUuid(manga.url.trim())) { throw Exception(helper.intl.migrateWarning) } @@ -547,6 +537,8 @@ abstract class MangaDex(final override val lang: String, private val dexLang: St .map(helper::createChapter) } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { if (!helper.containsUuid(chapter.url)) { throw Exception(helper.intl.migrateWarning) diff --git a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt index 4fcf770e1..dde19faa3 100644 --- a/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt +++ b/src/all/mangadex/src/eu/kanade/tachiyomi/extension/all/mangadex/MangaDexHelper.kt @@ -269,9 +269,9 @@ class MangaDexHelper(lang: String) { val titleMap = mangaDataDto.attributes!!.title val dirtyTitle = titleMap.values.firstOrNull() // use literally anything from title as first resort - ?: mangaDataDto.attributes.altTitles - .find { (it[lang] ?: it["en"]) !== null } - ?.values?.singleOrNull() // find something else from alt titles + ?: mangaDataDto.attributes.altTitles + .find { (it[lang] ?: it["en"]) !== null } + ?.values?.singleOrNull() // find something else from alt titles title = (dirtyTitle ?: "").removeEntitiesAndMarkdown() coverFileName?.let { diff --git a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt index e40dd8912..ffef32691 100644 --- a/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt +++ b/src/all/mangaplus/src/eu/kanade/tachiyomi/extension/all/mangaplus/MangaPlus.kt @@ -6,7 +6,6 @@ import androidx.preference.ListPreference import androidx.preference.PreferenceScreen import androidx.preference.SwitchPreferenceCompat import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.FilterList @@ -132,9 +131,9 @@ class MangaPlus( override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (query.matches(ID_SEARCH_PATTERN)) { - return titleDetailsRequest(query.removePrefix(PREFIX_ID_SEARCH)) + return mangaDetailsRequest(query.removePrefix(PREFIX_ID_SEARCH)) } else if (query.matches(CHAPTER_ID_SEARCH_PATTERN)) { - return mangaViewerRequest(query.removePrefix(PREFIX_CHAPTER_ID_SEARCH)) + return pageListRequest(query.removePrefix(PREFIX_CHAPTER_ID_SEARCH)) } val newHeaders = headersBuilder() @@ -170,7 +169,7 @@ class MangaPlus( val cachedTitle = titleCache?.get(titleId) val title = cachedTitle?.toSManga() ?: run { - val titleRequest = titleDetailsRequest(titleId.toString()) + val titleRequest = mangaDetailsRequest(titleId.toString()) val titleResult = client.newCall(titleRequest).execute().asMangaPlusResponse() checkNotNull(titleResult.success) { @@ -201,7 +200,12 @@ class MangaPlus( return MangasPage(searchResults.map(Title::toSManga), hasNextPage = false) } - private fun titleDetailsRequest(mangaUrl: String): Request { + // Remove the '#' and map to the new url format used in website. + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url.substring(1) + + override fun mangaDetailsRequest(manga: SManga): Request = mangaDetailsRequest(manga.url) + + private fun mangaDetailsRequest(mangaUrl: String): Request { val titleId = mangaUrl.substringAfterLast("/") val newHeaders = headersBuilder() @@ -211,20 +215,6 @@ class MangaPlus( return GET("$API_URL/title_detail?title_id=$titleId&format=json", newHeaders) } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(titleDetailsRequest(manga.url)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } - - override fun mangaDetailsRequest(manga: SManga): Request { - // Remove the '#' and map to the new url format used in website. - return GET(baseUrl + manga.url.substring(1), headers) - } - override fun mangaDetailsParse(response: Response): SManga { val result = response.asMangaPlusResponse() @@ -245,7 +235,7 @@ class MangaPlus( return titleDetails.toSManga() } - override fun chapterListRequest(manga: SManga): Request = titleDetailsRequest(manga.url) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga.url) override fun chapterListParse(response: Response): List { val result = response.asMangaPlusResponse() @@ -269,13 +259,16 @@ class MangaPlus( .map(Chapter::toSChapter) } + // Remove the '#' and map to the new url format used in website. + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url.substring(1) + override fun pageListRequest(chapter: SChapter): Request { val chapterId = chapter.url.substringAfterLast("/") - return mangaViewerRequest(chapterId) + return pageListRequest(chapterId) } - private fun mangaViewerRequest(chapterId: String): Request { + private fun pageListRequest(chapterId: String): Request { val newHeaders = headersBuilder() .set("Referer", "$baseUrl/viewer/$chapterId") .build() diff --git a/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt b/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt index 1427db52f..6ddd22300 100644 --- a/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt +++ b/src/all/mangaup/src/eu/kanade/tachiyomi/extension/all/mangaup/MangaUp.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.extension.all.mangaup import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -63,7 +62,7 @@ class MangaUp(override val lang: String) : HttpSource() { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (query.startsWith(PREFIX_ID_SEARCH) && query.matches(ID_SEARCH_PATTERN)) { - return titleDetailsRequest(query.removePrefix(PREFIX_ID_SEARCH)) + return mangaDetailsRequest(query.removePrefix(PREFIX_ID_SEARCH)) } val apiUrl = "$API_URL/manga/search".toHttpUrl().newBuilder() @@ -98,7 +97,11 @@ class MangaUp(override val lang: String) : HttpSource() { return MangasPage(titles.map(MangaUpTitle::toSManga), hasNextPage = false) } - private fun titleDetailsRequest(mangaUrl: String): Request { + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url + + override fun mangaDetailsRequest(manga: SManga): Request = mangaDetailsRequest(manga.url) + + private fun mangaDetailsRequest(mangaUrl: String): Request { val titleId = mangaUrl.substringAfterLast("/") val apiUrl = "$API_URL/manga/detail".toHttpUrl().newBuilder() @@ -110,20 +113,11 @@ class MangaUp(override val lang: String) : HttpSource() { return GET(apiUrl, headers) } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(titleDetailsRequest(manga.url)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } - override fun mangaDetailsParse(response: Response): SManga { return response.parseAs().toSManga() } - override fun chapterListRequest(manga: SManga): Request = titleDetailsRequest(manga.url) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga.url) override fun chapterListParse(response: Response): List { val titleId = response.request.url.queryParameter("title_id")!!.toInt() @@ -132,6 +126,8 @@ class MangaUp(override val lang: String) : HttpSource() { .map { it.toSChapter(titleId) } } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { val chapterId = chapter.url.substringAfterLast("/") diff --git a/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt b/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt index 21becec20..7e511cb9e 100644 --- a/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt +++ b/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHentai.kt @@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Headers @@ -222,6 +223,7 @@ open class NHentai( .plus("Favorited by: ${document.select("div#info i.fa-heart + span span").text().removeSurrounding("(", ")")}\n") .plus(getTagDescription(document)) genre = getTags(document) + update_strategy = UpdateStrategy.ONLY_FETCH_ONCE } } diff --git a/src/en/nana/src/eu/kanade/tachiyomi/extension/en/nana/Nana.kt b/src/en/nana/src/eu/kanade/tachiyomi/extension/en/nana/Nana.kt index 14fcf57ab..affc160ab 100644 --- a/src/en/nana/src/eu/kanade/tachiyomi/extension/en/nana/Nana.kt +++ b/src/en/nana/src/eu/kanade/tachiyomi/extension/en/nana/Nana.kt @@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.Call import okhttp3.HttpUrl.Companion.toHttpUrl @@ -86,6 +87,7 @@ class Nana : ParsedHttpSource() { .joinToString { it.text() } status = SManga.COMPLETED + update_strategy = UpdateStrategy.ONLY_FETCH_ONCE initialized = true } diff --git a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt index af1d6606a..cb7c503e0 100644 --- a/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt +++ b/src/pt/argosscan/src/eu/kanade/tachiyomi/extension/pt/argosscan/ArgosScan.kt @@ -7,7 +7,6 @@ import androidx.preference.EditTextPreference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.FilterList @@ -127,16 +126,9 @@ class ArgosScan : HttpSource(), ConfigurableSource { override fun searchMangaParse(response: Response): MangasPage = popularMangaParse(response) - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { val mangaId = manga.url.substringAfter("obras/").toInt() val payload = buildMangaDetailsQueryPayload(mangaId) @@ -172,7 +164,7 @@ class ArgosScan : HttpSource(), ConfigurableSource { genre = project.tags.orEmpty().sortedBy(ArgosTagDto::name).joinToString { it.name } } - override fun chapterListRequest(manga: SManga): Request = mangaDetailsApiRequest(manga) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga) override fun chapterListParse(response: Response): List { val result = response.parseAs>() @@ -192,6 +184,8 @@ class ArgosScan : HttpSource(), ConfigurableSource { url = "/leitor/${chapter.id}" } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { if (chapter.url.removePrefix("/leitor/").toIntOrNull() != null) { throw Exception(REFRESH_WARNING) diff --git a/src/pt/hqnow/src/eu/kanade/tachiyomi/extension/pt/hqnow/HQNow.kt b/src/pt/hqnow/src/eu/kanade/tachiyomi/extension/pt/hqnow/HQNow.kt index 7fb7b771b..718c124b7 100644 --- a/src/pt/hqnow/src/eu/kanade/tachiyomi/extension/pt/hqnow/HQNow.kt +++ b/src/pt/hqnow/src/eu/kanade/tachiyomi/extension/pt/hqnow/HQNow.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.extension.pt.hqnow import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -164,16 +163,9 @@ class HQNow : HttpSource() { return MangasPage(comicList, hasNextPage = false) } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { val comicBookId = manga.url.substringAfter("/hq/").substringBefore("/") val query = buildQuery { @@ -219,7 +211,7 @@ class HQNow : HttpSource() { status = comicBook.status.orEmpty().toStatus() } - override fun chapterListRequest(manga: SManga): Request = mangaDetailsApiRequest(manga) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga) override fun chapterListParse(response: Response): List { val result = json.parseToJsonElement(response.body!!.string()).jsonObject @@ -239,7 +231,7 @@ class HQNow : HttpSource() { "/chapter/${chapter.id}/page/1" } - // Pages + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url override fun pageListRequest(chapter: SChapter): Request { val chapterId = chapter.url.substringAfter("/chapter/").substringBefore("/") diff --git a/src/pt/mangavibe/src/eu/kanade/tachiyomi/extension/pt/mangavibe/MangaVibe.kt b/src/pt/mangavibe/src/eu/kanade/tachiyomi/extension/pt/mangavibe/MangaVibe.kt index f4d56a97e..9e792a928 100644 --- a/src/pt/mangavibe/src/eu/kanade/tachiyomi/extension/pt/mangavibe/MangaVibe.kt +++ b/src/pt/mangavibe/src/eu/kanade/tachiyomi/extension/pt/mangavibe/MangaVibe.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.extension.pt.mangavibe import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -160,16 +159,9 @@ class MangaVibe : HttpSource() { private fun searchMangaFromObject(comic: MangaVibeComicDto): SManga = popularMangaFromObject(comic) - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { val comicId = manga.url.substringAfter("/manga/") .substringBefore("/") diff --git a/src/pt/nixmangas/src/eu/kanade/tachiyomi/extension/pt/nixmangas/NixMangas.kt b/src/pt/nixmangas/src/eu/kanade/tachiyomi/extension/pt/nixmangas/NixMangas.kt index 7c8b4ac01..08e97d32b 100644 --- a/src/pt/nixmangas/src/eu/kanade/tachiyomi/extension/pt/nixmangas/NixMangas.kt +++ b/src/pt/nixmangas/src/eu/kanade/tachiyomi/extension/pt/nixmangas/NixMangas.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.extension.pt.nixmangas import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -84,19 +83,12 @@ class NixMangas : HttpSource() { return MangasPage(workList, result.mangas.hasNextPage) } - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga.url)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(mangaUrl: String): Request { + override fun mangaDetailsRequest(manga: SManga): Request { // Their API doesn't have an endpoint for the manga details, so we // use their site wrapped API instead for now. - val apiUrl = (baseUrl + mangaUrl).toHttpUrl().newBuilder() + val apiUrl = (baseUrl + manga.url).toHttpUrl().newBuilder() .addQueryParameter("_data", "routes/__app/obras/\$slug") .toString() @@ -109,7 +101,7 @@ class NixMangas : HttpSource() { return result.manga.toSManga() } - override fun chapterListRequest(manga: SManga): Request = mangaDetailsApiRequest(manga.url) + override fun chapterListRequest(manga: SManga): Request = mangaDetailsRequest(manga) override fun chapterListParse(response: Response): List { val result = response.parseAs() @@ -122,6 +114,8 @@ class NixMangas : HttpSource() { .sortedByDescending(SChapter::chapter_number) } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { val apiUrl = (baseUrl + chapter.url).toHttpUrl().newBuilder() .addQueryParameter("_data", "routes/__leitor/ler.\$manga.\$chapter") diff --git a/src/pt/saikaiscan/src/eu/kanade/tachiyomi/extension/pt/saikaiscan/SaikaiScan.kt b/src/pt/saikaiscan/src/eu/kanade/tachiyomi/extension/pt/saikaiscan/SaikaiScan.kt index adae7acc6..eec3f30a8 100644 --- a/src/pt/saikaiscan/src/eu/kanade/tachiyomi/extension/pt/saikaiscan/SaikaiScan.kt +++ b/src/pt/saikaiscan/src/eu/kanade/tachiyomi/extension/pt/saikaiscan/SaikaiScan.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.extension.pt.saikaiscan import eu.kanade.tachiyomi.network.GET -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimitHost import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -105,16 +104,9 @@ class SaikaiScan : HttpSource() { override fun searchMangaParse(response: Response): MangasPage = popularMangaParse(response) - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(storyDetailsRequest(manga)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun storyDetailsRequest(manga: SManga): Request { + override fun mangaDetailsRequest(manga: SManga): Request { val storySlug = manga.url.substringAfterLast("/") val apiHeaders = headersBuilder() @@ -164,6 +156,8 @@ class SaikaiScan : HttpSource() { .sortedByDescending(SChapter::chapter_number) } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { val releaseId = chapter.url .substringBeforeLast("/") diff --git a/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt b/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt index ed801b467..474c234c8 100644 --- a/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt +++ b/src/pt/taosect/src/eu/kanade/tachiyomi/extension/pt/taosect/TaoSect.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.extension.pt.taosect import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST -import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.interceptor.rateLimit import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.MangasPage @@ -140,7 +139,7 @@ class TaoSect : HttpSource() { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { if (query.startsWith(SLUG_PREFIX_SEARCH) && query.removePrefix(SLUG_PREFIX_SEARCH).isNotBlank()) { - return mangaDetailsApiRequest(query.removePrefix(SLUG_PREFIX_SEARCH)) + return mangaDetailsRequest(query.removePrefix(SLUG_PREFIX_SEARCH)) } val apiUrl = "$baseUrl/$API_BASE_PATH/projetos".toHttpUrl().newBuilder() @@ -160,16 +159,11 @@ class TaoSect : HttpSource() { override fun searchMangaParse(response: Response): MangasPage = popularMangaParse(response) - // Workaround to allow "Open in browser" use the real URL. - override fun fetchMangaDetails(manga: SManga): Observable { - return client.newCall(mangaDetailsApiRequest(manga.url)) - .asObservableSuccess() - .map { response -> - mangaDetailsParse(response).apply { initialized = true } - } - } + override fun getMangaUrl(manga: SManga): String = baseUrl + manga.url - private fun mangaDetailsApiRequest(mangaUrl: String): Request { + override fun mangaDetailsRequest(manga: SManga): Request = mangaDetailsRequest(manga.url) + + private fun mangaDetailsRequest(mangaUrl: String): Request { val projectSlug = mangaUrl .substringAfterLast("projeto/") .substringBefore("/") @@ -244,6 +238,8 @@ class TaoSect : HttpSource() { url = "/leitor-online/projeto/$projectSlug/${obj.slug}/" } + override fun getChapterUrl(chapter: SChapter): String = baseUrl + chapter.url + override fun pageListRequest(chapter: SChapter): Request { val projectSlug = chapter.url .substringAfter("projeto/")