UnionMangas - Implement Url Intent, fix url (#2787)
UnionMangas - Implement Url Intent and Fix Base Url
This commit is contained in:
parent
32ec0a2eae
commit
eefbc2896b
|
@ -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=".UnionMangasUrlActivity"
|
||||
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="unionleitor.top"
|
||||
android:pathPattern="/perfil-manga/..*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
|
@ -5,7 +5,7 @@ ext {
|
|||
appName = 'Tachiyomi: Union Mangás'
|
||||
pkgNameSuffix = 'pt.unionmangas'
|
||||
extClass = '.UnionMangas'
|
||||
extVersionCode = 12
|
||||
extVersionCode = 13
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.google.gson.JsonObject
|
|||
import com.google.gson.JsonParser
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.source.model.*
|
||||
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
|
||||
import okhttp3.FormBody
|
||||
|
@ -17,6 +18,7 @@ import okhttp3.Request
|
|||
import okhttp3.Response
|
||||
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
|
||||
|
@ -29,7 +31,7 @@ class UnionMangas : ParsedHttpSource() {
|
|||
|
||||
override val name = "Union Mangás"
|
||||
|
||||
override val baseUrl = "https://unionmangas.top"
|
||||
override val baseUrl = "https://unionleitor.top"
|
||||
|
||||
override val lang = "pt-BR"
|
||||
|
||||
|
@ -46,7 +48,7 @@ class UnionMangas : ParsedHttpSource() {
|
|||
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||
.add("User-Agent", USER_AGENT)
|
||||
.add("Origin", baseUrl)
|
||||
.add("Referer", "$baseUrl/ax")
|
||||
.add("Referer", "$baseUrl/xz")
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
val newHeaders = headersBuilder()
|
||||
|
@ -181,6 +183,25 @@ class UnionMangas : ParsedHttpSource() {
|
|||
|
||||
override fun searchMangaNextPageSelector() = throw Exception("This method should not be called!")
|
||||
|
||||
private fun searchMangaByIdRequest(id: String) = GET("$baseUrl/perfil-manga/$id", headers)
|
||||
|
||||
private fun searchMangaByIdParse(response: Response, id: String): MangasPage {
|
||||
val details = mangaDetailsParse(response)
|
||||
details.url = "/perfil-manga/$id"
|
||||
return MangasPage(listOf(details), false)
|
||||
}
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
return if (query.startsWith(PREFIX_ID_SEARCH)) {
|
||||
val id = query.removePrefix(PREFIX_ID_SEARCH)
|
||||
client.newCall(searchMangaByIdRequest(id))
|
||||
.asObservableSuccess()
|
||||
.map { response -> searchMangaByIdParse(response, id) }
|
||||
} else {
|
||||
super.fetchSearchManga(page, query, filters)
|
||||
}
|
||||
}
|
||||
|
||||
private fun SimpleDateFormat.tryParseTime(date: String) : Long {
|
||||
return try {
|
||||
parse(date).time
|
||||
|
@ -200,6 +221,8 @@ class UnionMangas : ParsedHttpSource() {
|
|||
|
||||
private val JSON_PARSER by lazy { JsonParser() }
|
||||
|
||||
const val PREFIX_ID_SEARCH = "id:"
|
||||
|
||||
private val DATE_FORMATTER by lazy { SimpleDateFormat("(dd/MM/yyyy)", Locale.ENGLISH) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package eu.kanade.tachiyomi.extension.pt.unionmangas
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
/**
|
||||
* Springboard that accepts https://unionleitor.top/perfil-manga/xxxxxx intents and redirects them to
|
||||
* the main Tachiyomi process.
|
||||
*/
|
||||
class UnionMangasUrlActivity : 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", "${UnionMangas.PREFIX_ID_SEARCH}$id")
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e("UnionMangasUrl", e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e("UnionMangasUrl", "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue