diff --git a/src/en/mangaowl/build.gradle b/src/en/mangaowl/build.gradle new file mode 100644 index 000000000..3824f4286 --- /dev/null +++ b/src/en/mangaowl/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: MangaOwl' + pkgNameSuffix = 'en.mangaowl' + extClass = '.MangaOwl' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/mangaowl/res/mipmap-hdpi/ic_launcher.png b/src/en/mangaowl/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..2d63f0ab2 Binary files /dev/null and b/src/en/mangaowl/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/mangaowl/res/mipmap-mdpi/ic_launcher.png b/src/en/mangaowl/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..13b650f39 Binary files /dev/null and b/src/en/mangaowl/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/mangaowl/res/mipmap-xhdpi/ic_launcher.png b/src/en/mangaowl/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..e412e079f Binary files /dev/null and b/src/en/mangaowl/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/mangaowl/res/mipmap-xxhdpi/ic_launcher.png b/src/en/mangaowl/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..644ee754b Binary files /dev/null and b/src/en/mangaowl/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/mangaowl/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/mangaowl/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..3ad68eaa0 Binary files /dev/null and b/src/en/mangaowl/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/mangaowl/res/web_hi_res_512.png b/src/en/mangaowl/res/web_hi_res_512.png new file mode 100644 index 000000000..1e8a6282b Binary files /dev/null and b/src/en/mangaowl/res/web_hi_res_512.png differ diff --git a/src/en/mangaowl/src/eu/kanade/tachiyomi/extension/en/mangaowl/MangaOwl.kt b/src/en/mangaowl/src/eu/kanade/tachiyomi/extension/en/mangaowl/MangaOwl.kt new file mode 100644 index 000000000..7aa202d80 --- /dev/null +++ b/src/en/mangaowl/src/eu/kanade/tachiyomi/extension/en/mangaowl/MangaOwl.kt @@ -0,0 +1,134 @@ +package eu.kanade.tachiyomi.extension.en.mangaowl + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.* +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.text.SimpleDateFormat +import java.util.* + +class MangaOwl : ParsedHttpSource() { + + override val name = "MangaOwl" + + override val baseUrl = "http://mangaowl.com" + + override val lang = "en" + + override val supportsLatest = true + + override val client: OkHttpClient = network.cloudflareClient + + // Popular + + override fun popularMangaRequest(page: Int): Request { + return GET("$baseUrl/popular/$page", headers) + } + + override fun popularMangaSelector() = "div.col-md-2" + + override fun popularMangaFromElement(element: Element): SManga { + val manga = SManga.create() + element.select("h6 a").let { + manga.setUrlWithoutDomain(it.attr("href")) + manga.title = it.text() + } + manga.thumbnail_url = element.select("div.img-responsive").attr("abs:data-background-image") + + return manga + } + + override fun popularMangaNextPageSelector() = "div.blog-pagenat-wthree li a:contains(>>)" + + // Latest + + override fun latestUpdatesRequest(page: Int): Request { + return GET("$baseUrl/lastest/$page", headers) + } + + override fun latestUpdatesSelector() = popularMangaSelector() + + override fun latestUpdatesFromElement(element: Element): SManga = popularMangaFromElement(element) + + override fun latestUpdatesNextPageSelector() = popularMangaNextPageSelector() + + // Search + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { + return GET("$baseUrl/search/$query/$page", headers) + } + + override fun searchMangaSelector() = popularMangaSelector() + + override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) + + override fun searchMangaNextPageSelector() = "div.navigation li a:contains(next)" + + // Manga summary page + + override fun mangaDetailsParse(document: Document): SManga { + val infoElement = document.select("div.col-sm-8").first() + + val manga = SManga.create() + manga.title = infoElement.select("h2").first().ownText() + manga.author = infoElement.select("p:contains(author)").first().ownText() + val status = infoElement.select("p:contains(pub. status)").first().ownText() + manga.status = parseStatus(status) + manga.genre = infoElement.select("a.label").mapNotNull{ it.text() }.joinToString(", ") + manga.description = infoElement.select("div.single-right-grids.description").first().ownText() + manga.thumbnail_url = infoElement.select("div.col-xs-offset-1 img").attr("abs:data-src") + + return manga + } + + private fun parseStatus(status: String?) = when { + status == null -> SManga.UNKNOWN + status.contains("Ongoing") -> SManga.ONGOING + status.contains("Completed") -> SManga.COMPLETED + else -> SManga.UNKNOWN + } + + // Chapters + + override fun chapterListSelector() = "div.table-chapter-list table.table-responsive-md tr" + + override fun chapterFromElement(element: Element): SChapter { + val chapter = SChapter.create() + element.select("a").let { + chapter.setUrlWithoutDomain(it.attr("href")) + chapter.name = it.text() + } + chapter.date_upload = parseChapterDate(element.select("td + td").text()) + + return chapter + } + + companion object { + val dateFormat by lazy { + SimpleDateFormat("MM/dd/yyyy", Locale.US) + } + } + + private fun parseChapterDate(string: String): Long { + return dateFormat.parse(string).time + } + + // Pages + + override fun pageListParse(document: Document): List { + val pages = mutableListOf() + + document.select("div.item img.owl-lazy").forEachIndexed { i, img -> + pages.add(Page(i, "", img.attr("abs:data-src"))) + } + return pages + } + + override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used") + + override fun getFilterList() = FilterList() + +}