diff --git a/src/en/explosm/build.gradle b/src/en/explosm/build.gradle new file mode 100644 index 000000000..e6a87d2b4 --- /dev/null +++ b/src/en/explosm/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: Cyanide & Happiness' + pkgNameSuffix = 'en.explosm' + extClass = '.Explosm' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/explosm/res/mipmap-hdpi/ic_launcher.png b/src/en/explosm/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..367996349 Binary files /dev/null and b/src/en/explosm/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/explosm/res/mipmap-mdpi/ic_launcher.png b/src/en/explosm/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..c99982ad9 Binary files /dev/null and b/src/en/explosm/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/explosm/res/mipmap-xhdpi/ic_launcher.png b/src/en/explosm/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..24d58943d Binary files /dev/null and b/src/en/explosm/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/explosm/res/mipmap-xxhdpi/ic_launcher.png b/src/en/explosm/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..434532a0f Binary files /dev/null and b/src/en/explosm/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/explosm/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/explosm/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..a14197407 Binary files /dev/null and b/src/en/explosm/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/explosm/res/web_hi_res_512.png b/src/en/explosm/res/web_hi_res_512.png new file mode 100644 index 000000000..00e116d77 Binary files /dev/null and b/src/en/explosm/res/web_hi_res_512.png differ diff --git a/src/en/explosm/src/eu/kanade/tachiyomi/extension/en/explosm/Explosm.kt b/src/en/explosm/src/eu/kanade/tachiyomi/extension/en/explosm/Explosm.kt new file mode 100644 index 000000000..4d6ea9f72 --- /dev/null +++ b/src/en/explosm/src/eu/kanade/tachiyomi/extension/en/explosm/Explosm.kt @@ -0,0 +1,104 @@ +package eu.kanade.tachiyomi.extension.en.explosm + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.* +import eu.kanade.tachiyomi.source.online.HttpSource +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document +import rx.Observable +import org.jsoup.nodes.Element + +class Explosm : HttpSource() { + + override val name = "Cyanide & Happiness" + + override val baseUrl = "http://explosm.net" + + override val lang = "en" + + override val supportsLatest = false + + override val client: OkHttpClient = network.cloudflareClient + + private fun createManga(element: Element): SManga { + return SManga.create().apply { + initialized = true + title = "C&H ${element.attr("id").substringAfter("panel")}" // year + setUrlWithoutDomain(element.select("li a").first().attr("href")) // January + thumbnail_url = "https://vhx.imgix.net/vitalyuncensored/assets/13ea3806-5ebf-4987-bcf1-82af2b689f77/S2E4_Still1.jpg" + } + } + + // Popular + + override fun popularMangaRequest(page: Int): Request { + return (GET("$baseUrl/comics/archive", headers)) + } + + override fun popularMangaParse(response: Response): MangasPage { + val eachYearAsAManga = response.asJsoup().select("dd.accordion-navigation > div").map { createManga(it) } + + return MangasPage(eachYearAsAManga, false) + } + + // Latest + + override fun latestUpdatesRequest(page: Int): Request = throw UnsupportedOperationException("Not used") + + override fun latestUpdatesParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used") + + // Search + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): Observable = Observable.just(MangasPage(emptyList(), false)) + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = throw UnsupportedOperationException("Not used") + + override fun searchMangaParse(response: Response): MangasPage = throw UnsupportedOperationException("Not used") + + // Details + + override fun mangaDetailsParse(response: Response): SManga { + return createManga(response.asJsoup().select("div.content.active").first()) + } + + // Chapters + + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + + val januaryChapters = document.chaptersFromDocument() // should be at bottom of final returned list + + // get the rest of the year + val chapters = document.select("div.content.active li:not(.active) a").reversed().map { + client.newCall(GET(it.attr("abs:href"), headers)).execute().asJsoup().chaptersFromDocument() + }.flatten() + + return chapters + januaryChapters + } + + private fun Document.chaptersFromDocument(): List { + return this.select("div.inner-wrap > div.row div.row.collapse").map { + SChapter.create().apply { + setUrlWithoutDomain(it.select("a").attr("href")) + name = it.select("div#comic-author").text() + } + } + } + + // Pages + + override fun fetchPageList(chapter: SChapter): Observable> { + return Observable.just(listOf(Page(0, baseUrl + chapter.url))) + } + + override fun pageListParse(response: Response): List = throw UnsupportedOperationException("Not used") + + override fun imageUrlParse(response: Response): String { + return response.asJsoup().select("div#comic-wrap img").attr("abs:src") + } + + override fun getFilterList() = FilterList() +}