MangaDex: Make chapter URLs deeplink to series page in Tachiyomi (#8205)
* MangaDex: Chapter URLs deeplink to series page in Tachiyomi * Changes to getMangaIdFromChapterId: * Remove FORCE_NETWORK from request * Decode to ChapterDto instead of manually parsing json * Make exception on unsuccessful response more verbose * Use constant instead of "manga" literal
This commit is contained in:
parent
f3e86f75be
commit
233746b94d
|
@ -29,6 +29,14 @@
|
|||
android:host="www.mangadex.org"
|
||||
android:pathPattern="/manga/..*"
|
||||
android:scheme="https" />
|
||||
<data
|
||||
android:host="mangadex.org"
|
||||
android:pathPattern="/chapter/..*"
|
||||
android:scheme="https" />
|
||||
<data
|
||||
android:host="www.mangadex.org"
|
||||
android:pathPattern="/chapter/..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
|
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'MangaDex'
|
||||
pkgNameSuffix = 'all.mangadex'
|
||||
extClass = '.MangaDexFactory'
|
||||
extVersionCode = 125
|
||||
extVersionCode = 126
|
||||
libVersion = '1.2'
|
||||
containsNsfw = true
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ object MDConstants {
|
|||
.apply { timeZone = TimeZone.getTimeZone("UTC") }
|
||||
|
||||
const val prefixIdSearch = "id:"
|
||||
const val prefixChSearch = "ch:"
|
||||
|
||||
const val dataSaverPref = "dataSaverV5"
|
||||
|
||||
|
|
|
@ -173,6 +173,30 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||
|
||||
// SEARCH section
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
if (query.startsWith(MDConstants.prefixChSearch)) {
|
||||
return getMangaIdFromChapterId(query.removePrefix(MDConstants.prefixChSearch)).flatMap { manga_id ->
|
||||
super.fetchSearchManga(page, MDConstants.prefixIdSearch + manga_id, filters)
|
||||
}
|
||||
}
|
||||
return super.fetchSearchManga(page, query, filters)
|
||||
}
|
||||
|
||||
private fun getMangaIdFromChapterId(id: String): Observable<String> {
|
||||
return client.newCall(GET("${MDConstants.apiChapterUrl}/$id", headers))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
if (response.isSuccessful.not()) {
|
||||
throw Exception("Unable to process Chapter request. HTTP code: ${response.code}")
|
||||
}
|
||||
|
||||
helper.json.decodeFromString<ChapterDto>(response.body!!.string()).relationships
|
||||
.find {
|
||||
it.type == MDConstants.manga
|
||||
}!!.id
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
if (query.startsWith(MDConstants.prefixIdSearch)) {
|
||||
val url = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply {
|
||||
|
|
|
@ -25,7 +25,11 @@ class MangadexUrlActivity : Activity() {
|
|||
val titleid = pathSegments[1]
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", "${MDConstants.prefixIdSearch}$titleid")
|
||||
if (pathSegments[0].equals("chapter")) {
|
||||
putExtra("query", "${MDConstants.prefixChSearch}$titleid")
|
||||
} else {
|
||||
putExtra("query", "${MDConstants.prefixIdSearch}$titleid")
|
||||
}
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue