|
|
|
@ -5,11 +5,13 @@ import kotlinx.coroutines.coroutineScope
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.MangaSourceParser
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
import org.koitharu.kotatsu.parsers.model.Manga
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaParserSource
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaState
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaState
|
|
|
|
import org.koitharu.kotatsu.parsers.model.RATING_UNKNOWN
|
|
|
|
import org.koitharu.kotatsu.parsers.model.RATING_UNKNOWN
|
|
|
|
import org.koitharu.kotatsu.parsers.site.wpcomics.WpComicsParser
|
|
|
|
import org.koitharu.kotatsu.parsers.site.wpcomics.WpComicsParser
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
import org.koitharu.kotatsu.parsers.util.*
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
|
|
|
|
|
|
|
@MangaSourceParser("NETTRUYENVIE", "NetTruyenVie", "vi")
|
|
|
|
@MangaSourceParser("NETTRUYENVIE", "NetTruyenVie", "vi")
|
|
|
|
internal class NetTruyenVie(context: MangaLoaderContext) :
|
|
|
|
internal class NetTruyenVie(context: MangaLoaderContext) :
|
|
|
|
@ -17,9 +19,10 @@ internal class NetTruyenVie(context: MangaLoaderContext) :
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun getDetails(manga: Manga): Manga = coroutineScope {
|
|
|
|
override suspend fun getDetails(manga: Manga): Manga = coroutineScope {
|
|
|
|
val fullUrl = manga.url.toAbsoluteUrl(domain)
|
|
|
|
val fullUrl = manga.url.toAbsoluteUrl(domain)
|
|
|
|
val doc = webClient.httpGet(fullUrl).parseHtml()
|
|
|
|
val docDeferred = async { webClient.httpGet(fullUrl).parseHtml() }
|
|
|
|
val chaptersDeferred = async { getChapters(doc) }
|
|
|
|
val chaptersDeferred = async { fetchChapters(manga.url) }
|
|
|
|
val tagMap = getOrCreateTagMap()
|
|
|
|
val tagMap = getOrCreateTagMap()
|
|
|
|
|
|
|
|
val doc = docDeferred.await()
|
|
|
|
val tagsElement = doc.select("li.kind p.col-xs-8 a")
|
|
|
|
val tagsElement = doc.select("li.kind p.col-xs-8 a")
|
|
|
|
val mangaTags = tagsElement.mapNotNullToSet { tagMap[it.text()] }
|
|
|
|
val mangaTags = tagsElement.mapNotNullToSet { tagMap[it.text()] }
|
|
|
|
manga.copy(
|
|
|
|
manga.copy(
|
|
|
|
@ -38,4 +41,29 @@ internal class NetTruyenVie(context: MangaLoaderContext) :
|
|
|
|
chapters = chaptersDeferred.await(),
|
|
|
|
chapters = chaptersDeferred.await(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private suspend fun fetchChapters(mangaUrl: String): List<MangaChapter> {
|
|
|
|
|
|
|
|
val slug = mangaUrl.substringAfterLast('/')
|
|
|
|
|
|
|
|
val chaptersUrl = "/Comic/Services/ComicService.asmx/ChapterList?slug=$slug".toAbsoluteUrl(domain)
|
|
|
|
|
|
|
|
val df = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val data = webClient.httpGet(chaptersUrl).parseJson().getJSONArray("data")
|
|
|
|
|
|
|
|
return List(data.length()) { i ->
|
|
|
|
|
|
|
|
val jo = data.getJSONObject(data.length() - 1 - i)
|
|
|
|
|
|
|
|
val chapterSlug = jo.getString("chapter_slug")
|
|
|
|
|
|
|
|
val chapterUrl = "/truyen-tranh/$slug/$chapterSlug"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MangaChapter(
|
|
|
|
|
|
|
|
id = generateUid(chapterUrl),
|
|
|
|
|
|
|
|
name = jo.getString("chapter_name"),
|
|
|
|
|
|
|
|
number = i + 1f,
|
|
|
|
|
|
|
|
volume = 0,
|
|
|
|
|
|
|
|
url = chapterUrl,
|
|
|
|
|
|
|
|
scanlator = null,
|
|
|
|
|
|
|
|
uploadDate = df.tryParse(jo.getString("updated_at")),
|
|
|
|
|
|
|
|
branch = null,
|
|
|
|
|
|
|
|
source = source,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|