HeanCms: deeplink support & thumbnail on search (#16156)
* HeanCms: fix english string * attempt to use thumbnail from search if available * deep link support * version * suggested changes Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com> * lint * attempt to use status from details response --------- Co-authored-by: Alessandro Jean <14254807+alessandrojean@users.noreply.github.com>
This commit is contained in:
parent
e1ecd8d26d
commit
61d34b9ff8
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="eu.kanade.tachiyomi.extension">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name="eu.kanade.tachiyomi.multisrc.heancms.HeanCmsUrlActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data
|
||||
android:host="${SOURCEHOST}"
|
||||
android:pathPattern="/.*/..*"
|
||||
android:scheme="${SOURCESCHEME}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
|
@ -117,6 +117,17 @@ abstract class HeanCms(
|
|||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage = popularMangaParse(response)
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
if (!query.startsWith(SEARCH_PREFIX)) {
|
||||
return super.fetchSearchManga(page, query, filters)
|
||||
}
|
||||
|
||||
val slug = query.substringAfter(SEARCH_PREFIX)
|
||||
val manga = SManga.create().apply { url = "/series/$slug" }
|
||||
|
||||
return fetchMangaDetails(manga).map { MangasPage(listOf(it), false) }
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
/**
|
||||
* Their query search endpoint doesn't return the thumbnails, so we need to do
|
||||
|
@ -224,7 +235,8 @@ abstract class HeanCms(
|
|||
?: throw Exception(intl.urlChangedError(name))
|
||||
|
||||
return seriesDetails.apply {
|
||||
status = response.request.url.fragment?.toIntOrNull() ?: SManga.UNKNOWN
|
||||
status = status.takeUnless { it == SManga.UNKNOWN }
|
||||
?: response.request.url.fragment?.toIntOrNull() ?: SManga.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,5 +407,7 @@ abstract class HeanCms(
|
|||
private val JSON_MEDIA_TYPE = "application/json".toMediaType()
|
||||
|
||||
val TIMESTAMP_REGEX = "-\\d+$".toRegex()
|
||||
|
||||
const val SEARCH_PREFIX = "slug:"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ data class HeanCmsSearchDto(
|
|||
@SerialName("series_slug") val slug: String,
|
||||
@SerialName("series_type") val type: String,
|
||||
val title: String,
|
||||
val thumbnail: String? = null,
|
||||
) {
|
||||
|
||||
fun toSManga(
|
||||
|
@ -40,7 +41,8 @@ data class HeanCmsSearchDto(
|
|||
val thumbnailFileName = slugMap[slugOnly]?.thumbnailFileName
|
||||
|
||||
title = this@HeanCmsSearchDto.title
|
||||
thumbnail_url = thumbnailFileName?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
thumbnail_url = thumbnail?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
?: thumbnailFileName?.toAbsoluteThumbnailUrl(apiUrl, coverPath)
|
||||
url = "/series/$slugOnly"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class HeanCmsGenerator : ThemeSourceGenerator {
|
|||
|
||||
override val themeClass = "HeanCms"
|
||||
|
||||
override val baseVersionCode: Int = 12
|
||||
override val baseVersionCode: Int = 13
|
||||
|
||||
override val sources = listOf(
|
||||
SingleLang("Omega Scans", "https://omegascans.org", "en", isNsfw = true, overrideVersionCode = 16),
|
||||
|
|
|
@ -25,7 +25,7 @@ class HeanCmsIntl(lang: String) {
|
|||
val statusOnHiatus: String = when (availableLang) {
|
||||
BRAZILIAN_PORTUGUESE -> "Em hiato"
|
||||
SPANISH -> "En hiatus"
|
||||
else -> "Ongoing"
|
||||
else -> "On Hiatus"
|
||||
}
|
||||
|
||||
val statusDropped: String = when (availableLang) {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package eu.kanade.tachiyomi.multisrc.heancms
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class HeanCmsUrlActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
|
||||
if (pathSegments != null && pathSegments.size >= 2) {
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", createQuery(pathSegments))
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e("HeanCmsUrlActivity", e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e("HeanCmsUrlActivity", "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
private fun createQuery(pathSegments: MutableList<String>): String? {
|
||||
return if (pathSegments.size >= 2) {
|
||||
val slug = pathSegments[1]
|
||||
"${HeanCms.SEARCH_PREFIX}$slug"
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue