Add URL intent to TaoSect (#10813)
* Add URL intent to TaoSect. * Fix infinite loading on slug search when empty.
This commit is contained in:
parent
8f2c359e99
commit
643d072d5b
@ -1,2 +1,24 @@
|
||||
<?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=".pt.taosect.TaoSectUrlActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter android:autoVerify="true">
|
||||
<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="taosect.com"
|
||||
android:pathPattern="/projeto/..*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
@ -6,7 +6,7 @@ ext {
|
||||
extName = 'Tao Sect'
|
||||
pkgNameSuffix = 'pt.taosect'
|
||||
extClass = '.TaoSect'
|
||||
extVersionCode = 13
|
||||
extVersionCode = 14
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,8 @@ class TaoSect : HttpSource() {
|
||||
|
||||
val projectList = result.map(::popularMangaFromObject)
|
||||
|
||||
val currentPage = response.request.url.queryParameter("page")!!.toInt()
|
||||
val currentPage = response.request.url.queryParameter("page")
|
||||
.orEmpty().toIntOrNull() ?: 1
|
||||
val lastPage = response.headers["X-Wp-TotalPages"]!!.toInt()
|
||||
val hasNextPage = currentPage < lastPage
|
||||
|
||||
@ -139,6 +140,10 @@ class TaoSect : HttpSource() {
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
if (query.startsWith(SLUG_PREFIX_SEARCH) && query.removePrefix(SLUG_PREFIX_SEARCH).isNotBlank()) {
|
||||
return mangaDetailsApiRequest(query.removePrefix(SLUG_PREFIX_SEARCH))
|
||||
}
|
||||
|
||||
val apiUrl = "$baseUrl/$API_BASE_PATH/projetos".toHttpUrl().newBuilder()
|
||||
.addQueryParameter("page", page.toString())
|
||||
.addQueryParameter("per_page", PROJECTS_PER_PAGE.toString())
|
||||
@ -226,22 +231,22 @@ class TaoSect : HttpSource() {
|
||||
|
||||
// Workaround to allow "Open in browser" use the real URL.
|
||||
override fun fetchMangaDetails(manga: SManga): Observable<SManga> {
|
||||
return client.newCall(mangaDetailsApiRequest(manga))
|
||||
return client.newCall(mangaDetailsApiRequest(manga.url))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
mangaDetailsParse(response).apply { initialized = true }
|
||||
}
|
||||
}
|
||||
|
||||
private fun mangaDetailsApiRequest(manga: SManga): Request {
|
||||
val projectSlug = manga.url
|
||||
private fun mangaDetailsApiRequest(mangaUrl: String): Request {
|
||||
val projectSlug = mangaUrl
|
||||
.substringAfterLast("projeto/")
|
||||
.substringBefore("/")
|
||||
|
||||
val apiUrl = "$baseUrl/$API_BASE_PATH/projetos".toHttpUrl().newBuilder()
|
||||
.addQueryParameter("per_page", "1")
|
||||
.addQueryParameter("slug", projectSlug)
|
||||
.addQueryParameter("_fields", "title,informacoes,content,thumbnail")
|
||||
.addQueryParameter("_fields", "title,informacoes,content,thumbnail,link")
|
||||
.toString()
|
||||
|
||||
return GET(apiUrl, apiHeaders)
|
||||
@ -289,7 +294,7 @@ class TaoSect : HttpSource() {
|
||||
val result = response.parseAs<List<TaoSectChapterDto>>()
|
||||
|
||||
if (result.isNullOrEmpty()) {
|
||||
throw Exception(PROJECT_NOT_FOUND)
|
||||
throw Exception(CHAPTERS_NOT_FOUND)
|
||||
}
|
||||
|
||||
// Count the project views, requested by the scanlator.
|
||||
@ -488,11 +493,14 @@ class TaoSect : HttpSource() {
|
||||
private const val ACCEPT_JSON = "application/json"
|
||||
private val USER_AGENT = "Tachiyomi " + System.getProperty("http.agent")
|
||||
|
||||
const val SLUG_PREFIX_SEARCH = "slug:"
|
||||
|
||||
private const val API_BASE_PATH = "wp-json/wp/v2"
|
||||
private const val PROJECTS_PER_PAGE = 18
|
||||
private const val DEFAULT_ORDERBY = 3
|
||||
private const val DEFAULT_FIELDS = "title,thumbnail,link"
|
||||
private const val PROJECT_NOT_FOUND = "Projeto não encontrado."
|
||||
private const val CHAPTERS_NOT_FOUND = "Capítulos não encontrados."
|
||||
private const val EXCEEDED_GOOGLE_DRIVE_VIEW_LIMIT = "Limite de visualizações atingido " +
|
||||
"no Google Drive. Aguarde com que o limite seja reestabelecido."
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
package eu.kanade.tachiyomi.extension.pt.taosect
|
||||
|
||||
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 TaoSectUrlActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
if (pathSegments != null && pathSegments.size > 1) {
|
||||
val projectSlug = pathSegments[1]
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", TaoSect.SLUG_PREFIX_SEARCH + projectSlug)
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e("TaoSectUrlActivity", e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e("TaoSectUrlActivity", "Could not parse URI from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user