diff --git a/src/en/tcbscans/build.gradle b/src/en/tcbscans/build.gradle new file mode 100644 index 000000000..1e1028d38 --- /dev/null +++ b/src/en/tcbscans/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + extName = 'TCB Scans' + pkgNameSuffix = 'en.tcbscans' + extClass = '.TCBScans' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/tcbscans/res/mipmap-hdpi/ic_launcher.png b/src/en/tcbscans/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..0c67d04bf Binary files /dev/null and b/src/en/tcbscans/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/tcbscans/res/mipmap-mdpi/ic_launcher.png b/src/en/tcbscans/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..99f8acbb0 Binary files /dev/null and b/src/en/tcbscans/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/tcbscans/res/mipmap-xhdpi/ic_launcher.png b/src/en/tcbscans/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..14a58b11d Binary files /dev/null and b/src/en/tcbscans/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/tcbscans/res/mipmap-xxhdpi/ic_launcher.png b/src/en/tcbscans/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..b35c60be7 Binary files /dev/null and b/src/en/tcbscans/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/tcbscans/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/tcbscans/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..caa4533f0 Binary files /dev/null and b/src/en/tcbscans/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/tcbscans/res/web_hi_res_512.png b/src/en/tcbscans/res/web_hi_res_512.png new file mode 100644 index 000000000..004348b0c Binary files /dev/null and b/src/en/tcbscans/res/web_hi_res_512.png differ diff --git a/src/en/tcbscans/src/eu/kanade/tachiyomi/extension/en/tcbscans/TCBScans.kt b/src/en/tcbscans/src/eu/kanade/tachiyomi/extension/en/tcbscans/TCBScans.kt new file mode 100644 index 000000000..2e188ea24 --- /dev/null +++ b/src/en/tcbscans/src/eu/kanade/tachiyomi/extension/en/tcbscans/TCBScans.kt @@ -0,0 +1,130 @@ +package eu.kanade.tachiyomi.extension.en.tcbscans + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.Page +import eu.kanade.tachiyomi.source.model.SChapter +import eu.kanade.tachiyomi.source.model.SManga +import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import okhttp3.OkHttpClient +import okhttp3.Request +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import java.util.Calendar + +class TCBScans : ParsedHttpSource() { + + override val name = "TCB Scans" + override val baseUrl = "https://onepiecechapters.com" + override val lang = "en" + override val supportsLatest = false + override val client: OkHttpClient = network.cloudflareClient + + // popular + override fun popularMangaRequest(page: Int): Request { + return GET(baseUrl) + } + + override fun popularMangaSelector() = "#page" + + override fun popularMangaFromElement(element: Element): SManga { + val manga = SManga.create() + manga.thumbnail_url = element.select(".mangainfo_body > img").attr("src") + manga.url = element.select("#primary-menu .menu-item:first-child").attr("href") + manga.title = element.select(".intro_content h2").text() + return manga + } + + override fun popularMangaNextPageSelector(): String? = null + + // latest + override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException() + + override fun latestUpdatesSelector(): String = throw UnsupportedOperationException() + + override fun latestUpdatesFromElement(element: Element): SManga = throw UnsupportedOperationException() + + override fun latestUpdatesNextPageSelector(): String? = throw UnsupportedOperationException() + + // search + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = popularMangaRequest(page) + + override fun searchMangaSelector(): String = popularMangaSelector() + + override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) + + override fun searchMangaNextPageSelector(): String? = null + + // manga details + override fun mangaDetailsParse(document: Document) = SManga.create().apply { + thumbnail_url = document.select(".mangainfo_body > img").attr("src") + title = document.select(".intro_content h2").text() + status = parseStatus(document.select(".intro_content").text()) + description = document.select(".intro_content").joinToString("\n") { it.text() } + } + + private fun parseStatus(element: String): Int = when { + element.toLowerCase().contains("ongoing (pub") -> SManga.ONGOING + element.toLowerCase().contains("completed (pub") -> SManga.COMPLETED + else -> SManga.UNKNOWN + } + + // chapters + override fun chapterListSelector() = "table.chap_tab tr" + + override fun chapterFromElement(element: Element): SChapter { + val urlElement = element.select("a").first() + val chapter = SChapter.create() + chapter.setUrlWithoutDomain(urlElement.attr("href")) + chapter.name = element.select("a").text() + chapter.date_upload = element.select("#time i").last()?.text()?.let { parseChapterDate(it) } + ?: 0 + return chapter + } + + private fun parseChapterDate(date: String): Long { + val dateWords: List = date.split(" ") + if (dateWords.size == 3) { + val timeAgo = Integer.parseInt(dateWords[0]) + val dates: Calendar = Calendar.getInstance() + when { + dateWords[1].contains("minute") -> { + dates.add(Calendar.MINUTE, -timeAgo) + } + dateWords[1].contains("hour") -> { + dates.add(Calendar.HOUR_OF_DAY, -timeAgo) + } + dateWords[1].contains("day") -> { + dates.add(Calendar.DAY_OF_YEAR, -timeAgo) + } + dateWords[1].contains("week") -> { + dates.add(Calendar.WEEK_OF_YEAR, -timeAgo) + } + dateWords[1].contains("month") -> { + dates.add(Calendar.MONTH, -timeAgo) + } + dateWords[1].contains("year") -> { + dates.add(Calendar.YEAR, -timeAgo) + } + } + return dates.timeInMillis + } + return 0L + } + + // pages + override fun pageListParse(document: Document): List { + val pages = mutableListOf() + var i = 0 + document.select(".container .img_container center img").forEach { element -> + val url = element.attr("src") + i++ + if (url.isNotEmpty()) { + pages.add(Page(i, "", url)) + } + } + return pages + } + + override fun imageUrlParse(document: Document) = "" +}