Added Url intents for DynastyScans and Kuaikanmanhua (#6822)

* Added Url intents for KKMH

* Added Url intents for Dynasty Scans
This commit is contained in:
ShadesOfRay 2021-05-04 22:16:13 -04:00 committed by GitHub
parent 60693e465c
commit b7110681db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 191 additions and 4 deletions

View File

@ -1,2 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="eu.kanade.tachiyomi.extension" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.kanade.tachiyomi.extension">
<application>
<activity
android:name=".en.dynasty.DynastyUrlActivity"
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="*dynasty-scans.com"
android:pathPattern="/anthologies/..*"
android:scheme="https" />
<data
android:host="*dynasty-scans.com"
android:pathPattern="/chapters/..*"
android:scheme="https" />
<data
android:host="*dynasty-scans.com"
android:pathPattern="/doujins/..*"
android:scheme="https" />
<data
android:host="*dynasty-scans.com"
android:pathPattern="/issues/..*"
android:scheme="https" />
<data
android:host="*dynasty-scans.com"
android:pathPattern="/series/..*"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -5,7 +5,7 @@ ext {
extName = 'Dynasty'
pkgNameSuffix = 'en.dynasty'
extClass = '.DynastyFactory'
extVersionCode = 12
extVersionCode = 13
libVersion = '1.2'
}

View File

@ -10,6 +10,8 @@ class DynastyAnthologies : DynastyScans() {
override val name = "Dynasty-Anthologies"
override val searchPrefix = "anthologies"
override fun popularMangaInitialUrl() = "$baseUrl/anthologies?view=cover"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {

View File

@ -12,6 +12,7 @@ import org.jsoup.nodes.Element
class DynastyChapters : DynastyScans() {
override val name = "Dynasty-Chapters"
override val searchPrefix = "chapters"
override fun popularMangaInitialUrl() = ""
private fun popularMangaInitialUrl(page: Int) = "$baseUrl/search?q=&classes%5B%5D=Chapter&page=$page=$&sort="

View File

@ -15,6 +15,8 @@ class DynastyDoujins : DynastyScans() {
override val name = "Dynasty-Doujins"
override val searchPrefix = "doujins"
override fun popularMangaInitialUrl() = "$baseUrl/doujins?view=cover"
override fun popularMangaFromElement(element: Element): SManga {

View File

@ -10,6 +10,8 @@ class DynastyIssues : DynastyScans() {
override val name = "Dynasty-Issues"
override val searchPrefix = "issues"
override fun popularMangaInitialUrl() = "$baseUrl/issues?view=cover"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {

View File

@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.extension.en.dynasty
import android.net.Uri
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
import eu.kanade.tachiyomi.source.model.SChapter
@ -16,6 +18,7 @@ import org.jsoup.nodes.Element
import org.jsoup.nodes.Node
import org.jsoup.nodes.TextNode
import org.jsoup.select.Elements
import rx.Observable
import java.text.SimpleDateFormat
import java.util.ArrayList
import java.util.Locale
@ -30,6 +33,8 @@ abstract class DynastyScans : ParsedHttpSource() {
override val supportsLatest = false
open val searchPrefix = ""
private var parent: List<Node> = ArrayList()
private var list = InternalList(ArrayList(), "")
@ -58,6 +63,24 @@ abstract class DynastyScans : ParsedHttpSource() {
return MangasPage(mangas, false)
}
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
if (query.startsWith("manga:")) {
return if (query.startsWith("manga:$searchPrefix:")) {
val newQuery = query.removePrefix("manga:$searchPrefix:")
client.newCall(GET("$baseUrl/$searchPrefix/$newQuery"))
.asObservableSuccess()
.map { response ->
val details = mangaDetailsParse(response)
details.url = "/$searchPrefix/$newQuery"
MangasPage(listOf(details), false)
}
} else {
return Observable.just(MangasPage(ArrayList<SManga>(0), false))
}
}
return super.fetchSearchManga(page, query, filters)
}
override fun searchMangaSelector() = "a.name"
override fun searchMangaFromElement(element: Element): SManga {

View File

@ -10,6 +10,8 @@ class DynastySeries : DynastyScans() {
override val name = "Dynasty-Series"
override val searchPrefix = "series"
override fun popularMangaInitialUrl() = "$baseUrl/series?view=cover"
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {

View File

@ -0,0 +1,34 @@
package eu.kanade.tachiyomi.extension.en.dynasty
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 DynastyUrlActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val pathSegments = intent?.data?.pathSegments
if (pathSegments != null && pathSegments.size > 1) {
val id = pathSegments[1]
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", "manga:${pathSegments[0]}:$id")
putExtra("filter", packageName)
}
try {
startActivity(mainIntent)
} catch (e: ActivityNotFoundException) {
Log.e("DynastyUrlActivity", e.toString())
}
} else {
Log.e("DynastyUrlActivity", "could not parse uri from intent $intent")
}
finish()
exitProcess(0)
}
}

View File

@ -1,2 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="eu.kanade.tachiyomi.extension" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.kanade.tachiyomi.extension">
<application>
<activity
android:name=".zh.kuaikanmanhua.KuaikanmanhuaUrlActivity"
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="m.kuaikanmanhua.com"
android:pathPattern="/mobile/..*"
android:scheme="https" />
<data
android:host="*kuaikanmanhua.com"
android:pathPattern="/web/topic/..*"
android:scheme="https" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -5,7 +5,7 @@ ext {
extName = 'Kuaikanmanhua'
pkgNameSuffix = 'zh.kuaikanmanhua'
extClass = '.Kuaikanmanhua'
extVersionCode = 3
extVersionCode = 4
libVersion = '1.2'
}

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.extension.zh.kuaikanmanhua
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.asObservableSuccess
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.MangasPage
@ -68,8 +69,23 @@ class Kuaikanmanhua : HttpSource() {
// Search
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
if (query.startsWith(TOPIC_ID_SEARCH_PREFIX)) {
val new_query = query.removePrefix(TOPIC_ID_SEARCH_PREFIX)
return client.newCall(GET("$apiUrl/v1/topics/$new_query"))
.asObservableSuccess()
.map { response ->
val details = mangaDetailsParse(response)
details.url = "/web/topic/$new_query"
MangasPage(listOf(details), false)
}
}
return super.fetchSearchManga(page, query, filters)
}
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
return if (query.isNotEmpty()) {
GET("$apiUrl/v1/search/topic?q=$query&size=18", headers)
} else {
lateinit var genre: String
@ -112,6 +128,7 @@ class Kuaikanmanhua : HttpSource() {
val data = JSONObject(response.body!!.string()).getJSONObject("data")
val manga = SManga.create()
manga.title = data.getString("title")
manga.thumbnail_url = data.getString("vertical_image_url")
manga.author = data.getJSONObject("user").getString("nickname")
manga.description = data.getString("description")
manga.status = data.getInt("update_status_code")
@ -227,4 +244,8 @@ class Kuaikanmanhua : HttpSource() {
Filter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
fun toUriPart() = vals[state].second
}
companion object {
const val TOPIC_ID_SEARCH_PREFIX = "topic:"
}
}

View File

@ -0,0 +1,38 @@
package eu.kanade.tachiyomi.extension.zh.kuaikanmanhua
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 KuaikanmanhuaUrlActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val host = intent?.data?.host
val pathSegments = intent?.data?.pathSegments
if (pathSegments != null && pathSegments.size > 1) {
val id = when (host) {
"m.kuaikanmanhua.com" -> pathSegments[1]
else -> pathSegments[2]
}
val mainIntent = Intent().apply {
action = "eu.kanade.tachiyomi.SEARCH"
putExtra("query", "${Kuaikanmanhua.TOPIC_ID_SEARCH_PREFIX}$id")
putExtra("filter", packageName)
}
try {
startActivity(mainIntent)
} catch (e: ActivityNotFoundException) {
Log.e("KkmhUrlActivity", e.toString())
}
} else {
Log.e("KkmhUrlActivity", "could not parse uri from intent $intent")
}
finish()
exitProcess(0)
}
}