diff --git a/src/all/erocool/AndroidManifest.xml b/src/all/erocool/AndroidManifest.xml new file mode 100644 index 000000000..30deb7f79 --- /dev/null +++ b/src/all/erocool/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/src/all/erocool/build.gradle b/src/all/erocool/build.gradle new file mode 100644 index 000000000..4a4726a4d --- /dev/null +++ b/src/all/erocool/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + extName = 'EroCool' + pkgNameSuffix = 'all.erocool' + extClass = '.EroCoolFactory' + extVersionCode = 1 + isNsfw = true +} + +apply from: "$rootDir/common.gradle" diff --git a/src/all/erocool/res/mipmap-hdpi/ic_launcher.png b/src/all/erocool/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..cd8aae645 Binary files /dev/null and b/src/all/erocool/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/all/erocool/res/mipmap-mdpi/ic_launcher.png b/src/all/erocool/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..3ba1f1472 Binary files /dev/null and b/src/all/erocool/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/all/erocool/res/mipmap-xhdpi/ic_launcher.png b/src/all/erocool/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..4628cbe30 Binary files /dev/null and b/src/all/erocool/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/all/erocool/res/mipmap-xxhdpi/ic_launcher.png b/src/all/erocool/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..f3e0a8125 Binary files /dev/null and b/src/all/erocool/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/all/erocool/res/mipmap-xxxhdpi/ic_launcher.png b/src/all/erocool/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..4bb071195 Binary files /dev/null and b/src/all/erocool/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/all/erocool/res/web_hi_res_512.png b/src/all/erocool/res/web_hi_res_512.png new file mode 100644 index 000000000..7d6af5c56 Binary files /dev/null and b/src/all/erocool/res/web_hi_res_512.png differ diff --git a/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCool.kt b/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCool.kt new file mode 100644 index 000000000..b677edb45 --- /dev/null +++ b/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCool.kt @@ -0,0 +1,108 @@ +package eu.kanade.tachiyomi.extension.all.erocool + +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 org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import java.text.SimpleDateFormat +import java.util.Locale + +class EroCool( + override val lang: String, + private val langName: String, + number: Int +) : ParsedHttpSource() { + override val name = "EroCool" + + override val baseUrl = "https://$lang.erocool$number.com" + + override val supportsLatest = true + + override fun latestUpdatesSelector() = GALLERY_SELECTOR + + override fun latestUpdatesNextPageSelector() = NEXT_PAGE_SELECTOR + + override fun latestUpdatesRequest(page: Int) = + GET("$baseUrl/language/$langName/page/$page", headers) + + override fun latestUpdatesFromElement(element: Element) = element.toManga() + + override fun popularMangaSelector() = GALLERY_SELECTOR + + override fun popularMangaNextPageSelector() = NEXT_PAGE_SELECTOR + + override fun popularMangaRequest(page: Int) = + GET("$baseUrl/language/$langName/popular/page/$page", headers) + + override fun popularMangaFromElement(element: Element) = element.toManga() + + override fun searchMangaSelector() = GALLERY_SELECTOR + + override fun searchMangaNextPageSelector() = NEXT_PAGE_SELECTOR + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = + if (query.isBlank()) popularMangaRequest(page) + else GET("$baseUrl/search/q_$query $langName", headers) + + override fun searchMangaFromElement(element: Element) = element.toManga() + + override fun mangaDetailsParse(document: Document) = SManga.create().apply { + description = document.selectFirst(".breadtitle")?.text() + genre = document.select(TAGS_SELECTOR)?.joinToString { it.text() } + artist = document.select(ARTISTS_SELECTOR)?.joinToString { it.text() } + author = document.select(GROUPS_SELECTOR) + ?.joinToString { it.text() }?.ifEmpty { artist } ?: artist + } + + override fun chapterListSelector() = "#comicdetail" + + override fun chapterFromElement(element: Element) = SChapter.create().apply { + name = "Chapter" + chapter_number = -1f + date_upload = element.uploadDate() + setUrlWithoutDomain(element.baseUri()) + } + + override fun pageListParse(document: Document) = + document.select(".vimg.lazyload").mapIndexed { idx, img -> + Page(idx, "", img.absUrl("data-src")) + } + + override fun imageUrlParse(document: Document) = + throw UnsupportedOperationException("Not used") + + private fun Element.toManga() = SManga.create().also { + it.url = attr("href") + it.title = selectFirst(".caption").attr("title") + it.thumbnail_url = selectFirst(".list-content") + .attr("style").substringAfter('(').substringBefore(')') + } + + private fun Element.uploadDate() = + dateFormat.parse(selectFirst(DATE_SELECTOR).text())?.time ?: 0L + + companion object { + private const val GALLERY_SELECTOR = ".gallery" + + private const val NEXT_PAGE_SELECTOR = ".list-p-li > a[rel=next]" + + private const val DATE_SELECTOR = ".ld_box > div:first-child > .ld_body" + + private const val GROUPS_SELECTOR = ".ld_boxs .ld_bodys[href^=/group/]" + + private const val ARTISTS_SELECTOR = ".ld_boxs .ld_bodys[href^=/artist/]" + + private const val TAGS_SELECTOR = + ".ld_boxs .ld_bodys[href^=/parody/]," + + ".ld_boxs .ld_bodys[href^=/tag/]," + + ".ld_boxs .ld_bodys[href^=/category/]" + + private val dateFormat by lazy { + SimpleDateFormat("yyyy/MM/dd", Locale.ROOT) + } + } +} diff --git a/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCoolFactory.kt b/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCoolFactory.kt new file mode 100644 index 000000000..9c013b090 --- /dev/null +++ b/src/all/erocool/src/eu/kanade/tachiyomi/extension/all/erocool/EroCoolFactory.kt @@ -0,0 +1,11 @@ +package eu.kanade.tachiyomi.extension.all.erocool + +import eu.kanade.tachiyomi.source.SourceFactory + +class EroCoolFactory : SourceFactory { + override fun createSources() = listOf( + EroCool("en", "english", 1), + EroCool("ja", "japanese", 2), + EroCool("zh", "chinese", 3), + ) +}