diff --git a/src/en/vgperson/build.gradle b/src/en/vgperson/build.gradle new file mode 100644 index 000000000..d11d0345e --- /dev/null +++ b/src/en/vgperson/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: vgperson' + pkgNameSuffix = 'en.vgperson' + extClass = '.Vgperson' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/vgperson/res/mipmap-hdpi/ic_launcher.png b/src/en/vgperson/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..a8e2402ac Binary files /dev/null and b/src/en/vgperson/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/vgperson/res/mipmap-mdpi/ic_launcher.png b/src/en/vgperson/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..0a925b7dd Binary files /dev/null and b/src/en/vgperson/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/vgperson/res/mipmap-xhdpi/ic_launcher.png b/src/en/vgperson/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..44363b173 Binary files /dev/null and b/src/en/vgperson/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/vgperson/res/mipmap-xxhdpi/ic_launcher.png b/src/en/vgperson/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..2126db0ec Binary files /dev/null and b/src/en/vgperson/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/vgperson/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/vgperson/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..3df99c376 Binary files /dev/null and b/src/en/vgperson/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/vgperson/res/web_hi_res_512.png b/src/en/vgperson/res/web_hi_res_512.png new file mode 100644 index 000000000..070bdc94d Binary files /dev/null and b/src/en/vgperson/res/web_hi_res_512.png differ diff --git a/src/en/vgperson/src/eu/kanade/tachiyomi/extension/en/vgperson/Vgperson.kt b/src/en/vgperson/src/eu/kanade/tachiyomi/extension/en/vgperson/Vgperson.kt new file mode 100644 index 000000000..e76425c2f --- /dev/null +++ b/src/en/vgperson/src/eu/kanade/tachiyomi/extension/en/vgperson/Vgperson.kt @@ -0,0 +1,135 @@ +package eu.kanade.tachiyomi.extension.en.vgperson + +import android.os.Build.VERSION +import eu.kanade.tachiyomi.extension.BuildConfig +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.network.asObservableSuccess +import eu.kanade.tachiyomi.source.model.* +import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import okhttp3.Headers +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import org.jsoup.nodes.TextNode +import rx.Observable + +class Vgperson : ParsedHttpSource() { + + override val name = "vgperson" + + override val lang = "en" + + override val supportsLatest = false + + override val baseUrl = "http://vgperson.com/other/mangaviewer.php" + + private val userAgent = "Mozilla/5.0 " + + "(Android ${VERSION.RELEASE}; Mobile) " + + "Tachiyomi/${BuildConfig.VERSION_NAME}" + + override fun headersBuilder() = Headers.Builder().apply { + add("User-Agent", userAgent) + add("Referer", baseUrl) + } + + override fun popularMangaSelector() = ".content a[href^=?m]" + + override fun popularMangaNextPageSelector() = null + + override fun popularMangaRequest(page: Int) = GET(baseUrl, headers) + + override fun popularMangaFromElement(element: Element) = SManga.create().apply { + title = element.text() + url = element.attr("href") + thumbnail_url = getCover(title) + } + + override fun fetchMangaDetails(manga: SManga) = + client.newCall(mangaDetailsRequest(manga)).asObservableSuccess().map { + mangaDetailsParse(it).apply { + url = manga.url + title = manga.title + thumbnail_url = manga.thumbnail_url + initialized = true + } + } + + override fun mangaDetailsParse(document: Document) = SManga.create().apply { + status = when (document.select(".chaptername").first().text()) { + "(Complete)" -> SManga.COMPLETED + "(Series in Progress)" -> SManga.ONGOING + else -> SManga.UNKNOWN + } + description = document.select(".content").first() + .childNodes().drop(5).takeWhile { + it.nodeName() != "table" + }.joinToString("") { + if (it is TextNode) it.text() + else when ((it as Element).tagName()) { + "br" -> "\n" + else -> it.text() + } + } + } + + override fun chapterListSelector() = ".chaptertable tbody tr" + + override fun chapterFromElement(element: Element) = SChapter.create().apply { + element.select("td > a").first().let { + name = it.text() + url = it.attr("href") + } + // append the name if it exists & remove the occasional hyphen + element.select(".chaptername")?.first()?.let { + name += " - ${it.text().substringAfter("- ")}" + } + // hardcode special chapter numbers for Three Days of Happiness + chapter_number = url.substringAfterLast("c=").toFloatOrNull() + ?: 16.5f + "0.${url.substringAfterLast("b=")}".toFloat() + scanlator = "vgperson" + date_upload = 0L + } + + override fun chapterListParse(response: Response) = + super.chapterListParse(response).sortedByDescending(SChapter::chapter_number) + + override fun pageListParse(document: Document) = + document.select("img").mapIndexed { i, img -> Page(i, "", img.attr("src")) } + + override fun fetchSearchManga(page: Int, query: String, filters: FilterList): + Observable = Observable.empty() + + // get known manga covers from imgur + private fun getCover(title: String) = when (title) { + "The Festive Monster's Cheerful Failure" -> "kEK10GL.png" + "Azure and Claude" -> "buXnlmh.jpg" + "Three Days of Happiness" -> "kL5dvnp.jpg" + else -> null + }?.let { "http://i.imgur.com/$it" } + + override fun latestUpdatesSelector() = "" + + override fun latestUpdatesNextPageSelector() = null + + override fun latestUpdatesRequest(page: Int) = + throw UnsupportedOperationException("This method should not be called!") + + override fun latestUpdatesFromElement(element: Element) = + throw UnsupportedOperationException("This method should not be called!") + + override fun searchMangaSelector() = "" + + override fun searchMangaNextPageSelector() = null + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList) = + throw UnsupportedOperationException("This method should not be called!") + + override fun searchMangaFromElement(element: Element) = + throw UnsupportedOperationException("This method should not be called!") + + override fun searchMangaParse(response: Response) = + throw UnsupportedOperationException("This method should not be called!") + + override fun imageUrlParse(document: Document) = + throw UnsupportedOperationException("This method should not be called!") +}