PeachScan: Deep linking support (#3162)

* Add support to deep linking

* Fix baseUrl

* Remove redirect

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>

---------

Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com>
This commit is contained in:
Chopper 2024-05-23 07:55:42 -03:00 committed by Draff
parent 241578b0a2
commit f1a59ba618
5 changed files with 85 additions and 3 deletions

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity
android:name="eu.kanade.tachiyomi.multisrc.peachscan.PeachScanUrlActivity"
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>

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 7
baseVersionCode = 8
dependencies {
compileOnly("com.github.tachiyomiorg:image-decoder:e08e9be535")

View File

@ -8,6 +8,7 @@ import android.graphics.Canvas
import android.graphics.Rect
import android.util.Base64
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.Page
@ -28,6 +29,7 @@ import okhttp3.ResponseBody.Companion.toResponseBody
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import uy.kohesive.injekt.injectLazy
@ -82,6 +84,18 @@ abstract class PeachScan(
override fun latestUpdatesNextPageSelector() = null
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
if (query.startsWith(URL_SEARCH_PREFIX)) {
val manga = SManga.create().apply { url = "/${query.substringAfter(URL_SEARCH_PREFIX)}/" }
return client.newCall(mangaDetailsRequest(manga))
.asObservableSuccess()
.map {
MangasPage(listOf(mangaDetailsParse(it).apply { url = manga.url }), false)
}
}
return super.fetchSearchManga(page, query, filters)
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = baseUrl.toHttpUrl().newBuilder().apply {
addPathSegments("auto-complete/")
@ -261,4 +275,8 @@ abstract class PeachScan(
memInfo.totalMem < 3L * 1024 * 1024 * 1024
}
companion object {
const val URL_SEARCH_PREFIX = "slug:"
}
}

View File

@ -0,0 +1,42 @@
package eu.kanade.tachiyomi.multisrc.peachscan
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 PeachScanUrlActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val pathSegments = intent?.data?.pathSegments
if (pathSegments != null && pathSegments.size >= 1) {
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", "${slug(pathSegments)}")
putExtra("filter", packageName)
}
try {
startActivity(mainIntent)
} catch (e: ActivityNotFoundException) {
Log.e("PeachScanUrlActivity", e.toString())
}
} else {
Log.e("PeachScanUrlActivity", "could not parse uri from intent $intent")
}
finish()
exitProcess(0)
}
private fun slug(pathSegments: MutableList<String>): String? {
return if (pathSegments.size >= 1) {
val slug = pathSegments[0]
"${PeachScan.URL_SEARCH_PREFIX}$slug"
} else {
null
}
}
}

View File

@ -2,8 +2,8 @@ ext {
extName = 'Lura Toon'
extClass = '.LuraToon'
themePkg = 'peachscan'
baseUrl = 'https://luratoon.com'
overrideVersionCode = 41
baseUrl = 'https://lura-toons.com'
overrideVersionCode = 42
}
apply from: "$rootDir/common.gradle"