Nekopost fix (#10423)

* Add Cat300 Source

* Fix Nekopost after old Api is Outdated
This commit is contained in:
Promchai Chooseang 2022-01-10 23:58:35 +07:00 committed by GitHub
parent 22ce75ab3f
commit 4851bad1d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 87 additions and 104 deletions

View File

@ -27,12 +27,12 @@ import java.util.Locale
class Nekopost : ParsedHttpSource() {
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 =
"https://tuner.nekopost.net/ApiTest/getLatestChapterOffset/m"
"https://uatapi.nekopost.net/frontAPI/getLatestChapter/m"
private val projectDataEndpoint: String =
"https://tuner.nekopost.net/ApiTest/getProjectDetailFull"
"https://uatapi.nekopost.net/frontAPI/getProjectInfo"
private val fileHost: String = "https://fs.nekopost.net"
override val client: OkHttpClient = network.cloudflareClient
@ -87,17 +87,20 @@ class Nekopost : ParsedHttpSource() {
manga.apply {
projectInfo.projectInfo.let {
url = it.npProjectId
title = it.npName
url = it.projectId
title = it.projectName
artist = it.artistName
author = it.authorName
description = it.npInfo
status = getStatus(it.npStatus)
description = it.info
status = getStatus(it.status)
initialized = true
}
genre =
projectInfo.projectCategoryUsed.joinToString(", ") { it.npcName }
genre = if (projectInfo.projectCategoryUsed != null) {
projectInfo.projectCategoryUsed.joinToString(", ") { it.categoryName }
} else {
""
}
}
}
}
@ -112,17 +115,24 @@ class Nekopost : ParsedHttpSource() {
?: throw Error("Unable to fetch manga detail of ${manga.title}")
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 {
url = "${manga.url}/${chapter.ncChapterId}/${chapter.ncDataFile}"
name = chapter.ncChapterName
url =
"${manga.url}/${chapter.chapterId}/${manga.url}_${chapter.chapterId}.json"
name = chapter.chapterName
date_upload = SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss",
Locale("th")
).parse(chapter.ncCreatedDate)?.time
).parse(chapter.createDate)?.time
?: 0L
chapter_number = chapter.ncChapterNo.toFloat()
scanlator = chapter.cuDisplayname
chapter_number = chapter.chapterNo.toFloat()
scanlator = chapter.providerName
}
}
}
@ -141,10 +151,14 @@ class Nekopost : ParsedHttpSource() {
val chapterInfo: RawChapterInfo = json.decodeFromString(responseBody.string())
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(
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 mangaList: List<SManga> =
projectList.listItem
?.filter { !existingProject.contains(it.npProjectId) }
projectList.listChapter
?.filter { !existingProject.contains(it.projectId) }
?.map {
SManga.create().apply {
url = it.npProjectId
title = it.npName
url = it.projectId
title = it.projectName
thumbnail_url =
"$fileHost/collectManga/${it.npProjectId}/${it.npProjectId}_cover.jpg"
"$fileHost/collectManga/${it.projectId}/${it.projectId}_cover.jpg"
initialized = false
status = 0
}
@ -201,7 +215,8 @@ class Nekopost : ParsedHttpSource() {
.asObservableSuccess()
.map { response ->
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 ->
Regex(

View File

@ -6,7 +6,6 @@ import kotlinx.serialization.Serializable
data class RawChapterInfo(
val chapterId: Int,
val chapterNo: String,
val pageCount: Int,
val pageItem: List<RawPageItem>,
val projectId: String
)

View File

@ -4,10 +4,8 @@ import kotlinx.serialization.Serializable
@Serializable
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 fileName: String? = null,
val height: Int,
val pageNo: Int,
val width: Int

View File

@ -5,8 +5,8 @@ import kotlinx.serialization.Serializable
@Serializable
data class RawProjectCategory(
@SerialName("npc_name")
val npcName: String,
@SerialName("npc_name_link")
val npcNameLink: String
@SerialName("cateName")
val categoryName: String,
@SerialName("cateLink")
val categoryLink: String
)

View File

@ -1,24 +1,14 @@
package eu.kanade.tachiyomi.extension.th.nekopost.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class RawProjectChapter(
@SerialName("cu_displayname")
val cuDisplayname: String,
@SerialName("nc_chapter_id")
val ncChapterId: String,
@SerialName("nc_chapter_name")
val ncChapterName: String,
@SerialName("nc_chapter_no")
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
val chapterId: String?,
val chapterNo: String,
val chapterName: String,
val status: String,
val publishDate: String,
val createDate: String,
val providerName: String,
)

View File

@ -1,11 +1,16 @@
package eu.kanade.tachiyomi.extension.th.nekopost.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class RawProjectInfo(
val code: String,
val projectCategoryUsed: List<RawProjectCategory>,
val projectChapterList: List<RawProjectChapter>,
@SerialName("code")
val code: Int,
@SerialName("listCate")
val projectCategoryUsed: List<RawProjectCategory>?,
@SerialName("listChapter")
val projectChapterList: List<RawProjectChapter>?,
@SerialName("projectInfo")
val projectInfo: RawProjectInfoData
)

View File

@ -5,34 +5,24 @@ import kotlinx.serialization.Serializable
@Serializable
data class RawProjectInfoData(
@SerialName("artist_name")
val artistName: String,
@SerialName("author_name")
@SerialName("projectId")
val projectId: String,
@SerialName("projectName")
val projectName: String,
@SerialName("aliasName")
val aliasName: String,
@SerialName("website")
val website: String,
@SerialName("authorName")
val authorName: String,
@SerialName("np_comment")
val npComment: String,
@SerialName("np_created_date")
val npCreatedDate: String,
@SerialName("np_flag_mature")
val npFlagMature: String,
@SerialName("np_info")
val npInfo: String,
@SerialName("np_licenced_by")
val npLicencedBy: 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
@SerialName("artistName")
val artistName: String,
@SerialName("info")
val info: String,
@SerialName("status")
val status: String,
@SerialName("flgMature")
val flgMature: String,
@SerialName("releaseDate")
val releaseDate: String,
)

View File

@ -1,30 +1,16 @@
package eu.kanade.tachiyomi.extension.th.nekopost.model
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class RawProjectSummary(
@SerialName("nc_chapter_cover")
val ncChapterCover: String,
@SerialName("nc_chapter_id")
val ncChapterId: String,
@SerialName("nc_chapter_name")
val ncChapterName: 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 cover: String,
val chapterId: String,
val chapterName: String,
val chapterNo: String,
val createDate: String,
val providerName: String,
val noNewChapter: String,
@SerialName("np_group_dir")
val npGroupDir: String,
@SerialName("np_name")
val npName: String,
@SerialName("np_name_link")
val npNameLink: String,
@SerialName("np_project_id")
val npProjectId: String
val projectName: String,
val projectId: String
)

View File

@ -4,6 +4,6 @@ import kotlinx.serialization.Serializable
@Serializable
data class RawProjectSummaryList(
val code: String,
val listItem: List<RawProjectSummary>?
val code: Int,
val listChapter: List<RawProjectSummary>?
)