parent
e0ca5b5c3b
commit
b02a8254c3
|
@ -5,12 +5,11 @@ ext {
|
||||||
appName = 'Tachiyomi: Manga Rock'
|
appName = 'Tachiyomi: Manga Rock'
|
||||||
pkgNameSuffix = 'en.mangarock'
|
pkgNameSuffix = 'en.mangarock'
|
||||||
extClass = '.MangaRock'
|
extClass = '.MangaRock'
|
||||||
extVersionCode = 7
|
extVersionCode = 8
|
||||||
libVersion = '1.0'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.google.code.gson:gson:2.8.5'
|
|
||||||
compileOnly 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
compileOnly 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.github.salomonbrys.kotson.jsonObject
|
||||||
import com.github.salomonbrys.kotson.set
|
import com.github.salomonbrys.kotson.set
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.POST
|
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.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
|
@ -18,6 +19,7 @@ import okhttp3.RequestBody
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import rx.Observable
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.experimental.and
|
import kotlin.experimental.and
|
||||||
import kotlin.experimental.xor
|
import kotlin.experimental.xor
|
||||||
|
@ -30,7 +32,9 @@ class MangaRock : HttpSource() {
|
||||||
|
|
||||||
override val name = "Manga Rock"
|
override val name = "Manga Rock"
|
||||||
|
|
||||||
override val baseUrl = "https://api.mangarockhd.com/query/web401"
|
override val baseUrl = "https://mangarock.com"
|
||||||
|
|
||||||
|
private val apiUrl = "https://api.mangarockhd.com/query/web401"
|
||||||
|
|
||||||
override val lang = "en"
|
override val lang = "en"
|
||||||
|
|
||||||
|
@ -48,9 +52,7 @@ class MangaRock : HttpSource() {
|
||||||
return response.newBuilder().body(rb).build()
|
return response.newBuilder().body(rb).build()
|
||||||
}).build()
|
}).build()
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request {
|
override fun latestUpdatesRequest(page: Int) = GET("$apiUrl/mrs_latest")
|
||||||
return GET("$baseUrl/mrs_latest")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||||
val res = response.body()!!.string()
|
val res = response.body()!!.string()
|
||||||
|
@ -58,9 +60,7 @@ class MangaRock : HttpSource() {
|
||||||
return getMangasPageFromJsonList(list)
|
return getMangasPageFromJsonList(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun popularMangaRequest(page: Int): Request {
|
override fun popularMangaRequest(page: Int) = GET("$apiUrl/mrs_latest")
|
||||||
return GET("$baseUrl/mrs_latest")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun popularMangaParse(response: Response): MangasPage {
|
override fun popularMangaParse(response: Response): MangasPage {
|
||||||
val res = response.body()!!.string()
|
val res = response.body()!!.string()
|
||||||
|
@ -106,7 +106,7 @@ class MangaRock : HttpSource() {
|
||||||
"rank" to rank,
|
"rank" to rank,
|
||||||
"order" to orderBy
|
"order" to orderBy
|
||||||
).toString())
|
).toString())
|
||||||
return POST("$baseUrl/mrs_filter", headers, body)
|
return POST("$apiUrl/mrs_filter", headers, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular search
|
// Regular search
|
||||||
|
@ -114,7 +114,7 @@ class MangaRock : HttpSource() {
|
||||||
"type" to "series",
|
"type" to "series",
|
||||||
"keywords" to query
|
"keywords" to query
|
||||||
).toString())
|
).toString())
|
||||||
return POST("$baseUrl/mrs_search", headers, body)
|
return POST("$apiUrl/mrs_search", headers, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMangaParse(response: Response): MangasPage {
|
override fun searchMangaParse(response: Response): MangasPage {
|
||||||
|
@ -152,21 +152,36 @@ class MangaRock : HttpSource() {
|
||||||
|
|
||||||
private fun parseMangaJson(obj: JSONObject): SManga {
|
private fun parseMangaJson(obj: JSONObject): SManga {
|
||||||
return SManga.create().apply {
|
return SManga.create().apply {
|
||||||
|
setUrlWithoutDomain("/manga/${obj.getString("oid")}")
|
||||||
title = obj.getString("name")
|
title = obj.getString("name")
|
||||||
thumbnail_url = obj.getString("thumbnail")
|
thumbnail_url = obj.getString("thumbnail")
|
||||||
status = if (obj.getBoolean("completed")) SManga.COMPLETED else SManga.ONGOING
|
status = if (obj.getBoolean("completed")) SManga.COMPLETED else SManga.ONGOING
|
||||||
url = "/info?oid=${obj.getString("oid")}"
|
}
|
||||||
|
}
|
||||||
|
private fun sortByRank(arr: List<JSONObject>): List<JSONObject> {
|
||||||
|
return arr.sortedBy { it.getInt("rank") }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Avoid directly overriding mangaDetailsRequest so that "Open in browser" action uses the
|
||||||
|
// "real" URL
|
||||||
|
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||||
|
return client.newCall(getMangaApiRequest(manga))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map { response ->
|
||||||
|
mangaDetailsParse(response).apply { initialized = true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortByRank(arr: List<JSONObject>): List<JSONObject> {
|
override fun chapterListRequest(manga: SManga) = getMangaApiRequest(manga)
|
||||||
return arr.sortedBy { it.getInt("rank") }
|
|
||||||
|
private fun getMangaApiRequest(manga: SManga): Request {
|
||||||
|
val oid = manga.url.substringAfterLast("/")
|
||||||
|
return GET("$apiUrl/info?oid=$oid", headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
override fun mangaDetailsParse(response: Response) = SManga.create().apply {
|
||||||
val obj = JSONObject(response.body()!!.string()).getJSONObject("data")
|
val obj = JSONObject(response.body()!!.string()).getJSONObject("data")
|
||||||
|
|
||||||
url = "https://mangarock.com/manga/${obj.getString("oid")}"
|
|
||||||
title = obj.getString("name")
|
title = obj.getString("name")
|
||||||
description = obj.getString("description")
|
description = obj.getString("description")
|
||||||
|
|
||||||
|
@ -215,6 +230,8 @@ class MangaRock : HttpSource() {
|
||||||
return chapters
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun pageListRequest(chapter: SChapter) = GET(apiUrl + chapter.url, headers)
|
||||||
|
|
||||||
override fun pageListParse(response: Response): List<Page> {
|
override fun pageListParse(response: Response): List<Page> {
|
||||||
val obj = JSONObject(response.body()!!.string()).getJSONArray("data")
|
val obj = JSONObject(response.body()!!.string()).getJSONArray("data")
|
||||||
val pages = ArrayList<Page>()
|
val pages = ArrayList<Page>()
|
||||||
|
|
Loading…
Reference in New Issue