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:host="www.mangadex.org"
|
||||||
android:pathPattern="/manga/..*"
|
android:pathPattern="/manga/..*"
|
||||||
android:scheme="https" />
|
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>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 125
|
extVersionCode = 126
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ object MDConstants {
|
|||||||
.apply { timeZone = TimeZone.getTimeZone("UTC") }
|
.apply { timeZone = TimeZone.getTimeZone("UTC") }
|
||||||
|
|
||||||
const val prefixIdSearch = "id:"
|
const val prefixIdSearch = "id:"
|
||||||
|
const val prefixChSearch = "ch:"
|
||||||
|
|
||||||
const val dataSaverPref = "dataSaverV5"
|
const val dataSaverPref = "dataSaverV5"
|
||||||
|
|
||||||
|
@ -173,6 +173,30 @@ abstract class MangaDex(override val lang: String, val dexLang: String) :
|
|||||||
|
|
||||||
// SEARCH section
|
// 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 {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
if (query.startsWith(MDConstants.prefixIdSearch)) {
|
if (query.startsWith(MDConstants.prefixIdSearch)) {
|
||||||
val url = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply {
|
val url = MDConstants.apiMangaUrl.toHttpUrlOrNull()!!.newBuilder().apply {
|
||||||
|
@ -25,7 +25,11 @@ class MangadexUrlActivity : Activity() {
|
|||||||
val titleid = pathSegments[1]
|
val titleid = pathSegments[1]
|
||||||
val mainIntent = Intent().apply {
|
val mainIntent = Intent().apply {
|
||||||
action = "eu.kanade.tachiyomi.SEARCH"
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
|
if (pathSegments[0].equals("chapter")) {
|
||||||
|
putExtra("query", "${MDConstants.prefixChSearch}$titleid")
|
||||||
|
} else {
|
||||||
putExtra("query", "${MDConstants.prefixIdSearch}$titleid")
|
putExtra("query", "${MDConstants.prefixIdSearch}$titleid")
|
||||||
|
}
|
||||||
putExtra("filter", packageName)
|
putExtra("filter", packageName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user