Purple Cress: Add search and deepliking (#8176)
This commit is contained in:
parent
b153c3cf22
commit
3ffa78ae2b
|
@ -1,2 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="eu.kanade.tachiyomi.extension" />
|
||||
<manifest package="eu.kanade.tachiyomi.extension"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".en.purplecress.PurpleCressURLActivity"
|
||||
android:excludeFromRecents="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="purplecress.com"
|
||||
android:pathPattern="/series/..*"
|
||||
android:scheme="https" />
|
||||
<data
|
||||
android:host="purplecress.com"
|
||||
android:pathPattern="/chapter/..*"
|
||||
android:scheme="https" />
|
||||
|
||||
<data
|
||||
android:host="www.purplecress.com"
|
||||
android:pathPattern="/series/..*"
|
||||
android:scheme="https" />
|
||||
<data
|
||||
android:host="www.purplecress.com"
|
||||
android:pathPattern="/chapter/..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
|
@ -5,7 +5,7 @@ ext {
|
|||
extName = 'Purple Cress'
|
||||
pkgNameSuffix = 'en.purplecress'
|
||||
extClass = '.PurpleCress'
|
||||
extVersionCode = 1
|
||||
extVersionCode = 2
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -121,13 +121,35 @@ class PurpleCress : HttpSource() {
|
|||
return Observable.just(page.imageUrl)
|
||||
}
|
||||
|
||||
override fun imageUrlRequest(page: Page): Request = throw UnsupportedOperationException("Not used")
|
||||
companion object {
|
||||
const val URL_SEARCH_PREFIX = "purplecress_url:"
|
||||
}
|
||||
|
||||
override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> = Observable.just(MangasPage(emptyList(), false))
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
if (query.startsWith(URL_SEARCH_PREFIX)) {
|
||||
val manga = SManga.create().apply {
|
||||
url = query.removePrefix(URL_SEARCH_PREFIX)
|
||||
}
|
||||
return fetchMangaDetails(manga).map {
|
||||
MangasPage(listOf(it), false)
|
||||
}
|
||||
}
|
||||
return fetchPopularManga(page).map {
|
||||
mangasPage ->
|
||||
MangasPage(
|
||||
mangasPage.mangas.filter {
|
||||
it.title.contains(query, true)
|
||||
},
|
||||
mangasPage.hasNextPage
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun searchMangaParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun imageUrlRequest(page: Page): Request = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun imageUrlParse(response: Response): String = throw UnsupportedOperationException("Not used")
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package eu.kanade.tachiyomi.extension.en.purplecress
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class PurpleCressURLActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
if (pathSegments != null && pathSegments.size >= 2) {
|
||||
val url = "/series/" + Uri.encode(pathSegments[1])
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", PurpleCress.URL_SEARCH_PREFIX + url)
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e("PurpleCressUrlActivity", e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e("PurpleCressUrlActivity", "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue