diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt index 5e5ba6edb..103160a73 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventure.kt @@ -38,15 +38,13 @@ abstract class MangAdventure( "(Android ${VERSION.RELEASE}; Mobile) " + "Tachiyomi/${AppInfo.getVersionName()}" - /** The URI of the site's API. */ - private val apiUri by lazy { - Uri.parse("$baseUrl/api/v$versionId")!! - } + /** The URL of the site's API. */ + private val apiUrl by lazy { "$baseUrl/api/v2" } /** The JSON parser of the class. */ private val json by injectLazy() - override val versionId = 2 + override val versionId = 3 override val supportsLatest = true @@ -54,21 +52,13 @@ abstract class MangAdventure( super.headersBuilder().set("User-Agent", userAgent) override fun latestUpdatesRequest(page: Int) = - apiUri.buildUpon().appendEncodedPath("series").run { - appendQueryParameter("page", page.toString()) - appendQueryParameter("sort", "-latest_upload") - GET(toString(), headers) - } + GET("$apiUrl/series?page=$page&sort=-latest_upload", headers) override fun popularMangaRequest(page: Int) = - apiUri.buildUpon().appendEncodedPath("series").run { - appendQueryParameter("page", page.toString()) - appendQueryParameter("sort", "-views") - GET(toString(), headers) - } + GET("$apiUrl/series?page=$page&sort=-views", headers) override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = - apiUri.buildUpon().appendEncodedPath("series").run { + Uri.parse(apiUrl).buildUpon().appendEncodedPath("series").run { if (query.startsWith(SLUG_QUERY)) { appendQueryParameter("slug", query.substring(SLUG_QUERY.length)) } else { @@ -82,21 +72,10 @@ abstract class MangAdventure( } override fun chapterListRequest(manga: SManga) = - apiUri.buildUpon().appendEncodedPath("chapters").run { - appendQueryParameter("series", manga.slug) - appendQueryParameter("date_format", "timestamp") - GET(toString(), headers) - } + GET("$apiUrl/series/${manga.url}/chapters?date_format=timestamp", headers) override fun pageListRequest(chapter: SChapter) = - apiUri.buildUpon().appendEncodedPath("pages").run { - val (slug, vol, num) = chapter.components - appendQueryParameter("track", "true") - appendQueryParameter("series", slug) - appendQueryParameter("volume", vol) - appendQueryParameter("number", num) - GET(toString(), headers) - } + GET("$apiUrl/chapters/${chapter.url}/pages?track=true", headers) override fun latestUpdatesParse(response: Response) = response.decode>().let { @@ -112,7 +91,7 @@ abstract class MangAdventure( override fun chapterListParse(response: Response) = response.decode>().map { chapter -> SChapter.create().apply { - url = chapter.url + url = chapter.id.toString() name = buildString { append(chapter.full_title) if (chapter.final) append(" [END]") @@ -133,11 +112,11 @@ abstract class MangAdventure( // Return the real URL for "Open in browser" override fun mangaDetailsRequest(manga: SManga) = - GET(baseUrl + manga.url, headers) + GET("$baseUrl/reader/${manga.url}", headers) // Workaround to allow "Open in browser" to use the real URL override fun fetchMangaDetails(manga: SManga) = - client.newCall(GET("$apiUri/series/${manga.slug}", headers)) + client.newCall(GET("$apiUrl/series/${manga.url}", headers)) .asObservableSuccess().map { mangaDetailsParse(it).apply { initialized = true } }!! @@ -154,14 +133,6 @@ abstract class MangAdventure( CategoryList(categories) ) - /** The slug of the manga. */ - private inline val SManga.slug - get() = url.split('/')[2] - - /** The components (series, volume, number) of the chapter. */ - private inline val SChapter.components - get() = url.split('/').slice(2..5) - /** Decodes the JSON response as an object. */ private inline fun Response.decode() = json.decodeFromJsonElement(json.parseToJsonElement(body!!.string())) @@ -169,7 +140,7 @@ abstract class MangAdventure( /** Converts a [Series] object to an [SManga]. */ private fun mangaFromJSON(series: Series) = SManga.create().apply { - url = series.url + url = series.slug title = series.title thumbnail_url = series.cover description = buildString { diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureAPI.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureAPI.kt index a46451842..4aeed52a9 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureAPI.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureAPI.kt @@ -30,7 +30,7 @@ internal data class Page( /** Chapter model schema. */ @kotlinx.serialization.Serializable internal data class Chapter( - private val id: Int, + val id: Int, val title: String, val number: Float, val volume: Int?, @@ -38,8 +38,7 @@ internal data class Chapter( val final: Boolean, val series: String, val groups: List, - val full_title: String, - val url: String + val full_title: String ) { override fun equals(other: Any?) = this === other || other is Chapter && id == other.id @@ -50,10 +49,9 @@ internal data class Chapter( /** Series model schema. */ @kotlinx.serialization.Serializable internal data class Series( - private val slug: String, + val slug: String, val title: String, - val url: String, - val cover: String?, + val cover: String, val description: String? = null, val completed: Boolean? = null, val licensed: Boolean? = null, diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureGenerator.kt index d4d68d49d..66695eac6 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/mangadventure/MangAdventureGenerator.kt @@ -9,7 +9,7 @@ class MangAdventureGenerator : ThemeSourceGenerator { override val themeClass = "MangAdventure" - override val baseVersionCode = 9 + override val baseVersionCode = 10 override val sources = listOf( SingleLang("Arc-Relight", "https://arc-relight.com", "en", className = "ArcRelight"),