Add Nikkangecchan source (#1119)

This commit is contained in:
Alessandro Jean 2019-05-20 23:14:18 -03:00 committed by Eugene
parent 2ae9b607a9
commit 1fd6232af5
8 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,12 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
ext {
appName = 'Tachiyomi: Nikkangecchan'
pkgNameSuffix = 'ja.nikkangecchan'
extClass = '.Nikkangecchan'
extVersionCode = 1
libVersion = '1.2'
}
apply from: "$rootDir/common.gradle"

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -0,0 +1,124 @@
package eu.kanade.tachiyomi.extension.ja.nikkangecchan
import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.source.model.*
import eu.kanade.tachiyomi.source.online.ParsedHttpSource
import okhttp3.*
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
class Nikkangecchan : ParsedHttpSource() {
override val name = "Nikkangecchan"
override val baseUrl = "https://nikkangecchan.jp"
override val lang = "ja"
override val supportsLatest = false
private val catalogHeaders = Headers.Builder()
.apply {
add("User-Agent", USER_AGENT)
add("Referer", baseUrl)
}
.build()
override fun popularMangaRequest(page: Int): Request = GET(baseUrl, catalogHeaders)
override fun popularMangaSelector(): String = ".contentInner > figure"
override fun popularMangaFromElement(element: Element): SManga {
val imgBox = element.select(".imgBox").first()
val detailBox = element.select(".detailBox").last()
return SManga.create().apply {
title = detailBox.select("h3").first().text()
thumbnail_url = baseUrl + imgBox.select("a > img").first().attr("src")
setUrlWithoutDomain(baseUrl + imgBox.select("a").first().attr("href"))
}
}
override fun popularMangaNextPageSelector(): String? = null
override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable<MangasPage> {
return super.fetchSearchManga(page, query, filters)
.map {
val filtered = it.mangas.filter{ e -> e.title.contains(query, true) }
MangasPage(filtered, false)
}
}
// Does not have search, use complete list (in popular) instead.
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request
= popularMangaRequest(page)
override fun searchMangaSelector() = popularMangaSelector()
override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element)
override fun searchMangaNextPageSelector(): String? = null
override fun mangaDetailsParse(document: Document): SManga {
val detailBox = document.select("#comicDetail .detailBox")
return SManga.create().apply {
title = detailBox.select("h3").first().text()
author = detailBox.select(".author").first().text()
artist = detailBox.select(".author").first().text()
description = document.select(".description").first().text()
status = SManga.ONGOING
}
}
override fun chapterListSelector(): String = ".episodeBox"
override fun chapterListParse(response: Response): List<SChapter>
= super.chapterListParse(response).reversed()
override fun chapterFromElement(element: Element): SChapter {
val episodePage = element.select(".episode-page").first()
val title = element.select("h4.episodeTitle").first().text()
val dataTitle = episodePage.attr("data-title").substringBefore("|").trim()
return SChapter.create().apply {
name = "$title - $dataTitle"
chapter_number = element.select("h4.episodeTitle").first().text().toFloatOrNull() ?: 0f
scanlator = "Akita Publishing"
setUrlWithoutDomain(baseUrl + episodePage.attr("data-src").substringBeforeLast("/"))
}
}
override fun fetchPageList(chapter: SChapter): Observable<List<Page>> {
return Observable.just(listOf(Page(0, chapter.url, "$baseUrl${chapter.url}/image")))
}
override fun imageUrlParse(document: Document) = ""
override fun imageRequest(page: Page): Request {
val headers = Headers.Builder()
.apply {
add("User-Agent", USER_AGENT)
add("Referer", baseUrl + page.url.substringBeforeLast("/"))
}
return GET(page.imageUrl!!, headers.build())
}
override fun latestUpdatesSelector() = ""
override fun latestUpdatesRequest(page: Int): Request = throw Exception("This method should not be called!")
override fun latestUpdatesFromElement(element: Element): SManga = throw Exception("This method should not be called!")
override fun latestUpdatesNextPageSelector(): String? = null
override fun pageListRequest(chapter: SChapter): Request = throw Exception("This method should not be called!")
override fun pageListParse(document: Document): List<Page> = throw Exception("This method should not be called!")
companion object {
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36"
}
}