[RU] Libmanga. Fix latest page. Add intent to mangalib.me (#4923)
* [RU] Libmanga. Fix latest page. Add intent to mangalib.me * [Ru]Mangalib. Fix manga status * [Ru]Mangalib. More concrete intent Co-authored-by: pavkazzz <me@pavkazzz.ru>
This commit is contained in:
parent
3c473ea28d
commit
75695a9ee2
23
src/ru/libmanga/AndroidManifest.xml
Normal file
23
src/ru/libmanga/AndroidManifest.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".LibMangaActivity"
|
||||
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"/>
|
||||
|
||||
<!-- LibMangaActivity sites can be added here. -->
|
||||
<data
|
||||
android:scheme="https"
|
||||
android:host="mangalib.me"
|
||||
android:pathPattern="/..*/v..*/c..*/..*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
@ -5,7 +5,7 @@ ext {
|
||||
extName = 'MangaLib'
|
||||
pkgNameSuffix = 'ru.libmanga'
|
||||
extClass = '.LibManga'
|
||||
extVersionCode = 23
|
||||
extVersionCode = 24
|
||||
libVersion = '1.2'
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ class LibManga : ConfigurableSource, HttpSource() {
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET(baseUrl, headers)
|
||||
|
||||
private val latestUpdatesSelector = "div.updates__left"
|
||||
private val latestUpdatesSelector = "div.updates__item"
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val elements = response.asJsoup().select(latestUpdatesSelector)
|
||||
@ -121,13 +121,16 @@ class LibManga : ConfigurableSource, HttpSource() {
|
||||
}
|
||||
|
||||
private fun latestUpdatesFromElement(element: Element): SManga {
|
||||
val link = element.select("a").first()
|
||||
val img = link.select("img").first()
|
||||
val manga = SManga.create()
|
||||
manga.thumbnail_url = baseUrl + img.attr("data-src").substringAfter(baseUrl)
|
||||
.replace("cover_thumb", "cover_250x350")
|
||||
manga.setUrlWithoutDomain(link.attr("href"))
|
||||
manga.title = img.attr("alt")
|
||||
element.select("div.cover").first().let { img ->
|
||||
manga.thumbnail_url = baseUrl + img.attr("data-src").substringAfter(baseUrl)
|
||||
.replace("cover_thumb", "cover_250x350")
|
||||
}
|
||||
|
||||
element.select("a").first().let { link ->
|
||||
manga.setUrlWithoutDomain(link.attr("href"))
|
||||
manga.title = element.select("h4").first().text()
|
||||
}
|
||||
return manga
|
||||
}
|
||||
|
||||
@ -209,10 +212,11 @@ class LibManga : ConfigurableSource, HttpSource() {
|
||||
manga.author = body.select(".info-list__row:nth-child(2) > a").text()
|
||||
manga.artist = body.select(".info-list__row:nth-child(3) > a").text()
|
||||
manga.status = when (
|
||||
body.select(".info-list__row:has(strong:contains(Перевод))")
|
||||
body.select(".info-list__row:has(strong:contains(перевод))")
|
||||
.first()
|
||||
.select("span.m-label")
|
||||
.select("span")
|
||||
.text()
|
||||
.toLowerCase()
|
||||
) {
|
||||
"продолжается" -> SManga.ONGOING
|
||||
"завершен" -> SManga.COMPLETED
|
||||
@ -303,6 +307,29 @@ class LibManga : ConfigurableSource, HttpSource() {
|
||||
|
||||
override fun imageUrlParse(response: Response): String = ""
|
||||
|
||||
private fun searchMangaByIdRequest(id: String): Request {
|
||||
return GET("$baseUrl/$id", headers)
|
||||
}
|
||||
|
||||
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
|
||||
return if (query.startsWith(PREFIX_SLUG_SEARCH)) {
|
||||
val realQuery = query.removePrefix(PREFIX_SLUG_SEARCH)
|
||||
client.newCall(searchMangaByIdRequest(realQuery))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
val details = mangaDetailsParse(response)
|
||||
details.url = "/$realQuery"
|
||||
MangasPage(listOf(details), false)
|
||||
}
|
||||
} else {
|
||||
client.newCall(searchMangaRequest(page, query, filters))
|
||||
.asObservableSuccess()
|
||||
.map { response ->
|
||||
searchMangaParse(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
if (csrfToken.isEmpty()) {
|
||||
val tokenResponse = client.newCall(popularMangaRequest(page)).execute()
|
||||
@ -477,5 +504,6 @@ class LibManga : ConfigurableSource, HttpSource() {
|
||||
companion object {
|
||||
private const val SERVER_PREF_Title = "Сервер изображений"
|
||||
private const val SERVER_PREF = "MangaLibImageServer"
|
||||
const val PREFIX_SLUG_SEARCH = "slug:"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package eu.kanade.tachiyomi.extension.ru.libmanga
|
||||
|
||||
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://mangalib.me/xxx intents and redirects them to
|
||||
* the main tachiyomi process. The idea is to not install the intent filter unless
|
||||
* you have this extension installed, but still let the main tachiyomi app control
|
||||
* things.
|
||||
*/
|
||||
class LibMangaActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val pathSegments = intent?.data?.pathSegments
|
||||
if (pathSegments != null && pathSegments.size > 0) {
|
||||
val titleid = pathSegments[0]
|
||||
val mainIntent = Intent().apply {
|
||||
action = "eu.kanade.tachiyomi.SEARCH"
|
||||
putExtra("query", "${LibManga.PREFIX_SLUG_SEARCH}$titleid")
|
||||
putExtra("filter", packageName)
|
||||
}
|
||||
|
||||
try {
|
||||
startActivity(mainIntent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.e("LibMangaActivity", e.toString())
|
||||
}
|
||||
} else {
|
||||
Log.e("LibMangaActivity", "could not parse uri from intent $intent")
|
||||
}
|
||||
|
||||
finish()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user