Remanga alt search (#17099)

* [RU]Remanga alt search

* [RU]Remanga alt search

* exHeaders

* pages
This commit is contained in:
Eshlender 2023-07-13 21:52:44 +05:00 committed by GitHub
parent 37476be2fe
commit 1e2bce3809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 6 deletions

View File

@ -6,7 +6,7 @@ ext {
extName = 'Remanga'
pkgNameSuffix = 'ru.remanga'
extClass = '.Remanga'
extVersionCode = 75
extVersionCode = 76
}
dependencies {

View File

@ -10,13 +10,14 @@ import eu.kanade.tachiyomi.extension.ru.remanga.dto.BookDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.BranchesDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.ChunksPageDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.ExBookDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.ExLibraryDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.ExWrapperDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.LibraryDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.MangaDetDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.MyLibraryDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.PageDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.PageWrapperDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.PagesDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.SeriesExWrapperDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.SeriesWrapperDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.TagsDto
import eu.kanade.tachiyomi.extension.ru.remanga.dto.UserDto
@ -212,7 +213,14 @@ class Remanga : ConfigurableSource, HttpSource() {
override fun latestUpdatesParse(response: Response): MangasPage = searchMangaParse(response)
override fun searchMangaParse(response: Response): MangasPage {
if (response.request.url.toString().contains("/bookmarks/")) {
if (response.request.url.toString().contains(exManga)) {
val page = json.decodeFromString<ExWrapperDto<List<ExLibraryDto>>>(response.body.string())
val mangas = page.data.map {
it.toSManga()
}
return MangasPage(mangas, true)
} else if (response.request.url.toString().contains("/bookmarks/")) {
val page = json.decodeFromString<PageWrapperDto<MyLibraryDto>>(response.body.string())
val mangas = page.content.map {
it.title.toSManga()
@ -229,6 +237,13 @@ class Remanga : ConfigurableSource, HttpSource() {
return MangasPage(mangas, page.props.page < page.props.total_pages!!)
}
}
private fun ExLibraryDto.toSManga(): SManga =
SManga.create().apply {
// Do not change the title name to ensure work with a multilingual catalog!
title = name
url = "/api/titles/$dir/"
thumbnail_url = baseUrl + img
}
private fun LibraryDto.toSManga(): SManga =
SManga.create().apply {
@ -307,6 +322,11 @@ class Remanga : ConfigurableSource, HttpSource() {
url.setQueryParameter("count_chapters_gte", "0")
}
}
is RequireEX -> {
if (filter.state == 1) {
return GET("$exManga/manga?take=20&skip=${10 * (page - 1)}&name=$query", exHeaders())
}
}
else -> {}
}
}
@ -461,7 +481,7 @@ class Remanga : ConfigurableSource, HttpSource() {
else -> {
val mangaID = mangaIDs[manga.url.substringAfter("/api/titles/").substringBefore("/").substringBefore("?")]
val exChapters = if (preferences.getBoolean(exPAID_PREF, true)) {
json.decodeFromString<SeriesExWrapperDto<List<ExBookDto>>>(client.newCall(GET("$exManga/chapter/history/$mangaID", exHeaders())).execute().body.string()).data
json.decodeFromString<ExWrapperDto<List<ExBookDto>>>(client.newCall(GET("$exManga/chapter/history/$mangaID", exHeaders())).execute().body.string()).data
} else {
emptyList()
}
@ -570,7 +590,7 @@ class Remanga : ConfigurableSource, HttpSource() {
val heightEmptyChunks = 10
if (chapter.scanlator.equals("exmanga")) {
try {
val exPage = json.decodeFromString<SeriesExWrapperDto<List<List<PagesDto>>>>(body)
val exPage = json.decodeFromString<ExWrapperDto<List<List<PagesDto>>>>(body)
val result = mutableListOf<Page>()
exPage.data.forEach {
it.filter { page -> page.height > heightEmptyChunks }.forEach { page ->
@ -688,6 +708,7 @@ class Remanga : ConfigurableSource, HttpSource() {
private class AgeList(ages: List<CheckFilter>) : Filter.Group<CheckFilter>("Возрастное ограничение", ages)
override fun getFilterList() = FilterList(
RequireEX(),
OrderBy(),
GenreList(getGenreList()),
CategoryList(getCategoryList()),
@ -894,6 +915,11 @@ class Remanga : ConfigurableSource, HttpSource() {
"Только проекты с главами",
arrayOf("Да", "Все"),
)
private class RequireEX : Filter.Select<String>(
"Использовать поиск",
arrayOf("Remanga", "ExManga(без фильтров)"),
)
private var isEng: String? = preferences.getString(LANGUAGE_PREF, "eng")
override fun setupPreferenceScreen(screen: androidx.preference.PreferenceScreen) {
val userAgentSystem = androidx.preference.CheckBoxPreference(screen.context).apply {

View File

@ -97,7 +97,7 @@ data class BookDto(
)
@Serializable
data class SeriesExWrapperDto<T>(
data class ExWrapperDto<T>(
val data: T,
)
@ -108,6 +108,14 @@ data class ExBookDto(
val chapter: String,
)
@Serializable
data class ExLibraryDto(
val id: Long,
val dir: String,
val name: String = "Без названия",
val img: String?,
)
@Serializable
data class PagesDto(
val id: Int,