Change latest API endpoint in Bilibili (#8445)
* Change latest API endpoint in Bilibili. * Remove unused DTOs.
This commit is contained in:
parent
1b9ccf1b0f
commit
53c9141f57
|
@ -6,7 +6,7 @@ ext {
|
|||
extName = 'Bilibili Comics'
|
||||
pkgNameSuffix = 'en.bilibilicomics'
|
||||
extClass = '.BilibiliComics'
|
||||
extVersionCode = 6
|
||||
extVersionCode = 7
|
||||
libVersion = '1.2'
|
||||
containsNsfw = true
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import rx.Observable
|
|||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.ParseException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
@ -55,9 +54,6 @@ class BilibiliComics : HttpSource() {
|
|||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
private val day: Int
|
||||
get() = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1
|
||||
|
||||
override fun popularMangaRequest(page: Int): Request {
|
||||
val requestPayload = buildJsonObject {
|
||||
put("area_id", -1)
|
||||
|
@ -103,7 +99,16 @@ class BilibiliComics : HttpSource() {
|
|||
}
|
||||
|
||||
override fun latestUpdatesRequest(page: Int): Request {
|
||||
val requestPayload = buildJsonObject { put("day", day) }
|
||||
val requestPayload = buildJsonObject {
|
||||
put("area_id", -1)
|
||||
put("is_finish", -1)
|
||||
put("is_free", 1)
|
||||
put("order", 1)
|
||||
put("page_num", page)
|
||||
put("page_size", POPULAR_PER_PAGE)
|
||||
put("style_id", -1)
|
||||
put("style_prefer", "[]")
|
||||
}
|
||||
val requestBody = requestPayload.toString().toRequestBody(JSON_MEDIA_TYPE)
|
||||
|
||||
val newHeaders = headersBuilder()
|
||||
|
@ -112,29 +117,29 @@ class BilibiliComics : HttpSource() {
|
|||
.build()
|
||||
|
||||
return POST(
|
||||
"$baseUrl/$BASE_API_ENDPOINT/GetSchedule?device=pc&platform=web",
|
||||
"$baseUrl/$BASE_API_ENDPOINT/ClassPage?device=pc&platform=web",
|
||||
headers = newHeaders,
|
||||
body = requestBody
|
||||
)
|
||||
}
|
||||
|
||||
override fun latestUpdatesParse(response: Response): MangasPage {
|
||||
val result = json.decodeFromString<BilibiliResultDto<BilibiliScheduleDto>>(response.body!!.string())
|
||||
val result = json.decodeFromString<BilibiliResultDto<List<BilibiliComicDto>>>(response.body!!.string())
|
||||
|
||||
if (result.code != 0) {
|
||||
return MangasPage(emptyList(), hasNextPage = false)
|
||||
}
|
||||
|
||||
val comicList = result.data!!.list
|
||||
.map(::latestMangaFromObject)
|
||||
val comicList = result.data!!.map(::latestMangaFromObject)
|
||||
val hasNextPage = comicList.size == POPULAR_PER_PAGE
|
||||
|
||||
return MangasPage(comicList, hasNextPage = false)
|
||||
return MangasPage(comicList, hasNextPage)
|
||||
}
|
||||
|
||||
private fun latestMangaFromObject(comic: BilibiliComicDto): SManga = SManga.create().apply {
|
||||
title = comic.title
|
||||
thumbnail_url = comic.verticalCover
|
||||
url = "/detail/mc${comic.comicId}"
|
||||
url = "/detail/mc${comic.seasonId}"
|
||||
}
|
||||
|
||||
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
|
||||
|
|
|
@ -10,16 +10,6 @@ data class BilibiliResultDto<T>(
|
|||
@SerialName("msg") val message: String = ""
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class BilibiliFeaturedDto(
|
||||
@SerialName("roll_six_comics") val rollSixComics: List<BilibiliComicDto> = emptyList()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class BilibiliScheduleDto(
|
||||
val list: List<BilibiliComicDto> = emptyList()
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class BilibiliSearchDto(
|
||||
val list: List<BilibiliComicDto> = emptyList()
|
||||
|
|
Loading…
Reference in New Issue