Guya: Add support for opening guya.moe titles directly in Tachiyomi (#2284)
Guya: Add support for opening guya.moe titles directly in Tachiyomi
This commit is contained in:
parent
e23b69f8a7
commit
7c51b89575
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<application>
|
||||||
|
<activity
|
||||||
|
android:name=".GuyaUrlActivity"
|
||||||
|
android:theme="@android:style/Theme.NoDisplay"
|
||||||
|
android:excludeFromRecents="true">
|
||||||
|
<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:scheme="https"
|
||||||
|
android:host="guya.moe"
|
||||||
|
android:pathPattern="/read/manga/..*" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
|
@ -5,7 +5,7 @@ ext {
|
||||||
appName = 'Tachiyomi: Guya'
|
appName = 'Tachiyomi: Guya'
|
||||||
pkgNameSuffix = "en.guya"
|
pkgNameSuffix = "en.guya"
|
||||||
extClass = '.Guya'
|
extClass = '.Guya'
|
||||||
extVersionCode = 9
|
extVersionCode = 10
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,20 @@ open class Guya() : ConfigurableSource, HttpSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||||
return client.newCall(searchMangaRequest(page, query, filters))
|
return if ( query.startsWith(SLUG_PREFIX)) {
|
||||||
.asObservableSuccess()
|
val slug = query.removePrefix(SLUG_PREFIX)
|
||||||
.map { response ->
|
client.newCall(searchMangaRequest(page, query, filters))
|
||||||
searchMangaParse(response, query)
|
.asObservableSuccess()
|
||||||
}
|
.map { response ->
|
||||||
|
searchMangaParseWithSlug(response, slug)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client.newCall(searchMangaRequest(page, query, filters))
|
||||||
|
.asObservableSuccess()
|
||||||
|
.map { response ->
|
||||||
|
searchMangaParse(response, query)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||||
|
@ -146,6 +155,24 @@ open class Guya() : ConfigurableSource, HttpSource() {
|
||||||
throw Exception("Unused.")
|
throw Exception("Unused.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun searchMangaParseWithSlug(response: Response, slug: String) : MangasPage {
|
||||||
|
val results = JSONObject(response.body()!!.string())
|
||||||
|
val mangaIter = results.keys()
|
||||||
|
val truncatedJSON = JSONObject()
|
||||||
|
|
||||||
|
while (mangaIter.hasNext()) {
|
||||||
|
val mangaTitle = mangaIter.next()
|
||||||
|
val mangaDetails = results.getJSONObject(mangaTitle)
|
||||||
|
|
||||||
|
if (mangaDetails.get("slug") == slug) {
|
||||||
|
truncatedJSON.put(mangaTitle, mangaDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseManga(truncatedJSON)
|
||||||
|
}
|
||||||
|
|
||||||
private fun searchMangaParse(response: Response, query: String): MangasPage {
|
private fun searchMangaParse(response: Response, query: String): MangasPage {
|
||||||
val res = response.body()!!.string()
|
val res = response.body()!!.string()
|
||||||
val json = JSONObject(res)
|
val json = JSONObject(res)
|
||||||
|
@ -393,4 +420,7 @@ open class Guya() : ConfigurableSource, HttpSource() {
|
||||||
throw Exception("Latest updates not supported.")
|
throw Exception("Latest updates not supported.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val SLUG_PREFIX = "slug:"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package eu.kanade.tachiyomi.extension.en.guya
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts https://guya.moe/read/manga/xyz intents
|
||||||
|
*
|
||||||
|
* Added due to requests from various users to allow for opening of titles when given the
|
||||||
|
* Guya URL whilst on mobile.
|
||||||
|
*/
|
||||||
|
class GuyaUrlActivity : Activity() {
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
val pathSegments = intent?.data?.pathSegments
|
||||||
|
if (pathSegments != null && pathSegments.size == 3) {
|
||||||
|
val slug = pathSegments[2]
|
||||||
|
|
||||||
|
// Gotta do it like this since slug title != actual title
|
||||||
|
val mainIntent = Intent().apply {
|
||||||
|
action = "eu.kanade.tachiyomi.SEARCH"
|
||||||
|
putExtra("query", "${Guya.SLUG_PREFIX}$slug")
|
||||||
|
putExtra("filter", packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
startActivity(mainIntent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Log.e("GuyaUrlActivity", e.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("GuyaUrlActivity", "Unable to parse URI from intent $intent")
|
||||||
|
}
|
||||||
|
|
||||||
|
finish()
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue