diff --git a/src/en/randowiz/AndroidManifest.xml b/src/en/randowiz/AndroidManifest.xml new file mode 100644 index 000000000..30deb7f79 --- /dev/null +++ b/src/en/randowiz/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/src/en/randowiz/build.gradle b/src/en/randowiz/build.gradle new file mode 100644 index 000000000..2e86990c0 --- /dev/null +++ b/src/en/randowiz/build.gradle @@ -0,0 +1,11 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + extName = 'Randowiz' + pkgNameSuffix = 'en.randowiz' + extClass = '.Randowiz' + extVersionCode = 1 +} + +apply from: "$rootDir/common.gradle" diff --git a/src/en/randowiz/res/mipmap-hdpi/ic_launcher.png b/src/en/randowiz/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..bbdfb7b72 Binary files /dev/null and b/src/en/randowiz/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/en/randowiz/res/mipmap-mdpi/ic_launcher.png b/src/en/randowiz/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..7ff435629 Binary files /dev/null and b/src/en/randowiz/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/en/randowiz/res/mipmap-xhdpi/ic_launcher.png b/src/en/randowiz/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..22c76dc10 Binary files /dev/null and b/src/en/randowiz/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/en/randowiz/res/mipmap-xxhdpi/ic_launcher.png b/src/en/randowiz/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..464030f3f Binary files /dev/null and b/src/en/randowiz/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/en/randowiz/res/mipmap-xxxhdpi/ic_launcher.png b/src/en/randowiz/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..29221da30 Binary files /dev/null and b/src/en/randowiz/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/en/randowiz/res/web_hi_res_512.png b/src/en/randowiz/res/web_hi_res_512.png new file mode 100644 index 000000000..623c98f98 Binary files /dev/null and b/src/en/randowiz/res/web_hi_res_512.png differ diff --git a/src/en/randowiz/src/eu/kanade/tachiyomi/extension/en/randowiz/Randowiz.kt b/src/en/randowiz/src/eu/kanade/tachiyomi/extension/en/randowiz/Randowiz.kt new file mode 100644 index 000000000..eeda9163f --- /dev/null +++ b/src/en/randowiz/src/eu/kanade/tachiyomi/extension/en/randowiz/Randowiz.kt @@ -0,0 +1,166 @@ +package eu.kanade.tachiyomi.extension.en.randowiz + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage +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 eu.kanade.tachiyomi.util.asJsoup +import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element +import rx.Observable +import java.text.SimpleDateFormat +import java.util.Locale + +class Randowiz : ParsedHttpSource() { + + override val name = "Randowiz" + + override val baseUrl = "https://randowis.com" + + override val lang = "en" + + override val supportsLatest = false + + override fun fetchPopularManga(page: Int): Observable { + return Observable.just( + MangasPage( + listOf( + SManga.create().apply { + title = "Randowiz: We live in an MMO!?" + artist = "Randowiz" + author = "Randowiz" + status = SManga.ONGOING + url = "/category/we-live-in-an-mmo/" + description = + "The world of 'Mamuon' where players and NPC's live together in harmony. Or do they? DO THEY?" + thumbnail_url = + "https://i0.wp.com/randowis.com/wp-content/uploads/2016/02/MMO_CHP_001_CSP_000.jpg?resize=800%2C800&ssl=1" + }, + SManga.create().apply { + title = "Randowiz: Short comics" + artist = "Randowiz" + author = "Randowiz" + status = SManga.ONGOING + url = "/category/short-comics/" + description = + "So short that i have to compensate.." + thumbnail_url = + "https://i0.wp.com/randowis.com/wp-content/uploads/2021/10/Images_PNGs_Site_BOT-SUPPORT.png" + }, + SManga.create().apply { + title = "Randowiz: Illustations" + artist = "Randowiz" + author = "Randowiz" + status = SManga.ONGOING + url = "/category/art/" + description = + "You like draw? I give you draw." + thumbnail_url = + "https://i0.wp.com/randowis.com/wp-content/uploads/2021/05/colour-studies-021-post.jpg" + } + ), + false + ) + ) + } + + override fun fetchSearchManga( + page: Int, + query: String, + filters: FilterList + ): Observable = fetchPopularManga(page).map { + MangasPage( + it.mangas.filter { manga -> + manga.title.contains( + query, + ignoreCase = true + ) + }, + false + ) + } + + override fun fetchMangaDetails(manga: SManga): Observable = Observable.just(manga) + + override fun chapterListParse(response: Response): List { + val document = response.asJsoup() + val chapters = document.select(chapterListSelector()) + .map { chapterFromElement(it) } + .toMutableList() + var next = document.selectFirst(".next")?.attr("href") ?: "" + + while (next.isNotEmpty()) { + val nextDocument = client.newCall(GET(next, headers)).execute().asJsoup() + + chapters += nextDocument.select(chapterListSelector()) + .map { chapterFromElement(it) } + next = nextDocument.selectFirst(".next")?.attr("href") ?: "" + } + + return chapters.mapIndexed { i, chapter -> + chapter.apply { chapter_number = chapters.size.toFloat() - i } + } + } + + override fun chapterListSelector() = ".has-post-thumbnail" + + override fun chapterFromElement(element: Element): SChapter { + val linkTag = element.select(".elementor-post__title a").first() + val chapter = SChapter.create() + chapter.name = linkTag.text() + chapter.url = linkTag.attr("href").split(".com")[1] + chapter.date_upload = parseDate(element.select(".elementor-post-date").text()) + return chapter + } + + override fun pageListParse(document: Document): List { + val imgs = document.select(".elementor-widget-theme-post-content img[data-permalink]") + return imgs.mapIndexed { index, img -> + Page(index, url = "", imageUrl = img.attr("src")) + } + } + + override fun imageUrlParse(document: Document) = throw Exception("Not used") + + override fun popularMangaSelector(): String = throw Exception("Not used") + + override fun searchMangaFromElement(element: Element): SManga = throw Exception("Not used") + + override fun searchMangaNextPageSelector(): String = throw Exception("Not used") + + override fun searchMangaSelector(): String = throw Exception("Not used") + + override fun popularMangaRequest(page: Int): Request = throw Exception("Not used") + + override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request = + throw Exception("Not used") + + override fun popularMangaNextPageSelector(): String = throw Exception("Not used") + + override fun popularMangaFromElement(element: Element): SManga = throw Exception("Not used") + + override fun mangaDetailsParse(document: Document): SManga = throw Exception("Not used") + + override fun latestUpdatesNextPageSelector(): String = throw Exception("Not used") + + override fun latestUpdatesFromElement(element: Element): SManga = throw Exception("Not used") + + override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not used") + + override fun latestUpdatesSelector(): String = throw Exception("Not used") + + private fun parseDate(dateStr: String): Long { + return runCatching { DATE_FORMATTER.parse(dateStr)?.time }.getOrNull() ?: 0L + } + + companion object { + private val DATE_FORMATTER by lazy { + SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH) + } + } +}