UnionMangas: Fix deep linking (#3151)
* Fix deep linking * Remove if/else
This commit is contained in:
parent
410977c9df
commit
986683e93d
|
@ -1,7 +1,7 @@
|
|||
ext {
|
||||
extName = 'Union Mangas'
|
||||
extClass = '.UnionMangasFactory'
|
||||
extVersionCode = 2
|
||||
extVersionCode = 3
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
|
|
@ -171,14 +171,12 @@ class UnionMangas(private val langOption: LanguageOption) : HttpSource() {
|
|||
}
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
if (query.startsWith(slugPrefix)) {
|
||||
val mangaUrl = query.substringAfter(slugPrefix)
|
||||
return client.newCall(GET("$baseUrl/${langOption.infix}/$mangaUrl", headers))
|
||||
if (query.startsWith(SEARCH_PREFIX)) {
|
||||
val url = "$baseUrl/${langOption.infix}/${query.substringAfter(SEARCH_PREFIX)}"
|
||||
return client.newCall(GET(url, headers))
|
||||
.asObservableSuccess().map { response ->
|
||||
val manga = mangaDetailsParse(response).apply {
|
||||
url = mangaUrl
|
||||
}
|
||||
MangasPage(listOf(manga), false)
|
||||
val mangas = try { listOf(mangaDetailsParse(response)) } catch (_: Exception) { emptyList() }
|
||||
MangasPage(mangas, false)
|
||||
}
|
||||
}
|
||||
return super.fetchSearchManga(page, query, filters)
|
||||
|
@ -227,10 +225,10 @@ class UnionMangas(private val langOption: LanguageOption) : HttpSource() {
|
|||
private fun mangaUrlParse(slug: String, pathSegment: String) = "/$pathSegment/$slug"
|
||||
|
||||
companion object {
|
||||
const val SEARCH_PREFIX = "slug:"
|
||||
val apiUrl = "https://api.unionmanga.xyz"
|
||||
val apiSeed = "8e0550790c94d6abc71d738959a88d209690dc86"
|
||||
val domain = "yaoi-chan.xyz"
|
||||
val slugPrefix = "slug:"
|
||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH)
|
||||
val apiDateFormat = SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.ENGLISH)
|
||||
.apply { timeZone = TimeZone.getTimeZone("GMT") }
|
||||
|
|
|
@ -116,7 +116,7 @@ class MangaDetailsDto(
|
|||
|
||||
val thumbnailUrl get() = "${UnionMangas.apiUrl}$_thumbnailUrl"
|
||||
val genres get() = _genres.joinToString { it.name }
|
||||
val status get() = toSMangaStatus(_status.first().name)
|
||||
val status get() = toSMangaStatus(_status.firstOrNull()?.name ?: "")
|
||||
|
||||
@Serializable
|
||||
class Prop(
|
||||
|
|
|
@ -11,10 +11,9 @@ class UnionMangasUrlActivity : Activity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val host = intent?.data?.host
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
|
||||
if (host != null && pathSegments != null) {
|
||||
if (pathSegments != null && pathSegments.size > 1) {
|
||||
val intent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", slug(pathSegments))
|
||||
|
@ -32,5 +31,6 @@ class UnionMangasUrlActivity : Activity() {
|
|||
exitProcess(0)
|
||||
}
|
||||
|
||||
private fun slug(pathSegments: List<String>) = "${UnionMangas.slugPrefix}${pathSegments.last()}"
|
||||
private fun slug(pathSegments: List<String>) =
|
||||
"${UnionMangas.SEARCH_PREFIX}${pathSegments[1]}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue