Nekopost fix (#10423)
* Add Cat300 Source * Fix Nekopost after old Api is Outdated
This commit is contained in:
parent
22ce75ab3f
commit
4851bad1d6
|
@ -27,12 +27,12 @@ import java.util.Locale
|
||||||
|
|
||||||
class Nekopost : ParsedHttpSource() {
|
class Nekopost : ParsedHttpSource() {
|
||||||
private val json: Json by injectLazy()
|
private val json: Json by injectLazy()
|
||||||
override val baseUrl: String = "https://www.nekopost.net/project"
|
override val baseUrl: String = "https://www.nekopost.net/manga/"
|
||||||
|
|
||||||
private val latestMangaEndpoint: String =
|
private val latestMangaEndpoint: String =
|
||||||
"https://tuner.nekopost.net/ApiTest/getLatestChapterOffset/m"
|
"https://uatapi.nekopost.net/frontAPI/getLatestChapter/m"
|
||||||
private val projectDataEndpoint: String =
|
private val projectDataEndpoint: String =
|
||||||
"https://tuner.nekopost.net/ApiTest/getProjectDetailFull"
|
"https://uatapi.nekopost.net/frontAPI/getProjectInfo"
|
||||||
private val fileHost: String = "https://fs.nekopost.net"
|
private val fileHost: String = "https://fs.nekopost.net"
|
||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
@ -87,17 +87,20 @@ class Nekopost : ParsedHttpSource() {
|
||||||
|
|
||||||
manga.apply {
|
manga.apply {
|
||||||
projectInfo.projectInfo.let {
|
projectInfo.projectInfo.let {
|
||||||
url = it.npProjectId
|
url = it.projectId
|
||||||
title = it.npName
|
title = it.projectName
|
||||||
artist = it.artistName
|
artist = it.artistName
|
||||||
author = it.authorName
|
author = it.authorName
|
||||||
description = it.npInfo
|
description = it.info
|
||||||
status = getStatus(it.npStatus)
|
status = getStatus(it.status)
|
||||||
initialized = true
|
initialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
genre =
|
genre = if (projectInfo.projectCategoryUsed != null) {
|
||||||
projectInfo.projectCategoryUsed.joinToString(", ") { it.npcName }
|
projectInfo.projectCategoryUsed.joinToString(", ") { it.categoryName }
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,17 +115,24 @@ class Nekopost : ParsedHttpSource() {
|
||||||
?: throw Error("Unable to fetch manga detail of ${manga.title}")
|
?: throw Error("Unable to fetch manga detail of ${manga.title}")
|
||||||
val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string())
|
val projectInfo: RawProjectInfo = json.decodeFromString(responseBody.string())
|
||||||
|
|
||||||
projectInfo.projectChapterList.map { chapter ->
|
manga.status = getStatus(projectInfo.projectInfo.status)
|
||||||
|
|
||||||
|
if (manga.status == SManga.LICENSED) {
|
||||||
|
throw Exception("Licensed - No chapter to show")
|
||||||
|
}
|
||||||
|
|
||||||
|
projectInfo.projectChapterList!!.map { chapter ->
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = "${manga.url}/${chapter.ncChapterId}/${chapter.ncDataFile}"
|
url =
|
||||||
name = chapter.ncChapterName
|
"${manga.url}/${chapter.chapterId}/${manga.url}_${chapter.chapterId}.json"
|
||||||
|
name = chapter.chapterName
|
||||||
date_upload = SimpleDateFormat(
|
date_upload = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss",
|
"yyyy-MM-dd HH:mm:ss",
|
||||||
Locale("th")
|
Locale("th")
|
||||||
).parse(chapter.ncCreatedDate)?.time
|
).parse(chapter.createDate)?.time
|
||||||
?: 0L
|
?: 0L
|
||||||
chapter_number = chapter.ncChapterNo.toFloat()
|
chapter_number = chapter.chapterNo.toFloat()
|
||||||
scanlator = chapter.cuDisplayname
|
scanlator = chapter.providerName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,10 +151,14 @@ class Nekopost : ParsedHttpSource() {
|
||||||
val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string())
|
val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string())
|
||||||
|
|
||||||
chapterInfo.pageItem.map { page ->
|
chapterInfo.pageItem.map { page ->
|
||||||
val fileName = page.fileName ?: page.pageName
|
val imgUrl: String = if (page.pageName != null) {
|
||||||
|
"$fileHost/collectManga/${chapterInfo.projectId}/${chapterInfo.chapterId}/${page.pageName}"
|
||||||
|
} else {
|
||||||
|
"$fileHost/collectManga/${chapterInfo.projectId}/${chapterInfo.chapterId}/${page.fileName}"
|
||||||
|
}
|
||||||
Page(
|
Page(
|
||||||
index = page.pageNo,
|
index = page.pageNo,
|
||||||
imageUrl = "$fileHost/collectManga/${chapterInfo.projectId}/${chapterInfo.chapterId}/$fileName",
|
imageUrl = imgUrl
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,14 +177,14 @@ class Nekopost : ParsedHttpSource() {
|
||||||
val projectList: RawProjectSummaryList = json.decodeFromString(responseBody.string())
|
val projectList: RawProjectSummaryList = json.decodeFromString(responseBody.string())
|
||||||
|
|
||||||
val mangaList: List<SManga> =
|
val mangaList: List<SManga> =
|
||||||
projectList.listItem
|
projectList.listChapter
|
||||||
?.filter { !existingProject.contains(it.npProjectId) }
|
?.filter { !existingProject.contains(it.projectId) }
|
||||||
?.map {
|
?.map {
|
||||||
SManga.create().apply {
|
SManga.create().apply {
|
||||||
url = it.npProjectId
|
url = it.projectId
|
||||||
title = it.npName
|
title = it.projectName
|
||||||
thumbnail_url =
|
thumbnail_url =
|
||||||
"$fileHost/collectManga/${it.npProjectId}/${it.npProjectId}_cover.jpg"
|
"$fileHost/collectManga/${it.projectId}/${it.projectId}_cover.jpg"
|
||||||
initialized = false
|
initialized = false
|
||||||
status = 0
|
status = 0
|
||||||
}
|
}
|
||||||
|
@ -201,7 +215,8 @@ class Nekopost : ParsedHttpSource() {
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
val responseBody = response.body ?: throw Error("Unable to fetch title list")
|
val responseBody = response.body ?: throw Error("Unable to fetch title list")
|
||||||
val projectList: List<RawProjectNameListItem> = json.decodeFromString(responseBody.string())
|
val projectList: List<RawProjectNameListItem> =
|
||||||
|
json.decodeFromString(responseBody.string())
|
||||||
|
|
||||||
val mangaList: List<SManga> = projectList.filter { project ->
|
val mangaList: List<SManga> = projectList.filter { project ->
|
||||||
Regex(
|
Regex(
|
||||||
|
|
|
@ -6,7 +6,6 @@ import kotlinx.serialization.Serializable
|
||||||
data class RawChapterInfo(
|
data class RawChapterInfo(
|
||||||
val chapterId: Int,
|
val chapterId: Int,
|
||||||
val chapterNo: String,
|
val chapterNo: String,
|
||||||
val pageCount: Int,
|
|
||||||
val pageItem: List<RawPageItem>,
|
val pageItem: List<RawPageItem>,
|
||||||
val projectId: String
|
val projectId: String
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,10 +4,8 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawPageItem(
|
data class RawPageItem(
|
||||||
val id: Int? = null,
|
|
||||||
// workaround for https://github.com/Kotlin/kotlinx.serialization/pull/1473
|
|
||||||
val fileName: String? = null,
|
|
||||||
val pageName: String? = null,
|
val pageName: String? = null,
|
||||||
|
val fileName: String? = null,
|
||||||
val height: Int,
|
val height: Int,
|
||||||
val pageNo: Int,
|
val pageNo: Int,
|
||||||
val width: Int
|
val width: Int
|
||||||
|
|
|
@ -5,8 +5,8 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectCategory(
|
data class RawProjectCategory(
|
||||||
@SerialName("npc_name")
|
@SerialName("cateName")
|
||||||
val npcName: String,
|
val categoryName: String,
|
||||||
@SerialName("npc_name_link")
|
@SerialName("cateLink")
|
||||||
val npcNameLink: String
|
val categoryLink: String
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,24 +1,14 @@
|
||||||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectChapter(
|
data class RawProjectChapter(
|
||||||
@SerialName("cu_displayname")
|
val chapterId: String?,
|
||||||
val cuDisplayname: String,
|
val chapterNo: String,
|
||||||
@SerialName("nc_chapter_id")
|
val chapterName: String,
|
||||||
val ncChapterId: String,
|
val status: String,
|
||||||
@SerialName("nc_chapter_name")
|
val publishDate: String,
|
||||||
val ncChapterName: String,
|
val createDate: String,
|
||||||
@SerialName("nc_chapter_no")
|
val providerName: String,
|
||||||
val ncChapterNo: String,
|
|
||||||
@SerialName("nc_created_date")
|
|
||||||
val ncCreatedDate: String,
|
|
||||||
@SerialName("nc_data_file")
|
|
||||||
val ncDataFile: String,
|
|
||||||
@SerialName("nc_owner_id")
|
|
||||||
val ncOwnerId: String,
|
|
||||||
@SerialName("nc_provider")
|
|
||||||
val ncProvider: String
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectInfo(
|
data class RawProjectInfo(
|
||||||
val code: String,
|
@SerialName("code")
|
||||||
val projectCategoryUsed: List<RawProjectCategory>,
|
val code: Int,
|
||||||
val projectChapterList: List<RawProjectChapter>,
|
@SerialName("listCate")
|
||||||
|
val projectCategoryUsed: List<RawProjectCategory>?,
|
||||||
|
@SerialName("listChapter")
|
||||||
|
val projectChapterList: List<RawProjectChapter>?,
|
||||||
|
@SerialName("projectInfo")
|
||||||
val projectInfo: RawProjectInfoData
|
val projectInfo: RawProjectInfoData
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,34 +5,24 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectInfoData(
|
data class RawProjectInfoData(
|
||||||
@SerialName("artist_name")
|
@SerialName("projectId")
|
||||||
val artistName: String,
|
val projectId: String,
|
||||||
@SerialName("author_name")
|
@SerialName("projectName")
|
||||||
|
val projectName: String,
|
||||||
|
@SerialName("aliasName")
|
||||||
|
val aliasName: String,
|
||||||
|
@SerialName("website")
|
||||||
|
val website: String,
|
||||||
|
@SerialName("authorName")
|
||||||
val authorName: String,
|
val authorName: String,
|
||||||
@SerialName("np_comment")
|
@SerialName("artistName")
|
||||||
val npComment: String,
|
val artistName: String,
|
||||||
@SerialName("np_created_date")
|
@SerialName("info")
|
||||||
val npCreatedDate: String,
|
val info: String,
|
||||||
@SerialName("np_flag_mature")
|
@SerialName("status")
|
||||||
val npFlagMature: String,
|
val status: String,
|
||||||
@SerialName("np_info")
|
@SerialName("flgMature")
|
||||||
val npInfo: String,
|
val flgMature: String,
|
||||||
@SerialName("np_licenced_by")
|
@SerialName("releaseDate")
|
||||||
val npLicencedBy: String,
|
val releaseDate: String,
|
||||||
@SerialName("np_name")
|
|
||||||
val npName: String,
|
|
||||||
@SerialName("np_name_link")
|
|
||||||
val npNameLink: String,
|
|
||||||
@SerialName("np_project_id")
|
|
||||||
val npProjectId: String,
|
|
||||||
@SerialName("np_status")
|
|
||||||
val npStatus: String,
|
|
||||||
@SerialName("np_type")
|
|
||||||
val npType: String,
|
|
||||||
@SerialName("np_updated_date")
|
|
||||||
val npUpdatedDate: String,
|
|
||||||
@SerialName("np_view")
|
|
||||||
val npView: String,
|
|
||||||
@SerialName("np_web")
|
|
||||||
val npWeb: String
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,30 +1,16 @@
|
||||||
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
package eu.kanade.tachiyomi.extension.th.nekopost.model
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectSummary(
|
data class RawProjectSummary(
|
||||||
@SerialName("nc_chapter_cover")
|
val cover: String,
|
||||||
val ncChapterCover: String,
|
val chapterId: String,
|
||||||
@SerialName("nc_chapter_id")
|
val chapterName: String,
|
||||||
val ncChapterId: String,
|
val chapterNo: String,
|
||||||
@SerialName("nc_chapter_name")
|
val createDate: String,
|
||||||
val ncChapterName: String,
|
val providerName: String,
|
||||||
@SerialName("nc_chapter_no")
|
|
||||||
val ncChapterNo: String,
|
|
||||||
@SerialName("nc_created_date")
|
|
||||||
val ncCreatedDate: String,
|
|
||||||
@SerialName("nc_provider")
|
|
||||||
val ncProvider: String,
|
|
||||||
@SerialName("no_new_chapter")
|
|
||||||
val noNewChapter: String,
|
val noNewChapter: String,
|
||||||
@SerialName("np_group_dir")
|
val projectName: String,
|
||||||
val npGroupDir: String,
|
val projectId: String
|
||||||
@SerialName("np_name")
|
|
||||||
val npName: String,
|
|
||||||
@SerialName("np_name_link")
|
|
||||||
val npNameLink: String,
|
|
||||||
@SerialName("np_project_id")
|
|
||||||
val npProjectId: String
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,6 +4,6 @@ import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RawProjectSummaryList(
|
data class RawProjectSummaryList(
|
||||||
val code: String,
|
val code: Int,
|
||||||
val listItem: List<RawProjectSummary>?
|
val listChapter: List<RawProjectSummary>?
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue