[RU]Remanga latestUpdates rebirth (#11534)
* [RU]Remanga latestUpdates rebirth * update User-Agent * correction string * correction criterion imageContentType
This commit is contained in:
parent
de019d7ad4
commit
c6e2e1eba1
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Remanga'
|
extName = 'Remanga'
|
||||||
pkgNameSuffix = 'ru.remanga'
|
pkgNameSuffix = 'ru.remanga'
|
||||||
extClass = '.Remanga'
|
extClass = '.Remanga'
|
||||||
extVersionCode = 47
|
extVersionCode = 48
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -8,6 +8,7 @@ import MangaDetDto
|
|||||||
import MyLibraryDto
|
import MyLibraryDto
|
||||||
import PageDto
|
import PageDto
|
||||||
import PageWrapperDto
|
import PageWrapperDto
|
||||||
|
import PageWrapperDtoNoLimit
|
||||||
import SeriesWrapperDto
|
import SeriesWrapperDto
|
||||||
import TagsDto
|
import TagsDto
|
||||||
import UserDto
|
import UserDto
|
||||||
@ -72,10 +73,10 @@ class Remanga : ConfigurableSource, HttpSource() {
|
|||||||
|
|
||||||
override val supportsLatest = true
|
override val supportsLatest = true
|
||||||
|
|
||||||
private val userAgentRandomizer = " ${Random.nextInt().absoluteValue}"
|
private val userAgentRandomizer = "${Random.nextInt().absoluteValue}"
|
||||||
|
|
||||||
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||||
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/78.0$userAgentRandomizer")
|
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.$userAgentRandomizer")
|
||||||
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/jxl,image/webp,*/*;q=0.8")
|
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/jxl,image/webp,*/*;q=0.8")
|
||||||
.add("Referer", baseUrl.replace("api.", ""))
|
.add("Referer", baseUrl.replace("api.", ""))
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ class Remanga : ConfigurableSource, HttpSource() {
|
|||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
val urlRequest = originalRequest.url.toString()
|
val urlRequest = originalRequest.url.toString()
|
||||||
val possibleType = urlRequest.substringAfterLast("/").split(".")
|
val possibleType = urlRequest.substringAfterLast("/").substringBefore("?").split(".")
|
||||||
return if (urlRequest.contains("/images/") and (possibleType.size == 2)) {
|
return if (urlRequest.contains("/images/") and (possibleType.size == 2)) {
|
||||||
val realType = possibleType[1]
|
val realType = possibleType[1]
|
||||||
val image = response.body?.byteString()?.toResponseBody("image/$realType".toMediaType())
|
val image = response.body?.byteString()?.toResponseBody("image/$realType".toMediaType())
|
||||||
@ -123,10 +124,16 @@ class Remanga : ConfigurableSource, HttpSource() {
|
|||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/api/titles/last-chapters/?page=$page&count=$count", headers)
|
override fun latestUpdatesRequest(page: Int): Request = GET("$baseUrl/api/titles/last-chapters/?page=$page&count=$count", headers)
|
||||||
|
|
||||||
override fun latestUpdatesParse(response: Response): MangasPage = searchMangaParse(response)
|
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||||
|
val page = json.decodeFromString<PageWrapperDtoNoLimit<LibraryDto>>(response.body!!.string())
|
||||||
|
val mangas = page.content.map {
|
||||||
|
it.toSManga()
|
||||||
|
}
|
||||||
|
return MangasPage(mangas, mangas.isNotEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchMangaParse(response: Response): MangasPage {
|
override fun searchMangaParse(response: Response): MangasPage {
|
||||||
if (response.request.url.toString().contains("bookmarks")) {
|
if (response.request.url.toString().contains("/bookmarks/")) {
|
||||||
val page = json.decodeFromString<PageWrapperDto<MyLibraryDto>>(response.body!!.string())
|
val page = json.decodeFromString<PageWrapperDto<MyLibraryDto>>(response.body!!.string())
|
||||||
val mangas = page.content.map {
|
val mangas = page.content.map {
|
||||||
it.title.toSManga()
|
it.title.toSManga()
|
||||||
@ -151,9 +158,11 @@ class Remanga : ConfigurableSource, HttpSource() {
|
|||||||
// Do not change the title name to ensure work with a multilingual catalog!
|
// Do not change the title name to ensure work with a multilingual catalog!
|
||||||
title = if (isEng.equals("rus")) rus_name else en_name
|
title = if (isEng.equals("rus")) rus_name else en_name
|
||||||
url = "/api/titles/$dir/"
|
url = "/api/titles/$dir/"
|
||||||
thumbnail_url = if (img.high.isNotEmpty()) {
|
thumbnail_url = if (img.high?.isNotEmpty() == true) {
|
||||||
baseUrl + img.high
|
baseUrl + img.high
|
||||||
} else baseUrl + img.mid
|
} else if (img.mid?.isNotEmpty() == true) {
|
||||||
|
baseUrl + img.mid
|
||||||
|
} else baseUrl + img.low
|
||||||
}
|
}
|
||||||
|
|
||||||
private val simpleDateFormat by lazy { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US) }
|
private val simpleDateFormat by lazy { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US) }
|
||||||
|
@ -14,9 +14,9 @@ data class BranchesDto(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ImgDto(
|
data class ImgDto(
|
||||||
val high: String,
|
val high: String? = null,
|
||||||
val mid: String,
|
val mid: String? = null,
|
||||||
val low: String
|
val low: String? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -61,7 +61,6 @@ data class MangaDetDto(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PropsDto(
|
data class PropsDto(
|
||||||
val total_items: Int,
|
|
||||||
val total_pages: Int,
|
val total_pages: Int,
|
||||||
val page: Int
|
val page: Int
|
||||||
)
|
)
|
||||||
@ -72,6 +71,11 @@ data class PageWrapperDto<T>(
|
|||||||
val props: PropsDto
|
val props: PropsDto
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class PageWrapperDtoNoLimit<T>(
|
||||||
|
val content: List<T>
|
||||||
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SeriesWrapperDto<T>(
|
data class SeriesWrapperDto<T>(
|
||||||
val content: T
|
val content: T
|
||||||
|
Loading…
x
Reference in New Issue
Block a user