diff --git a/src/ar/teamx/build.gradle b/src/ar/teamx/build.gradle new file mode 100644 index 000000000..98bf3335a --- /dev/null +++ b/src/ar/teamx/build.gradle @@ -0,0 +1,12 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' + +ext { + appName = 'Tachiyomi: Team X' + pkgNameSuffix = 'ar.teamx' + extClass = '.TeamX' + extVersionCode = 1 + libVersion = '1.2' +} + +apply from: "$rootDir/common.gradle" diff --git a/src/ar/teamx/res/mipmap-hdpi/ic_launcher.png b/src/ar/teamx/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000..56a895c40 Binary files /dev/null and b/src/ar/teamx/res/mipmap-hdpi/ic_launcher.png differ diff --git a/src/ar/teamx/res/mipmap-mdpi/ic_launcher.png b/src/ar/teamx/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000..c4cbda740 Binary files /dev/null and b/src/ar/teamx/res/mipmap-mdpi/ic_launcher.png differ diff --git a/src/ar/teamx/res/mipmap-xhdpi/ic_launcher.png b/src/ar/teamx/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000..74f832995 Binary files /dev/null and b/src/ar/teamx/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/src/ar/teamx/res/mipmap-xxhdpi/ic_launcher.png b/src/ar/teamx/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000..52aa5662a Binary files /dev/null and b/src/ar/teamx/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/src/ar/teamx/res/mipmap-xxxhdpi/ic_launcher.png b/src/ar/teamx/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000..be7afc74c Binary files /dev/null and b/src/ar/teamx/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/src/ar/teamx/res/web_hi_res_512.png b/src/ar/teamx/res/web_hi_res_512.png new file mode 100644 index 000000000..12cfe7ef5 Binary files /dev/null and b/src/ar/teamx/res/web_hi_res_512.png differ diff --git a/src/ar/teamx/src/eu/kanade/tachiyomi/extension/ar/teamx/TeamX.kt b/src/ar/teamx/src/eu/kanade/tachiyomi/extension/ar/teamx/TeamX.kt new file mode 100644 index 000000000..b992ad434 --- /dev/null +++ b/src/ar/teamx/src/eu/kanade/tachiyomi/extension/ar/teamx/TeamX.kt @@ -0,0 +1,129 @@ +package eu.kanade.tachiyomi.extension.ar.teamx + +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.source.model.* +import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response +import org.jsoup.nodes.Document +import org.jsoup.nodes.Element + +class TeamX : ParsedHttpSource() { + + override val name = "Team X" + + override val baseUrl = "https://team1x1.com" + + override val lang = "ar" + + override val supportsLatest = true + + override val client: OkHttpClient = network.cloudflareClient + + // Popular + + override fun popularMangaRequest(page: Int): Request { + return GET("$baseUrl/manga/" + if (page > 1) "page/$page/" else "", headers) + } + + override fun popularMangaSelector() = "div.last-post-manga" + + private val titleSelector = "h3 a" + + override fun popularMangaFromElement(element: Element): SManga { + return SManga.create().apply { + title = element.select(titleSelector).text() + setUrlWithoutDomain(element.select("a").first().attr("href")) + thumbnail_url = element.select("img").first().attr("abs:src") + } + } + + override fun popularMangaNextPageSelector() = "i.fa-chevron-left" + + // Latest + + private val titlesAdded = mutableSetOf() + + override fun latestUpdatesRequest(page: Int): Request { + if (page == 1) titlesAdded.clear() + + return GET("$baseUrl/فصول-المانجا/" + if (page > 1) "page/$page/" else "", headers) + } + + override fun latestUpdatesParse(response: Response): MangasPage { + val document = response.asJsoup() + + val mangas = document.select(latestUpdatesSelector()) + .distinctBy { it.select(titleSelector).text() }.let { elements -> + if (titlesAdded.isNotEmpty()) elements.filter { it.select(titleSelector).text() !in titlesAdded } else elements + } + .map { + titlesAdded.add(it.select(titleSelector).text()) + latestUpdatesFromElement(it) + } + + return MangasPage(mangas, document.select(latestUpdatesNextPageSelector()).isNotEmpty()) + } + + 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 { + if (page == 1) titlesAdded.clear() + + return GET("$baseUrl/" + (if (page > 1) "page/$page/" else "") + "?s=$query", headers) + } + + override fun searchMangaParse(response: Response): MangasPage = latestUpdatesParse(response) + + override fun searchMangaSelector() = popularMangaSelector() + + override fun searchMangaFromElement(element: Element): SManga = popularMangaFromElement(element) + + override fun searchMangaNextPageSelector() = popularMangaNextPageSelector() + + // Details + + override fun mangaDetailsParse(document: Document): SManga { + return document.select("div.single-manga > div.container > div.row").let { info -> + SManga.create().apply { + title = info.select("div.col-md-9").text() + description = info.select("div.story p").text() + genre = info.select("div.genre a").joinToString { it.text() } + thumbnail_url = info.select("img").attr("abs:src") + } + } + } + + // Chapters + + // Filter out the fake chapters + override fun chapterListSelector() = "div.single-manga-chapter div.col-md-12 a[href^=$baseUrl]" + + override fun chapterFromElement(element: Element): SChapter { + return SChapter.create().apply { + name = element.text() + setUrlWithoutDomain(element.attr("href")) + } + } + + // Pages + + override fun pageListParse(document: Document): List { + return document.select("div#translationPageall img").mapIndexed { i, img -> + Page(i, "", img.attr("abs:src")) + } + } + + override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException("Not used") + + override fun getFilterList() = FilterList() + +}