WeebCentral: add support for deeplink (#9129)
* Add support for deeplink * Bump version * Refactoring * Add suggested changes * Remove empty search
This commit is contained in:
parent
48f590df0c
commit
d73a90d970
22
src/en/weebcentral/AndroidManifest.xml
Normal file
22
src/en/weebcentral/AndroidManifest.xml
Normal 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=".en.weebcentral.WeebCentralUrlActivity"
|
||||
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="weebcentral.com"
|
||||
android:pathPattern="/series/..*"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
@ -1,7 +1,7 @@
|
||||
ext {
|
||||
extName = 'Weeb Central'
|
||||
extClass = '.WeebCentral'
|
||||
extVersionCode = 14
|
||||
extVersionCode = 15
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package eu.kanade.tachiyomi.extension.en.weebcentral
|
||||
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.network.interceptor.rateLimit
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
@ -12,6 +14,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.Request
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import rx.Observable
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
@ -66,6 +69,17 @@ class WeebCentral : ParsedHttpSource() {
|
||||
override fun latestUpdatesNextPageSelector(): String = searchMangaNextPageSelector()
|
||||
|
||||
// =============================== Search ===============================
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
val pathSegment = query.takeIf { it.startsWith(URL_SEARCH_PREFIX) }
|
||||
?.removePrefix(URL_SEARCH_PREFIX)
|
||||
?: return super.fetchSearchManga(page, query, filters)
|
||||
|
||||
return client.newCall(mangaDetailsRequest(SManga.create().apply { url = "/series/$pathSegment" }))
|
||||
.asObservableSuccess()
|
||||
.map { MangasPage(listOf(mangaDetailsParse(it).apply { initialized = true }), false) }
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
val filterList = filters.ifEmpty { getFilterList() }
|
||||
val url = "$baseUrl/search/data".toHttpUrl().newBuilder().apply {
|
||||
@ -131,6 +145,8 @@ class WeebCentral : ParsedHttpSource() {
|
||||
}
|
||||
|
||||
description = descBuilder.toString()
|
||||
|
||||
setUrlWithoutDomain(document.location())
|
||||
}
|
||||
|
||||
private fun Element?.parseStatus(): Int = when (this?.text()?.lowercase()) {
|
||||
@ -231,5 +247,6 @@ class WeebCentral : ParsedHttpSource() {
|
||||
|
||||
companion object {
|
||||
const val FETCH_LIMIT = 24
|
||||
const val URL_SEARCH_PREFIX = "id:"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
package eu.kanade.tachiyomi.extension.en.weebcentral
|
||||
|
||||
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 WeebCentralUrlActivity : Activity() {
|
||||
|
||||
private val tag = javaClass.simpleName
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
|
||||
if (pathSegments != null && pathSegments.size >= 3) {
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", getEntry(pathSegments))
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e(tag, e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e(tag, "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
private fun getEntry(pathSegments: MutableList<String>): String? {
|
||||
val id = pathSegments[1]
|
||||
val slug = pathSegments[2]
|
||||
return "${WeebCentral.URL_SEARCH_PREFIX}$id/$slug"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user