diff --git a/src/ru/desu/build.gradle b/src/ru/desu/build.gradle new file mode 100644 index 000000000..963c9ff61 --- /dev/null +++ b/src/ru/desu/build.gradle @@ -0,0 +1,13 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: Desu' + pkgNameSuffix = "ru.desu" + extClass = '.Desu' + extVersionCode = 1 + extVersionSuffix = 0 + libVersion = '1.0' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/ru/desu/res/mipmap-hdpi/ic_launcher.png b/src/ru/desu/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..0cec4aa5f Binary files /dev/null and b/src/ru/desu/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/ru/desu/res/mipmap-mdpi/ic_launcher.png b/src/ru/desu/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..62ed9ff07 Binary files /dev/null and b/src/ru/desu/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/ru/desu/res/mipmap-xhdpi/ic_launcher.png b/src/ru/desu/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..d2daa17db Binary files /dev/null and b/src/ru/desu/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/ru/desu/res/mipmap-xxhdpi/ic_launcher.png b/src/ru/desu/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..2cb012fea Binary files /dev/null and b/src/ru/desu/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/ru/desu/res/mipmap-xxxhdpi/ic_launcher.png b/src/ru/desu/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..415f0fd8b Binary files /dev/null and b/src/ru/desu/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/ru/desu/res/web_hi_res_512.png b/src/ru/desu/res/web_hi_res_512.png new file mode 100644 index 000000000..49c08a9ca Binary files /dev/null and b/src/ru/desu/res/web_hi_res_512.png differ diff --git a/src/ru/desu/src/eu/kanade/tachiyomi/extension/ru/desu/Desu.kt b/src/ru/desu/src/eu/kanade/tachiyomi/extension/ru/desu/Desu.kt new file mode 100644 index 000000000..04b796456 --- /dev/null +++ b/src/ru/desu/src/eu/kanade/tachiyomi/extension/ru/desu/Desu.kt @@ -0,0 +1,114 @@ +package eu.kanade.tachiyomi.extension.ru.desu + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.* +import eu.kanade.tachiyomi.source.online.HttpSource +import okhttp3.Headers +import okhttp3.Request +import okhttp3.Response +import org.json.JSONArray +import org.json.JSONObject +import java.util.* + +class Desu : HttpSource() { + + override val name = "Desu" + + override val baseUrl = "http://desu.me/manga/api" + + override val lang = "ru" + + override val supportsLatest = true + + override fun headersBuilder() = Headers.Builder().apply { + add("User-Agent", "Tachiyomi") + add("Referer", baseUrl) + } + + private fun mangaPageFromJSON(json: String): MangasPage { + val arr = JSONArray(json) + val ret = ArrayList(arr.length()) + for (i in 0 until arr.length()) { + var obj = arr.getJSONObject(i) + ret.add(SManga.create().apply { + mangaFromJSON(obj) + }) + } + return MangasPage(ret, false) + } + + private fun SManga.mangaFromJSON(obj: JSONObject) { + val id = obj.getInt("id") + url = "/$id" + title = obj.getString("name") + thumbnail_url = obj.getJSONObject("image").getString("original") + description = obj.getString("description") + + status = when (obj.getString("status")) { + "ongoing" -> SManga.COMPLETED + "released" -> SManga.ONGOING + else -> SManga.UNKNOWN + } + } + + + override fun popularMangaRequest(page: Int) = GET("$baseUrl/?limit=50&order=popular&page=1") + + override fun popularMangaParse(response: Response) = searchMangaParse(response) + + override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/?limit=1&order=updated&page=1") + + override fun latestUpdatesParse(response: Response): MangasPage = searchMangaParse(response) + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { + return GET("$baseUrl/?limit=1&order=popular&page=1&search=$query") + } + + override fun searchMangaParse(response: Response): MangasPage { + val res = response.body()!!.string() + val obj = JSONObject(res).getJSONArray("response") + return mangaPageFromJSON(obj.toString()) + } + + override fun mangaDetailsParse(response: Response) = SManga.create().apply { + val obj = JSONObject(response.body()!!.string()).getJSONObject("response") + mangaFromJSON(obj) + } + + override fun chapterListParse(response: Response): List { + val obj = JSONObject(response.body()!!.string()).getJSONObject("response") + val ret = ArrayList() + + val cid = obj.getInt("id") + + val arr = obj.getJSONObject("chapters").getJSONArray("list") + for (i in 0 until arr.length()) { + val obj2 = arr.getJSONObject(i) + ret.add(SChapter.create().apply { + val ch = obj2.getString("ch") + val title = if (obj2.getString("title") == "null") "" else obj2.getString("title") + name = "$ch - $title" + val id = obj2.getString("id") + url = "/$cid/chapter/$id" + }) + } + return ret + } + + override fun pageListParse(response: Response): List { + val obj = JSONObject(response.body()!!.string()).getJSONObject("response") + val pages = obj.getJSONObject("pages") + val list = pages.getJSONArray("list") + val ret = ArrayList(list.length()) + for (i in 0 until list.length()) { + ret.add(Page(i, "", list.getJSONObject(i).getString("img"))) + } + return ret + } + + override fun imageUrlParse(response: Response) + = throw UnsupportedOperationException("This method should not be called!") + + override fun getFilterList() = FilterList( + ) +}