Ru: Remanga. Fix branches publisher and pagination (#10854)

* Ru: Remanga. Fix branches publisher and pagination

* Ru: Remanga. Reorder tags. Manga type first
This commit is contained in:
Pavka 2022-02-18 01:21:28 +03:00 committed by GitHub
parent 11981cd25e
commit 5cf7db2594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 20 deletions

View File

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

View File

@ -8,6 +8,7 @@ import MangaDetDto
import MyLibraryDto import MyLibraryDto
import PageDto import PageDto
import PageWrapperDto import PageWrapperDto
import PublisherDto
import SeriesWrapperDto import SeriesWrapperDto
import TagsDto import TagsDto
import UserDto import UserDto
@ -219,10 +220,10 @@ class Remanga : ConfigurableSource, HttpSource() {
} }
} }
private fun parseType(type: TagsDto): TagsDto { private fun parseType(type: TagsDto): String {
return when (type.name) { return when (type.name) {
"Западный комикс" -> TagsDto(type.id, "Комикс") "Западный комикс" -> "Комикс"
else -> type else -> type.name
} }
} }
private fun parseAge(age_limit: Int): String { private fun parseAge(age_limit: Int): String {
@ -259,7 +260,7 @@ class Remanga : ConfigurableSource, HttpSource() {
altName = "Альтернативные названия:\n" + another_name + "\n\n" altName = "Альтернативные названия:\n" + another_name + "\n\n"
} }
this.description = rus_name + "\n" + ratingStar + " " + ratingValue + " (голосов: " + count_rating + ")\n" + altName + Jsoup.parse(o.description).text() this.description = rus_name + "\n" + ratingStar + " " + ratingValue + " (голосов: " + count_rating + ")\n" + altName + Jsoup.parse(o.description).text()
genre = (genres + categories + parseType(type)).joinToString { it.name } + ", " + parseAge(age_limit) genre = parseType(type) + ", " + parseAge(age_limit) + ", " + (genres + categories).joinToString { it.name }
status = parseStatus(o.status.id) status = parseStatus(o.status.id)
} }
} }
@ -317,18 +318,27 @@ class Remanga : ConfigurableSource, HttpSource() {
Observable.error(Exception("Лицензировано - Нет глав")) Observable.error(Exception("Лицензировано - Нет глав"))
} }
else -> { else -> {
val branchId = branch.maxByOrNull { selector(it) }!!.id val selectedBranch = branch.maxByOrNull { selector(it) }!!
client.newCall(chapterListRequest(branchId)) return (1..(selectedBranch.count_chapters / 100 + 1)).map {
.asObservableSuccess() val response = chapterListRequest(selectedBranch.id, it)
.map { response -> chapterListParse(response, selectedBranch.publishers)
chapterListParse(response) }.let { Observable.just(it.flatten()) }
}
} }
} }
} }
private fun chapterListRequest(branch: Long): Request { private fun chapterListRequest(branch: Long, page: Number): Response =
return GET("$baseUrl/api/titles/chapters/?branch_id=$branch", headers) client.newCall(
GET(
"$baseUrl/api/titles/chapters/?branch_id=$branch&page=$page&count=100",
headers
)
).execute().run {
if (!isSuccessful) {
close()
throw Exception("HTTP error $code")
}
this
} }
@SuppressLint("DefaultLocale") @SuppressLint("DefaultLocale")
@ -340,7 +350,8 @@ class Remanga : ConfigurableSource, HttpSource() {
return chapterName return chapterName
} }
override fun chapterListParse(response: Response): List<SChapter> { override fun chapterListParse(response: Response): List<SChapter> = throw NotImplementedError("Unused")
private fun chapterListParse(response: Response, publishers: List<PublisherDto>): List<SChapter> {
var chapters = json.decodeFromString<SeriesWrapperDto<List<BookDto>>>(response.body!!.string()).content var chapters = json.decodeFromString<SeriesWrapperDto<List<BookDto>>>(response.body!!.string()).content
if (!preferences.getBoolean(PAID_PREF, false)) { if (!preferences.getBoolean(PAID_PREF, false)) {
chapters = chapters.filter { !it.is_paid or (it.is_bought == true) } chapters = chapters.filter { !it.is_paid or (it.is_bought == true) }
@ -351,8 +362,8 @@ class Remanga : ConfigurableSource, HttpSource() {
name = chapterName(chapter) name = chapterName(chapter)
url = "/api/titles/chapters/${chapter.id}" url = "/api/titles/chapters/${chapter.id}"
date_upload = parseDate(chapter.upload_date) date_upload = parseDate(chapter.upload_date)
scanlator = if (chapter.publishers.isNotEmpty()) { scanlator = if (publishers.isNotEmpty()) {
chapter.publishers.joinToString { it.name } publishers.joinToString { it.name }
} else null } else null
} }
} }

View File

@ -9,7 +9,8 @@ data class TagsDto(
@Serializable @Serializable
data class BranchesDto( data class BranchesDto(
val id: Long, val id: Long,
val count_chapters: Int val count_chapters: Int,
val publishers: List<PublisherDto>
) )
@Serializable @Serializable
@ -90,8 +91,7 @@ data class BookDto(
val name: String, val name: String,
val upload_date: String, val upload_date: String,
val is_paid: Boolean, val is_paid: Boolean,
val is_bought: Boolean?, val is_bought: Boolean?
val publishers: List<PublisherDto>
) )
@Serializable @Serializable